/********************************************************
         * Creates Public Anon Channel
         * ********************************************************/
        public async Task CreatePublicAnonChannel(SocketGuild guild)
        {
            var everyoneRole = guild.Roles.FirstOrDefault(x => x.IsEveryone);

            Console.WriteLine($"Creating PublicChannel for Guild {guild.Name}");
            var text = await guild.CreateTextChannelAsync("Anon");

            ICategoryChannel category = guild.CategoryChannels.FirstOrDefault(x => x.Id == CatagoryID);

            //if catagory exits make a new one
            if (category == null)
            {
                category = await guild.CreateCategoryChannelAsync("Anonyomus Channels");

                await category.AddPermissionOverwriteAsync(everyoneRole, PermissionsDenyAll);
            }

            await text.AddPermissionOverwriteAsync(everyoneRole, PermissionsReadOnly);

            await text.ModifyAsync(x => x.CategoryId = category.Id);

            var message = await text.SendMessageAsync($"**Welcome to {guild.Name}'s Anonamus Channel!**\n\n" +
                                                      "This channel allows all the users on the server to see the anonamous chat without being in it." +
                                                      "The bot grabs all messages sent by users and sends them to everyone elses channel. " +
                                                      "Becouse the bot posts the message you don't know who sent the message.\n\n" +
                                                      "You can view the source code at https://github.com/doc543/AnonBot \n");

            await message.PinAsync();

            Console.WriteLine("Created Text Channel: " + CatagoryID.ToString());
        }
Beispiel #2
0
        private static async Task OnJoinedGuild(SocketGuild guild)
        {
            try
            {
                var pickupsCategory = (ICategoryChannel)guild.CategoryChannels
                                      .FirstOrDefault(c => c.Name.Equals(CategoryNames.Pickups, StringComparison.OrdinalIgnoreCase)) ??
                                      await guild.CreateCategoryChannelAsync(CategoryNames.Pickups);

                await CreateChannel(guild,
                                    ChannelNames.Pickup,
                                    "powered by pickup-bot | !help for instructions",
                                    pickupsCategory.Id);

                await CreateChannel(guild,
                                    ChannelNames.Duel,
                                    "powered by pickup-bot | !help for instructions",
                                    pickupsCategory.Id);

                await CreateChannel(guild,
                                    ChannelNames.ActivePickups,
                                    "Active pickups | use reactions to signup | powered by pickup-bot",
                                    pickupsCategory.Id);

                // create applicable roles if missing
                if (guild.Roles.All(w => w.Name != RoleNames.PickupPromote))
                {
                    await guild.CreateRoleAsync(RoleNames.PickupPromote, GuildPermissions.None, Color.Orange, isHoisted : false, isMentionable : true);
                }

                // create applicable roles if missing
                if (guild.Roles.All(w => w.Name != RoleNames.Duellist))
                {
                    await guild.CreateRoleAsync(RoleNames.Duellist, GuildPermissions.None, isHoisted : false, isMentionable : true);
                }

                // create voice channel category if missing
                if (guild.CategoryChannels.FirstOrDefault(c => c.Name.Equals(CategoryNames.PickupVoiceChannels, StringComparison.OrdinalIgnoreCase)) == null)
                {
                    await guild.CreateCategoryChannelAsync(CategoryNames.PickupVoiceChannels);
                }
            }
            catch (Exception e)
            {
                await LogAsync(new LogMessage(LogSeverity.Error, nameof(OnJoinedGuild), e.Message, e));
            }
        }
