【问题标题】:Discord Bot Python - Changing Bot's nicknameDiscord Bot Python - 更改 Bot 的昵称
【发布时间】:2021-04-05 00:16:29
【问题描述】:

我试图让机器人的名称在每次运行时都更改。我检查了 discord.py 文档,但没有任何用处,也没有任何错误。有什么想法吗?

拥有“管理员”和“更改昵称”权限

import discord
from discord.ext import commands
from discord.ext.commands import bot

bot = commands.Bot(command_prefix=PREFIX)
bot.remove_command('help')


@bot.event
async def on_ready():
    await bot.user.edit(nick="New Nickname")

bot.run(TOKEN)

【问题讨论】:

  • 机器人是否有权更改昵称?
  • 是的,有管理员和更改昵称

标签: python discord.py


【解决方案1】:

您必须拥有机器人的member 对象才能更改您的昵称,因为昵称是在公会中完成的。那么你必须edit它。

@bot.event
async def on_ready():
    for guild in bot.guilds:
        await guild.me.edit(nick="new nickname")

【讨论】:

    猜你喜欢
    • 2021-04-15
    • 2021-07-02
    • 2019-02-09
    • 2019-07-26
    • 2017-12-28
    • 2017-09-09
    • 2021-05-20
    • 2021-06-29
    • 2020-07-28
    相关资源
    最近更新 更多