Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }