【问题标题】:How can I move specific user to specific channels with discord.py? [duplicate]如何使用 discord.py 将特定用户移动到特定频道? [复制]
【发布时间】:2021-07-28 04:56:42
【问题描述】:

我正在制作一个不和谐的机器人,只是为了玩 python。我试图打动人们。
让我解释一下the Duck来自“A”必须去“1”然后“2”然后回到“A”。
有人知道这是如何工作的吗?await member.move_to(channel, *, reason=None) 我不知道如何将语音通道的 ID 保存在变量中

感谢您的关注

【问题讨论】:

    标签: python python-3.x discord discord.py bots


    【解决方案1】:

    您可以使用开发者模式保存 ID(可以在外观设置中打开)。

    sn-p 使用member 对象,可以通过以下方式获得:

    @bot.command()
    async def move(ctx, *, member = discord.Member):
    

    然后移动到指定的ID。

    注意:member = discord.Member 将提到的用户作为参数。示例:

    > !command @Duhon
    > member = @Duhon
    

    要获取执行命令的用户,请使用ctx.author

    你想要的代码是move_to函数的倍数。

    【讨论】:

    • 所以。我做了一些事情@bot.command() async def mv(ctx, *, member = discord.Member,channel): if ctx.author.voice and ctx.author.voice.channel: channel = ctx.author.voice.channel else: await ctx.send("You are not connected to voice!") if not member: await ctx.send("Who am I trying to move? Use !move @user") await member.move_to(channel) 我不知道它是如何/为什么给我发送这个错误消息TypeError: __new__() missing 2 required positional arguments: 'bases' and 'namespace',当我写!mv @name我和@name 是连接到不同的chan
    • @maevaLeroi 试试这个 sn-p:pastebin.com/e8UQ4zd4 为我工作(替换 ID)。另外,如果您想使用 5 秒睡眠,请执行 import time
    猜你喜欢
    • 1970-01-01
    • 2018-07-30
    • 1970-01-01
    • 2021-11-18
    • 2020-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-28
    相关资源
    最近更新 更多