Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Threading.Tasks;
- using Discord;
- using Discord.WebSocket;
- using System;
- namespace Hello_World
- {
- class Program
- {
- static DiscordSocketClient NotifEventBot = new DiscordSocketClient(new DiscordSocketConfig { LogLevel = LogSeverity.Verbose });
- static async Task AsyncBot()
- {
- await NotifEventBot.LoginAsync(TokenType.Bot, "NDUzNTEyNjk3MzQ3MDQ3NDI1.DfsSrQ.5-mFg4BotcSLrYsSfu-1n0jo964");
- await NotifEventBot.StartAsync();
- await NotifEventBot.SetGameAsync("Need help? Write .commands");
- NotifEventBot.MessageReceived += MessageReceived;
- NotifEventBot.Log += (logMsg) =>
- {
- Console.WriteLine(logMsg.Message);
- return null;
- };
- await Task.Delay(-1);
- }
- static async Task MessageReceived(SocketMessage Context)
- {
- string Message = Context.Content.ToLower();
- var Server = (Context.Channel as SocketGuildChannel).Guild;
- if(Message == ".commands" && Server.Id == 447023289634783232)
- {
- if (Context.Channel.Id == 458948229787287562)
- {
- await Context.Channel.SendMessageAsync("Commands:```js\n.role add NotifEvent //gives you the Notif-Event role\n.role delete NotifEvent //removes your Notif-Event role```");
- }
- else
- {
- var RepliedMessage = await Context.Channel.SendMessageAsync(Context.Author.Mention + ", commands are disable for this channel. Please use <#458948229787287562>.");
- await Task.Delay(7000);
- await RepliedMessage.DeleteAsync();
- await Context.DeleteAsync();
- }
- }
- else if(Message == ".role add notifevent" && Server.Id == 447023289634783232)
- {
- if (Context.Channel.Id == 458948229787287562)
- {
- try
- {
- await (Context.Author as IGuildUser).AddRoleAsync(Server.GetRole(448400139594366998));
- await Context.Channel.SendMessageAsync("You have been given the Notif-Event role!");
- }
- catch(Exception Error)
- {
- Console.WriteLine(Error.ToString());
- }
- }
- else
- {
- var RepliedMessage = await Context.Channel.SendMessageAsync(Context.Author.Mention + ", commands are disable for this channel. Please use <#458948229787287562>.");
- await Task.Delay(7000);
- await RepliedMessage.DeleteAsync();
- await Context.DeleteAsync();
- }
- }
- else if (Message == ".role delete notifevent" && Server.Id == 447023289634783232)
- {
- if (Context.Channel.Id == 458948229787287562)
- {
- try
- {
- await (Context.Author as IGuildUser).RemoveRoleAsync(Server.GetRole(448400139594366998));
- await Context.Channel.SendMessageAsync("I successfully removed your Notif-Event role!");
- }
- catch(Exception Error)
- {
- Console.WriteLine(Error.ToString());
- }
- }
- else
- {
- var RepliedMessage = await Context.Channel.SendMessageAsync(Context.Author.Mention + ", commands are disable for this channel. Please use <#458948229787287562>.");
- await Task.Delay(7000);
- await RepliedMessage.DeleteAsync();
- await Context.DeleteAsync();
- }
- }
- else if(Message.StartsWith(".announce ") && Context.Channel.Id == 453189954365947904 && Message.Length != 10)
- {
- try
- {
- var UserRoles = (Context.Author as IGuildUser).RoleIds;
- foreach (var Role in UserRoles)
- {
- if (Role == 453189351980007424)
- {
- await (Server.GetChannel(447033846316269568) as ISocketMessageChannel).SendMessageAsync(Context.Content.Substring(10));
- await Context.Channel.SendMessageAsync("Successfully announced your message!");
- return;
- }
- }
- await Context.Channel.SendMessageAsync("You need to have the Host role before you can use this command.");
- }
- catch(Exception Error)
- {
- Console.WriteLine(Error.ToString());
- }
- }
- }
- static void Main(string[] args)
- {
- AsyncBot().Wait();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement