![](/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.