![](/img/trans.png)
[英]Why does visual studio code not recognize that i have Pygame installed?
[英]Visual Studio does not recognize the NuGet
我对编程完全陌生,所以请指出你能看到的一切,这是错误的。 我正在尝试为 discord 制作一个机器人,它每小时左右发送一条消息(以后可能会改变)。 我查看了别人的代码并尝试使用它。 我已经安装了 discord-ext-alternatives,这个 discord.py NuGet 和其他一些,你可以在图像的右侧看到。 不知何故,Visual Studio 无法识别这些 NuGet(您也可以看到)。 我做错了什么?提前谢谢你们。 (我目前拥有的)
from discord.ext import
bot = commands.Bot("!")
target_channel_id = the channel id
@tasks.loop(hours=1)
async def called_once_a_day():
message_channel = bot.get_channel(target_channel_id)
print(f"Got channel {message_channel}")
await message_channel.send("my message")
@called_once_a_day.before_loop
async def before():
await bot.wait_until_ready()
print("Finished waiting")
called_once_a_day.start()
bot.run("bot token")
问题不在于 Visual Studio 没有识别模块,而是您错误地导入了它们。
而不是这样做:
from discord.ext import
您需要执行以下操作来导入 discord.py 以及执行任务和命令所需的模块:
import discord
from discord.ext import tasks, commands
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.