Example #1
0
        public async Task CreateVoiceChannelForRole(string channelName)
        {
            RestRole newRole = await Context.Guild.CreateRoleAsync(channelName);

            RestTextChannel textChannel = await Context.Guild.CreateTextChannelAsync(channelName);

            RestVoiceChannel voiceChannel = await Context.Guild.CreateVoiceChannelAsync(channelName);

            Discord.OverwritePermissions newRolePermission = new Discord.OverwritePermissions(
                readMessages: Discord.PermValue.Allow
                );

            Discord.OverwritePermissions everyonePermission = new Discord.OverwritePermissions(
                readMessages: Discord.PermValue.Deny
                );

            await textChannel.AddPermissionOverwriteAsync(Context.Guild.EveryoneRole, everyonePermission);

            await textChannel.AddPermissionOverwriteAsync(newRole, newRolePermission);

            DiscordServer server = DiscordServer.GetServerFromID(Context.Guild.Id);

            server.voiceChannelRoles.Add(new VoiceChannelRole()
            {
                voiceChannelID = voiceChannel.Id,
                textChannelID  = textChannel.Id,
                roleID         = newRole.Id
            });
            server.SaveData();
        }
Example #2
0
        public void BanPlayer(InGamePlayerInfo player)
        {
            if (!MuteOnDeath)
            {
                return;
            }
            var permissions = Channel.GetPermissionOverwrite(player.User.DiscordUser);

            if (permissions.HasValue)
            {
                permissions = permissions.Value.Modify(sendMessages: Discord.PermValue.Deny);
            }
            else
            {
                permissions = new Discord.OverwritePermissions(sendMessages: Discord.PermValue.Deny);
            }
            Channel.AddPermissionOverwriteAsync(player.User.DiscordUser, permissions.Value).Wait();
        }
Example #3
0
        public void BanPlayer(InGamePlayerInfo player)
        {
            if (!game.Settings.MuteOnDeath && !game.Settings.UseMuteBlacklist)
            {
                return;
            }
            if (game.Settings.UseMuteBlacklist && player.DbUser.IsMuteEnabled != true)
            {
                return;
            }
            var permissions = game.GameChannel.GetPermissionOverwrite(player.User.DiscordUser);

            if (permissions.HasValue)
            {
                permissions = permissions.Value.Modify(sendMessages: Discord.PermValue.Deny);
            }
            else
            {
                permissions = new Discord.OverwritePermissions(sendMessages: Discord.PermValue.Deny);
            }
            MutedPlayers.Add(player);
            game.GameChannel.AddPermissionOverwriteAsync(player.User.DiscordUser, permissions.Value).Wait();
        }