Example #1
0
        public async Task RegisterGuild(CommandContext ctx, DiscordChannel parentCategory, DiscordChannel waitingRoomVC, DiscordChannel commandListenChannel, DiscordRole memberRole, DiscordRole mutedRole, DiscordRole botManagerRole)
        {
            MessageType messageType = MessageType.Success;
            List <KeyValuePair <string, string> > embedContent = new List <KeyValuePair <string, string> >();

            if (!registeredGuildData.RegisterGuild(ctx.Guild, parentCategory, waitingRoomVC, commandListenChannel, memberRole, mutedRole, botManagerRole, out string error))
            {
                await ctx.Message.RespondAsync(error);

                goto Completed;
            }

            registeredGuildData[ctx.Guild].InitializePermissions(VoiceChannelCreationPermissions.Unauthorized, new[] { new KeyValuePair <DiscordRole, VoiceChannelCreationPermissions>(memberRole, new VoiceChannelCreationPermissions(ChannelCreationAuthority.Authorized, ChannelRenameAuthority.Unauthorized, ChannelCreationQuantityAuthority.Single, ChannelAccesibilityConfigurationAuthority.Private, ChannelRegionConfigurationAuthority.Unauthorized)), new KeyValuePair <DiscordRole, VoiceChannelCreationPermissions>(mutedRole, VoiceChannelCreationPermissions.Unauthorized), new KeyValuePair <DiscordRole, VoiceChannelCreationPermissions>(botManagerRole, VoiceChannelCreationPermissions.Authorized) }, new[] { new KeyValuePair <DiscordMember, VoiceChannelCreationPermissions>(ctx.Member, VoiceChannelCreationPermissions.Authorized) });

            if (error == string.Empty)
            {
                embedContent.AddRange(new[]
                {
                    new KeyValuePair <string, string>("Guild", $"{ctx.Guild.Name} - {ctx.Guild.Id}"),
                    new KeyValuePair <string, string>("Parent Category", $"{parentCategory?.Mention ?? "null"} - {parentCategory?.Id}"),
                    new KeyValuePair <string, string>("Waiting Room VC", $"{waitingRoomVC?.Mention ?? "null"} - {waitingRoomVC?.Id}"),
                    new KeyValuePair <string, string>("Command Listen Channel", $"{commandListenChannel?.Mention ?? "null"} - {waitingRoomVC?.Id}"),
                    new KeyValuePair <string, string>("Member Role", $"{memberRole.Mention} - {memberRole?.Id}"),
                    new KeyValuePair <string, string>("Muted Role", $"{mutedRole.Mention} - {mutedRole.Id}"),
                    new KeyValuePair <string, string>("Bot Manager Role", $"{botManagerRole.Mention} - {botManagerRole.Id}")
                });
                goto Completed;
            }

            embedContent.Add(new KeyValuePair <string, string>("Error", error));

Completed:
            await ctx.Message.RespondAsync(CreateEmbedMessage(ctx, messageType, $"Registering guild \"{ctx.Guild.Name}\" ({ctx.Guild.Id})", embedContent));

            return;
        }