简体   繁体   中英

Visual Studio does not recognize the NuGet

I´m absolutely new to programming so please point out everything that you can see, that is wrong. I´m trying to make a bot for discord that sends a message every hour or so (might change that later). I looked at someone elses code and tried to use it. I have installed the discord-ext-alternatives, this discord.py NuGet and some other ones, as you are able to see on the right side of the image. Somehow Visual Studio does not recognize these NuGets (as you can also see). What did I do wrong?Thank you guys in advance. ( What I currently have )

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")

The problem is not that Visual Studio is not identifying the modules, you are importing them wrongly.

Instead of doing:

from discord.ext import

You will need to do the following to import discord.py and the necessary modules to execute tasks and commands:

import discord
from discord.ext import tasks, commands

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM