我正在尝试制作一个Discord机器人,它使用语音聊天使参与者的声音静音
为此,我使用Python
这是我的代码,但它没有按预期工作
import discord
from discord.ext import commands
client = commands.Bot(command_prefix=" !")
@client.event
async def on_ready():
print('BOT ACTIVATED')
@client.command()
async def mute(ctx):
voice_client = ctx.guild.voice_client
if not voice_client:
return
channel = voice_client.channel
await voice_client.voice_state(ctx.guild.id, channel.id, self_mute=True)
client.run(My Token)
我的想法是:
我将输入命令:!muteall
\
机器人将使语音聊天中的所有参与者静音
我将输入命令:!unmuteall
\
机器人将取消语音聊天中所有参与者的静音
在我们讨论问题的关键之前,请在前缀上写一个简短的词:
您的命令前缀是
!
,前面有一个空格。我不知道这是否是有意的,但如果是,在我的测试中,我发现使用它是不可能的。不一致带开头的空格,所以我所有的消息!test
都显示为!test
修复此问题后,尝试使用
!mute
命令会产生错误:'VoiceClient' object has no attribute 'voice_state'
事实上,我在文档中找不到类似的内容。我花了很多时间寻找,但我可能已经得到了你想要的您的机器人需要权限才能禁用用户
相关问题 更多 >
编程相关推荐