Beispiel #3
0
        private async Task ConfigureGuild(SocketGuild guild)
        {
            _logger.LogDebug($"Configuring guild {guild.Name}");

            _logger.LogDebug($"Detecting language for guild {guild.Name}");
            var guildLang = guild.PreferredLocale;

            _logger.LogDebug($"PreferredLocale set to {guildLang}");
            var ci = new CultureInfo(guildLang);

            guildLang = ci.Parent?.Name;
            if (string.IsNullOrEmpty(guildLang))
            {
                guildLang = ci.Name;
            }

            if (!await _translationService.IsLangSupported(guildLang))
            {
                _logger.LogDebug($"Couldn't resolve guild language {guildLang}, defaulting to {TranslationConstants.StandardLanguage}");
                guildLang = TranslationConstants.StandardLanguage;
            }

            _logger.LogDebug($"Setting the translation language for {guild.Name} to {guildLang}");
            _guildLanguages[guild.Id] = guildLang;

            _logger.LogDebug(string.Join(", ", guild.CategoryChannels.Select(a => a.Name)));

            var category = guild.CategoryChannels.SingleOrDefault(a => a.Name == TranslationConstants.CategoryName) as ICategoryChannel;

            if (category == null)
            {
                _logger.LogDebug($"'{TranslationConstants.CategoryName}' category not found, creating.");
                _waitingForChannel = TranslationConstants.CategoryName;
                category           = await guild.CreateCategoryChannelAsync(TranslationConstants.CategoryName);

                _channelCreatedWaiter.WaitOne();
            }

            var tmpCat   = guild.GetCategoryChannel(category.Id);
            var tmpChans = tmpCat.Channels;

            var howtoChannel = await CreateOrUpdateChannel(guild, category, TranslationConstants.HowToChannelName, $"Use the ??translate create <your-language> command to start a session", 999);

            await PostStockMessages(howtoChannel);
            await CreateOrUpdateChannel(guild, category, TranslationConstants.HistoryChannelName, $"Use this channel to search past localized conversations", 0);

            _logger.LogDebug($"Done configuring guild {guild.Name}");
        }
Beispiel #4
0
        private static async Task AddCategoryWithChannels(SocketGuild guild, IRole memberRole, string categoryName, int position)
        {
            RestCategoryChannel category = await guild.CreateCategoryChannelAsync(categoryName, properties => properties.Position = position);

            await category.AddPermissionOverwriteAsync(guild.EveryoneRole, OverwritePermissions.InheritAll);

            await category.AddPermissionOverwriteAsync(memberRole, OverwritePermissions.InheritAll);

            //Text chat
            RestTextChannel chat = await guild.CreateTextChannelAsync(categoryName.ToLower(), properties => properties.CategoryId = category.Id);

            await chat.SyncPermissionsAsync();

            //Auto VC chat
            RestVoiceChannel autoVcChat = await AutoVCChannelCreator.CreateAutoVCChannel(guild, categoryName);

            await autoVcChat.ModifyAsync(properties => properties.CategoryId = category.Id);

            await autoVcChat.SyncPermissionsAsync();
        }
Beispiel #5
0
        public static async Task <SocketCategoryChannel> AddCategoryChannel(string name, SocketGuild guild)
        {
            foreach (SocketCategoryChannel cat in guild.CategoryChannels)
            {
                if (cat.Name == name)
                {
                    return(cat);
                }
            }

            await guild.CreateCategoryChannelAsync(name);

            foreach (SocketCategoryChannel cat in guild.CategoryChannels)
            {
                if (cat.Name == name)
                {
                    return(cat);
                }
            }

            return(null);
        }
        private void Setup()
        {
            var guildList = _client.Guilds;

            Console.WriteLine($"Guilds:");
            foreach (SocketGuild guild in guildList)
            {
                Console.WriteLine($"{guild.Name}");
                if (guild.Name == "Vampire Live Düsseldorf")
                {
                    VampireLiveGuildID = guild.Id;
                }
            }
            SocketGuild vampireguild = _client.GetGuild(VampireLiveGuildID);

            if (!CategorieExits(vampireguild, CatSLmitSpielern))
            {
                var categorie = vampireguild.CreateCategoryChannelAsync(CatSLmitSpielern, x => { x.CategoryId = SLChatID; }).Result;
                SLChatID = categorie.Id;
                Console.WriteLine($"Categorie mit der ID {SLChatID} erstellt");
            }
        }
 public virtual Task <RestCategoryChannel> CreateCategoryChannelAsync(string name, Action <GuildChannelProperties>?func = null, RequestOptions?options = null)
 {
     return(_socketGuild.CreateCategoryChannelAsync(name, func, options));
 }
Beispiel #8
0
        private async Task <SocketCategoryChannel> GenerateBaseCategory(SocketGuild guild)
        {
            await guild.CreateCategoryChannelAsync(ChannelNames.Category, func : x => { x.Position = -1; });

            return(guild.CategoryChannels.FirstOrDefault(x => x.Name == ChannelNames.Category));
        }