NameError: #39;discord#39; is not defined?(NameError:“不和谐未定义?)
本文介绍了NameError:“不和谐"未定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是针对我正在制作的不和谐机器人,我试图设置机器人的状态.我找到了一个看起来像 await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="for e/info"))
的答案,我已经把它在 on_ready
事件函数中.但是,它给了我以下例外:
This is for a discord bot I am making, and I have tried to set the bot's status. I've found an answer that looks like await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="for e/info"))
and I have put it in an on_ready
event function. However, it gives me the following exception:
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:UsersuserAppDataLocalProgramsPythonPython38-32libsite-packagesdiscordclient.py",
line 312, in _run_event
await coro(*args, **kwargs)
File "C:UsersuserOneDriveDesktopEffeKtiveot.py", line 14, in on_ready
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="for
e/info"))
NameError: name 'discord' is not defined
我觉得我缺少一个 import
.
推荐答案
您需要在代码顶部 import discord
.
这篇关于NameError:“不和谐"未定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:NameError:“不和谐"未定义?


猜你喜欢
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 我如何透明地重定向一个Python导入? 2022-01-01
- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01
- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01
- 我如何卸载 PyTorch? 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01