首页 > 解决方案 > Discord Bot 使用 Python 使用语音聊天来静音人们的声音

问题描述

我 15 岁,我正在尝试制作一个不和谐的机器人,使用语音聊天使参与者的声音静音。为此,我正在使用 Python。这是我的代码,但它没有按预期工作。

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.main_ws.voice_state(ctx.guild.id, channel.id, self_mute=True)

client.run('')

我的想法是:我将输入的命令:!muteall 机器人将静音语音聊天中的所有参与者 我将输入的命令:!unmuteall 机器人将取消语音聊天中的所有参与者的静音

请有人帮助我!!!!!!!

标签: pythondiscord

解决方案


推荐阅读