コード例 #1
0
        public async Task <bool> EditVoiceChannelAsync(DiscordMember member, string?newName = null, int?limit = 0,
                                                       bool?isPublic = false)
        {
            if (member.VoiceState?.Channel == null || member.VoiceState?.Channel.Id == _voiceConfig.ClickChannelId)
            {
                return(false);
            }

            newName = ConvertStringToValidState(newName);

            DiscordChannel customVoiceCategory = member.Guild.GetChannel(_voiceConfig.ClickChannelId).Parent;

            if (!customVoiceCategory.Equals(member.VoiceState?.Channel?.Parent))
            {
                return(false);
            }

            try
            {
                string?userName = ConvertStringToValidState(member.Nickname, member.Username);
                await EditChannelAsync(true, member.VoiceState?.Channel, newName, limit, isPublic, userName);

                return(true);
            }
            catch (Exception e)
            {
                _logger.LogWarning(e, "Editing voice channel failed");
            }

            return(false);
        }