Пример #1
0
        public async static Task MainAsync(string Token)
        {
            MGXStatistics.StartedAt = DateTime.UtcNow;
            var config = new DiscordSocketConfig {
                MessageCacheSize = 5, TotalShards = 1
            };

            Client = new DiscordShardedClient(config);
            DiscordBotListClient = new AuthDiscordBotListApi(534193192329805854, "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjUzNDE5MzE5MjMyOTgwNTg1NCIsImJvdCI6dHJ1ZSwiaWF0IjoxNTg3NDI3NzQxfQ.lU-e43AqYswMC3UZsc145RgadqEhrrrelKoSCvT8UXg");
            //(await DiscordBotListClient.GetMeAsync()).
            CustomResponses.UpdateResponses();
            await Client.LoginAsync(TokenType.Bot, Token);

            await Client.StartAsync();

            Client.MessageReceived += Client_MessageReceived;
            Client.MessageReceived += globalchat.MessageReceived;
            Client.MessageReceived += snipe.OnReceived;
            Client.MessageReceived += Secondary.MyClient_MessageReceived;
            Client.ShardReady      += Client_Ready;
            Client.JoinedGuild     += Client_JoinedGuild;
            Client.LeftGuild       += Client_LeftGuild;
            Client.MessageDeleted  += snipe.OnDelete;
            new Thread(async x =>
            {
                await Secondary.Secondary_Thread();
            }).Start();

            await Task.Delay(-1);
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        //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);
            }
        }