示例#1
0
        public static async void RtxLondonAsync(SocketMessage message, CommandContext context, DiscordSocketClient client)
        {
            bool found = false;
            await DiscordFunctions.DeleteSpecificMessage(message);

            if (Validation.IsUserAuthenticated(message, "guardian-london-18") == false)
            {
                foreach (var user in client.GetGuild(358283239053590528).Users)
                {
                    if (message.Author.Id == user.Id)
                    {
                        await DiscordFunctions.RoleTask(context, "guardian-london-18", user.Id.ToString());

                        found = true;
                    }
                }
            }
            if (found == true)
            {
                var ThumbsUp = new Discord.Emoji("👍");
                await context.Message.AddReactionAsync(ThumbsUp);
            }
            else
            {
                await message.Channel.SendMessageAsync(message.Author.Mention + " You are not a London Guardian if you think this is a mistake please contact an @Admin");
            }
        }
示例#2
0
        public static async void GuardianAuth(SocketMessage message, CommandContext context, Events Event)
        {
            bool found = false;

            if (Validation.IsUserAuthenticated(message, Event.Event) == false)
            {
                // Open database (or create if not exits)
                using (var db = new LiteDatabase(@"Guardians.db"))
                {
                    var      Guardians = db.GetCollection <UserData>("Guardians");
                    UserData Guardian  = null;
                    foreach (var Guard in Guardians.FindAll())
                    {
                        if (Guard.DiscordUsername.ToLower().Trim().Contains(message.Author.Username.ToLower() + "#" + message.Author.Discriminator.ToString().ToLower()))
                        {
                            Guardian = Guard;
                            break;
                        }
                    }
                    if (Guardian != null)
                    {
                        if (Guardian.DiscordUsername.ToLower() == message.Author.Username.ToLower() + "#" + message.Author.Discriminator.ToString())
                        {
                            Guardians.Update(Guardian);
                            await DiscordFunctions.RoleTask(context, "Guardian-" + Guardian.Event, message.Author.Id.ToString());

                            found = true;
                        }
                    }
                }
            }
            if (found == true)
            {
                var ThumbsUp = new Discord.Emoji("👍");
                await context.Message.AddReactionAsync(ThumbsUp);
            }
            else
            {
                await message.Channel.SendMessageAsync(message.Author.Mention + " You are not a Guardian if you think this is a mistake please contact an @Admin");
            }
        }
示例#3
0
        /// <summary>
        /// Used for cleaning up old discord events
        /// </summary>
        public static async Task CleanupEvent(CommandContext context, SocketMessage message)
        {
            // Dump Channels NOT Guardian Bar
            foreach (Discord.IGuildChannel channel in await context.Guild.GetChannelsAsync())
            {
                bool contains = channel.Name.ToLower().Trim().Contains(DiscordFunctions.GetWord(message, 1).ToLower() + "-" + DiscordFunctions.GetWord(message, 2).ToLower());
                if (contains)
                {
                    if (channel.Name.ToLower().Trim() != "guardian-bar-" + DiscordFunctions.GetWord(message, 1).ToLower() + "-" + DiscordFunctions.GetWord(message, 2).ToLower())
                    {
                        try
                        {
                            await channel.DeleteAsync();
                        }
                        catch { }
                        await Task.Delay(50);
                    }
                    else
                    {
                        // Get the list of categories
                        IReadOnlyCollection <IGuildChannel> categories = await context.Guild.GetCategoriesAsync();

                        ulong categoryId = 000000;
                        // Check if the category name matches the id if it does return the ID
                        foreach (var categoryname in categories)
                        {
                            if (categoryname.Name.ToLower().Trim() == "archive")
                            {
                                categoryId = categoryname.Id;
                                break;
                            }
                        }

                        // Add it to the category
                        await channel.ModifyAsync(x =>
                        {
                            x.CategoryId = categoryId;
                        });
                    }
                }
            }

            // Dump Voice Channels
            foreach (Discord.IVoiceChannel channel in await context.Guild.GetVoiceChannelsAsync())
            {
                if (channel.Name.ToLower().Trim().Contains(DiscordFunctions.GetWord(message, 1).ToLower() + "-" + DiscordFunctions.GetWord(message, 2).ToLower()))
                {
                    try
                    {
                        await channel.DeleteAsync();
                    }
                    catch { }
                    await Task.Delay(50);
                }
            }

            // Dump Categories
            foreach (Discord.ICategoryChannel channel in await context.Guild.GetCategoriesAsync())
            {
                if (channel.Name.ToLower().Trim().Contains(DiscordFunctions.GetWord(message, 1).ToLower() + "-" + DiscordFunctions.GetWord(message, 2).ToLower()) || channel.Name.ToLower().Trim().Contains(DiscordFunctions.GetWord(message, 1).ToLower() + "-commons-" + DiscordFunctions.GetWord(message, 2).ToLower()))
                {
                    try
                    {
                        await channel.DeleteAsync();
                    }
                    catch { }
                    await Task.Delay(50);
                }
            }

            // Dump Roles
            foreach (Discord.IRole existingrole in context.Guild.Roles)
            {
                if (existingrole.Name.ToLower().Trim().Contains(DiscordFunctions.GetWord(message, 1).ToLower() + "-" + DiscordFunctions.GetWord(message, 2).ToLower()))
                {
                    if (existingrole.Name.ToLower().Trim() != "guardian-" + DiscordFunctions.GetWord(message, 1).ToLower() + "-" + DiscordFunctions.GetWord(message, 2).ToLower())
                    {
                        try
                        {
                            await existingrole.DeleteAsync();
                        }
                        catch { }
                        await Task.Delay(50);
                    }
                }
            }
        }