public static async Task Maindo(SocketMessage arg) { try { var GuildId = ((SocketTextChannel)arg.Channel).Guild.Id; int Ran = new Random().Next(1, CustomResponses.WordResp.Count); CustomResponses.UpdateResponses(); bool CusResp = await SetupX(arg, $"Would you like me to send occasional replies to certain messages?\n\n`Reply with 'yes' or 'no'`"); await arg.Channel.TriggerTypingAsync(); Thread.Sleep(1250); bool GloblCht = await SetupX(arg, $"Do you want to participate in MGX globalchat?\nMGX globalchat allows your server to communicate with other servers through a specific channel. If you'd like more information about it, please friend and message {Program.MyAccount.Username}#{Program.MyAccount.Discriminator}.\n\n`Reply with 'yes' or 'no'`"); if (GloblCht) { await globalchat.DefSet(arg, true); } await arg.Channel.TriggerTypingAsync(); Thread.Sleep(2000); bool QuarantineCmd = await SetupX(arg, $"{Program.Prefix}quarantine is a command that can be used by anyone, and can mute people (it was created more as a meme than for genuine usefullness). Would you like this command to be usable?\n\n`Reply with 'yes' or 'no'`"); GuildStuff.NewGuildSetting(GuildStuff.GuildSettings.CustomResponses, GuildId, CusResp); GuildStuff.NewGuildSetting(GuildStuff.GuildSettings.CanUseQuarantine, GuildId, QuarantineCmd); string Desc = $"**Applied New Settings!**\nCongrats! You've successfully setup your server for use with {Program.Client.CurrentUser.Username}.\nCurrent settings:\n```\nCustom Responses: {ResolveBool(CusResp)}\nMGX Globalchat: {ResolveBool(GloblCht)}\nQuarantine Command: {ResolveBool(QuarantineCmd)}\n```"; var Emb = CreateEmbed($"{Program.Client.CurrentUser.Username}", "<3", Desc, null); await arg.Channel.SendMessageAsync("", false, Emb); } catch (Exception e) { Console.WriteLine(e); } }
public static async Task Maindo(SocketMessage arg) { if (arg.MentionedUsers.Count() > 0) { var User = arg.MentionedUsers.First(); var Guild = ((SocketGuildChannel)arg.Channel).Guild; if (User.Id == Program.Client.CurrentUser.Id) { await arg.Channel.SendMessageAsync("But I'm MGX ;c"); } else if (GuildStuff.ReadRank(Guild.Id, User.Id) != 19) { await arg.Channel.SendMessageAsync($"{User.Username} Isn't an administrator"); } else { GuildStuff.SetRank(Guild.Id, User.Id, 1); await arg.Channel.SendMessageAsync($"Successfully removed {User.Username} from administrator"); } } else { await arg.Channel.SendMessageAsync($"Please mention user to unadmin. Eg; '{Program.Prefix}unadmin <@{Program.Client.CurrentUser.Id}>'"); } }
public static async Task Maindo(SocketMessage arg) { var Guild = ((SocketGuildChannel)arg.Channel).Guild; SocketGuildUser UserToCheck = arg.MentionedUsers.Count >= 1 ? arg.MentionedUsers.First() as SocketGuildUser : arg.Author as SocketGuildUser; string TitleOfBuilder = $"{UserToCheck.Username}'s Rank"; var Builder = new EmbedBuilder() { Title = TitleOfBuilder, Color = Color.LightOrange, Footer = new EmbedFooterBuilder() { Text = "ure kinda nice <3" }, ThumbnailUrl = UserToCheck.GetAvatarUrl(), Timestamp = DateTime.UtcNow, }; var Field = new EmbedFieldBuilder() { Name = "Name", Value = GuildStuff.GetNameOfRank(GuildStuff.ReadRank(Guild.Id, UserToCheck.Id)) }; Builder.AddField(Field); await arg.Channel.SendMessageAsync("", false, Builder.Build()); }
public static async Task DefSet(SocketMessage arg, bool SecondCheck) { try { var Guild = ((SocketGuildChannel)arg.Channel).Guild; bool GlobalChatEnabled = GuildStuff.ReadSetting(GuildStuff.GuildSettings.GlobalChannelForOthers, Guild.Id); if (arg.MentionedChannels.Count > 0) { var NewGlobalChannel = (SocketTextChannel)arg.MentionedChannels.First(); GuildStuff.NewGuildSetting(GuildStuff.GuildSettings.GlobalChannelForOthers, Guild.Id, true, NewGlobalChannel.Id); await arg.Channel.SendMessageAsync($"{NewGlobalChannel.Mention} is now MGX's global chat. Send a message there and it'll be sent to all other MGX chats in other servers."); } else if (GlobalChatEnabled && !SecondCheck) { GuildStuff.NewGuildSetting(GuildStuff.GuildSettings.GlobalChannelForOthers, Guild.Id, false); await arg.Channel.SendMessageAsync($"Global chat for this server has been removed."); } else { await arg.Channel.SendMessageAsync($"Please mention a channel to use as MGX's global chat."); var Response = await new WaitForResponse() { TimeLimitS = 30, ChannelId = arg.Channel.Id, UserId = arg.Author.Id }.Start(); if (Response != null && Response.MentionedChannels.Count > 0) { var NewGlobalChannel = (SocketTextChannel)Response.MentionedChannels.First(); GuildStuff.NewGuildSetting(GuildStuff.GuildSettings.GlobalChannelForOthers, Guild.Id, true, NewGlobalChannel.Id); await arg.Channel.SendMessageAsync($"{NewGlobalChannel.Mention} is now MGX's global chat. Send a message there and it'll be sent to all other MGX chats in other servers."); } else { await arg.Channel.SendMessageAsync("No channel set!"); } } } catch (Exception e) { Console.WriteLine(e); } }
public static async Task Maindo(SocketMessage arg) { var GuildCh = arg.Channel as SocketGuildChannel; var Guild = GuildCh.Guild; bool Cur = GuildStuff.ReadSetting(GuildStuff.GuildSettings.CustomResponses, Guild.Id); if (!Cur) { await arg.Channel.SendMessageAsync($"Custom responses enabled"); GuildStuff.NewGuildSetting(GuildStuff.GuildSettings.CustomResponses, Guild.Id, true); } else { await arg.Channel.SendMessageAsync($"Custom responses disabled"); GuildStuff.NewGuildSetting(GuildStuff.GuildSettings.CustomResponses, Guild.Id, false); } }
public static async Task Maindo(SocketMessage arg) { if (arg.MentionedUsers.Count() > 0) { var User = arg.MentionedUsers.First(); var Guild = ((SocketGuildChannel)arg.Channel).Guild; if (User.Id == Program.Client.CurrentUser.Id) { await arg.Channel.SendMessageAsync("already got higher roles so gl with that noob"); } else if (GuildStuff.ReadRank(Guild.Id, User.Id) >= 19) { await arg.Channel.SendMessageAsync($"{User.Username} Is already an administrator or higher"); } else { GuildStuff.SetRank(Guild.Id, User.Id, 19); await arg.Channel.SendMessageAsync($"Successfully added {User.Username} as an administrator"); } } }
public static async Task Maindo(SocketMessage arg) { if (arg.MentionedUsers.Count() > 0) { var User = arg.MentionedUsers.First(); var Guild = ((SocketGuildChannel)arg.Channel).Guild; if (User.Id == Program.Client.CurrentUser.Id) { await arg.Channel.SendMessageAsync("But I'm MGX );"); return; } if (GuildStuff.ReadRank(Guild.Id, User.Id) >= 18) { await arg.Channel.SendMessageAsync($"{User.Username} Is already a moderator or higher"); } else { GuildStuff.SetRank(Guild.Id, User.Id, 18); await arg.Channel.SendMessageAsync($"Successfully added {User.Username} as a moderator"); } } }
public static async Task Maindo(SocketMessage arg) { try { if (arg.Content.ToLower().Contains("disable")) { GuildStuff.NewGuildSetting(GuildStuff.GuildSettings.CanUseQuarantine, ((SocketTextChannel)arg.Channel).Guild.Id, false); await arg.Channel.SendMessageAsync("No more quarantining in this server!"); } else if (GuildStuff.ReadSetting(GuildStuff.GuildSettings.CanUseQuarantine, ((SocketTextChannel)arg.Channel).Guild.Id)) { var Guild = ((SocketGuildChannel)arg.Channel).Guild; Emoji VoteYes = new Emoji("☣"); Emoji VoteNo = new Emoji("👎"); var User = arg.MentionedUsers.Count() >= 1 ? arg.MentionedUsers.First() : arg.Author; if (!AUsers.ContainsKey(arg.Author.Id)) { if (AUsers.ContainsKey(User.Id)) { AUsers.TryRemove(User.Id, out ulong Value); await arg.Channel.SendMessageAsync($"User {User.Mention} removed from quarantine."); } else { var Embed = new EmbedBuilder() { Footer = new EmbedFooterBuilder() { Text = $"If you want this command disabled, type '{Program.Prefix}quarantine disable'" }, Timestamp = DateTime.UtcNow, Color = Color.Orange, Description = $"Should {User.Mention} Be Quarantined?", Fields = new List <EmbedFieldBuilder>() { { new EmbedFieldBuilder() { Name = "Vote", Value = $"{VoteYes} - Yes\n{VoteNo} - No", } } }, ThumbnailUrl = User.GetAvatarUrl() != null?User.GetAvatarUrl() : Program.Client.CurrentUser.GetAvatarUrl(), }; var Msg = await arg.Channel.SendMessageAsync("", false, Embed.Build()); new Thread(async x => { await Msg.AddReactionsAsync(new[] { VoteYes, VoteNo }); int VotesInFavor = 0; ulong Target = User.Id; Func <Cacheable <IUserMessage, ulong>, ISocketMessageChannel, SocketReaction, Task> Ev = (arg1, arg2, arg3) => { if (arg3.Emote.Name == "☣") { VotesInFavor++; } else if (arg3.Emote.Name == "👎") { VotesInFavor--; } return(Task.CompletedTask); }; Program.Client.ReactionAdded += Ev; Thread.Sleep(10000); if (VotesInFavor >= 0) { AUsers.TryAdd(User.Id, Guild.Id); var MsgOfMGX = await arg.Channel.SendMessageAsync($"<@{Target}> is being quarantined.."); long MsgCount = 0; Task MessageEv(SocketMessage MsgArg) { var ThisGuild = ((SocketGuildChannel)MsgArg.Channel).Guild; if (!MsgArg.Author.IsBot && MsgArg.Author.Id == Target && MsgArg.Channel.Id == arg.Channel.Id && AUsers.ContainsKey(Target) && AUsers[Target] == ThisGuild.Id) { MsgCount++; MsgArg.DeleteAsync(); MsgOfMGX.ModifyAsync(xxx => { xxx.Content = $"Blocked {MsgCount} messages from quarantine - No infected messages here!"; }); } if (!AUsers.ContainsKey(Target)) { Program.Client.MessageReceived -= MessageEv; Thread.CurrentThread.Abort(); } else if (!MsgArg.Author.IsBot && MsgArg.Author.Id == Target && MsgArg.Channel.Id == arg.Channel.Id && !AUsers.ContainsKey(Target)) { Program.Client.MessageReceived -= MessageEv; Thread.CurrentThread.Abort(); } return(Task.CompletedTask); } Program.Client.MessageReceived += MessageEv; } else { await arg.Channel.SendMessageAsync($"<@{Target}> is not going to be quarantined. Congrats!\n~~you will die soon~~"); Thread.CurrentThread.Abort(); } }).Start(); } } } else if (GuildStuff.ReadRank(((SocketTextChannel)arg.Channel).Guild.Id, arg.Author.Id) >= 19) { await arg.Channel.SendMessageAsync("Would you like to enable this command for this server?"); var WFR = await new WaitForResponse() { TimeLimitS = 30, ChannelId = arg.Channel.Id, UserId = arg.Author.Id }.Start(); if (WFR != null && WFR.Content.ToLower().Contains("yes")) { await arg.Channel.SendMessageAsync($"Enabled {Program.Prefix}quarantine as a command!"); GuildStuff.NewGuildSetting(GuildStuff.GuildSettings.CanUseQuarantine, ((SocketTextChannel)arg.Channel).Guild.Id, true); } else { await arg.Channel.SendMessageAsync($"👌"); } } else { await arg.Channel.SendMessageAsync("Quarantine can't be used in this server!"); } } catch (Exception e) { Console.WriteLine(e); } }
public static async Task MessageReceived(SocketMessage arg) { try { if (!arg.Author.IsBot && arg.Channel.GetType() == typeof(SocketTextChannel)) { var ThisGuild = ((SocketTextChannel)arg.Channel).Guild; bool ThisGlobalChatEnabled = GuildStuff.ReadSetting(GuildStuff.GuildSettings.GlobalChannelForOthers, ThisGuild.Id); if (ThisGlobalChatEnabled) { string Id = GuildStuff.ReturnExtraSaved(GuildStuff.GuildSettings.GlobalChannelForOthers, ThisGuild.Id); SocketTextChannel ThisGlobalChatChannel = ThisGuild.GetTextChannel(ulong.Parse(Id)); if (ThisGlobalChatChannel.Id == arg.Channel.Id) { bool MsgUsed = false; EmbedBuilder Embed; var UserDataForEmb = StoreHandler.LoadData(arg.Author.Id, "GBCHATEMBED"); if (UserDataForEmb != null) { string AuthorForEmb = UserDataForEmb.Split(new[] { "author.name=" }, StringSplitOptions.None)[1].Split('=')[0]; System.Drawing.Color HexColor = ColorTranslator.FromHtml($"#{UserDataForEmb.Split(new[] { "embcolor=" }, StringSplitOptions.None)[1].Split('=')[0]}"); string FooterMsg = UserDataForEmb.Split(new[] { "footer.text=" }, StringSplitOptions.None)[1].Split('=')[0]; Embed = new EmbedBuilder() { Author = new EmbedAuthorBuilder() { IconUrl = arg.Author.GetAvatarUrl() ?? Program.Client.CurrentUser.GetAvatarUrl(), Name = $"{arg.Author.Username} • [{AuthorForEmb}]" }, Color = new Discord.Color(HexColor.R, HexColor.G, HexColor.B), Description = arg.Content, Footer = new EmbedFooterBuilder() { Text = FooterMsg.Length > 0 ? $"{arg.Author.Id} • [{FooterMsg}]" : arg.Author.Id.ToString() }, }; } else { Embed = new EmbedBuilder() { Author = new EmbedAuthorBuilder() { IconUrl = arg.Author.GetAvatarUrl() ?? Program.Client.CurrentUser.GetAvatarUrl(), Name = arg.Author.Username }, Color = Discord.Color.Teal, Description = arg.Content, Footer = new EmbedFooterBuilder() { Text = arg.Author.Id.ToString(), }, }; } bool Passed = false; foreach (var Guild in Program.GetAllShardGuilds()) { try { bool GlobalChatEnabled = GuildStuff.ReadSetting(GuildStuff.GuildSettings.GlobalChannelForOthers, Guild.Id); if (GlobalChatEnabled) { SocketTextChannel GlobalChatChannel = Guild.GetTextChannel(ulong.Parse(GuildStuff.ReturnExtraSaved(GuildStuff.GuildSettings.GlobalChannelForOthers, Guild.Id))); if (Guild != ThisGuild) { var MsgF = MessageFilter(arg); if (MsgF.MsgPassed) { Passed = MsgF.MsgPassed; await GlobalChatChannel.SendMessageAsync("", false, Embed.Build()); } else if (!MsgUsed) { MsgUsed = true; await arg.Channel.SendMessageAsync($"Sorry! Your message contained content that was deemed inappropriate - {MsgF.Reason}"); } } } } catch { } } if (new Random().Next(0, 100) > 98) { await arg.Channel.SendMessageAsync("`pls tell people about me if you like me` :pleading_face: "); } if (Passed) { await((SocketUserMessage)arg).AddReactionAsync(new Emoji("\u2705")); } } } } } catch { } }
//COMMAND HANDLING private static async Task Client_MessageReceived(SocketMessage arg) { try { if (!arg.Author.IsBot && arg.Channel.GetType() == typeof(SocketTextChannel)) { var Guild = ((SocketGuildChannel)arg.Channel).Guild; if (arg.Content.ToLower().StartsWith(Prefix)) { var Cmd = Type.GetType($"MGX_Discord_Bot.EModules.Commands.General.{arg.Content.Split(' ')[0].Split(new[] { Prefix }, StringSplitOptions.None)[1].ToLower()}"); int UserGuildRank = GuildStuff.ReadRank(Guild.Id, arg.Author.Id); int UserMGXRank = RankingManager.BotOwners.ContainsKey(arg.Author.Id) ? RankingManager.BotOwners[arg.Author.Id] : 1; if (Cmd != null) { var CmdInfo = (CommandInformation)Cmd.GetField("Info").GetValue(null); if (CmdInfo.Premium && false) // change false to check database for user if they have premium { await arg.Channel.SendMessageAsync("MGX premium is required for this command :pensive:"); } else if (CmdInfo.RequiredPermissions <= UserGuildRank) { Cmd.GetMethod("Maindo").Invoke(null, new[] { arg }); int CountAlr = StoreHandler.LoadData(arg.Author.Id, $"CMD-COUNT") != null?int.Parse(StoreHandler.LoadData(arg.Author.Id, $"CMD-COUNT")) : 0; StoreHandler.SaveData(arg.Author.Id, "CMD-COUNT", CountAlr + 1); } else { await arg.Channel.SendMessageAsync($"You aren't able to run this! You must be `{GuildStuff.GetNameOfRank(CmdInfo.RequiredPermissions)}` or higher."); } int CurCmd = StoreHandler.LoadData(0, "cmdcount") == null ? 0 : int.Parse(StoreHandler.LoadData(0, "cmdcount")); StoreHandler.SaveData(0, "cmdcount", CurCmd + 1); } else if (RankingManager.BotOwners.ContainsKey(arg.Author.Id)) { Cmd = Type.GetType($"MGX_Discord_Bot.EModules.Commands.Maintenance.{arg.Content.Split(' ')[0].Split(new[] { Prefix }, StringSplitOptions.None)[1].ToLower()}"); var CmdInfo = (CommandInformation)Cmd.GetField("Info").GetValue(null); if (Cmd != null && CmdInfo.RequiredPermissions <= UserMGXRank) { Cmd.GetMethod("Maindo").Invoke(null, new[] { arg }); } else { Console.WriteLine("Maint null"); } } } // CUSTOM RESPONSES \\ if (GuildStuff.ReadSetting(GuildStuff.GuildSettings.CustomResponses, Guild.Id)) { var ReturnedWordResp = CustomResponses.ReturnResponse(arg.Content); if (ReturnedWordResp != null) { await arg.Channel.SendMessageAsync(ReturnedWordResp); } else if (arg.Content.ToLower().StartsWith("ree")) { await arg.Channel.SendMessageAsync("*r e e ?*"); } else if (arg.Content.ToLower().Contains("anti") && arg.Content.ToLower().Contains("va") || arg.Content.ToLower().Contains("vac") && arg.Content.ToLower().Contains("do") && arg.Content.ToLower().Contains("nt")) { await arg.Channel.SendMessageAsync($"i swear to f*****g god you better vaccinate your kids"); } else if (arg.Content.ToLower().Contains("sksk") | arg.Content.ToLower().Contains(" oop ") | arg.Content.ToLower().Contains("ess kay") | arg.Content.ToLower().Contains("esskay")) { await arg.Channel.SendMessageAsync("ew, vsco. begone thot"); } else if (arg.Content.ToLower().StartsWith("i am ") || arg.Content.ToLower().StartsWith("im ") || arg.Content.ToLower().StartsWith("i'm ")) { string WhatTheyAre = arg.Content.Split(new string[] { "m" }, 2, StringSplitOptions.None)[1]; await arg.Channel.SendMessageAsync($"hi {WhatTheyAre.Trim()}, im dad"); } CustomResponses.UpdateResponses(); } if (GuildStuff.ReadSetting(GuildStuff.GuildSettings.ReplaceInvites, Guild.Id) && arg.Content.ToLower().Contains("discord.gg/")) { var RepInvEm = new EmbedBuilder() { Color = new Color(0x36393F), Timestamp = DateTime.UtcNow, Author = new EmbedAuthorBuilder() { Name = $"{arg.Author.Username} has invited you to a guild!" }, }; } } else if (!arg.Author.IsBot) { await MyAccount.SendMessageAsync($"{arg.Author.Username}#{arg.Author.Discriminator}: {arg.Content}\n\n{arg.Author.Id}"); foreach (var Attachment in arg.Attachments) { await MyAccount.SendMessageAsync(Attachment.Url); } } } catch (Exception e) { Console.WriteLine(e); } }