#Slash commands and prefix commands not working after creating new environment

1 messages · Page 1 of 1 (latest)

neat nymph
#

My bot was working just fine (slash commands and prefixed commands at once) but after reinstalling my OS I had to reinstall my IDE as well (pycharm). So i created new virtual environment for my project, and installed all packages that I was using including pycord and it isn't working anymore.

Should I have discord.py or discord.ext installed alongside pycord, because i don't recall having it on my old venv.?

The important parts of code that I've tried:

import discord
from discord.ext import commands
import datetime

intents = discord.Intents.default()
bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"), case_insensitive=True, intents=intents,
                   debug_guilds=["956899584716718101", "756115812443619357"])
@bot.command()
async def time(ctx):
    """Shows current time"""
    t = datetime.datetime.now()
    await ctx.respond(f"Time is: {t.hour:02d}:{t.minute:02d}:{t.second:02d} {t.day:02d}.{t.month:02d}.{t.year}")
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')

bot.run(TOKEN)
quasi spoke
#

iirc pycharm uses its own venv, there should be like a button somewhere down saying python packages

neat nymph
quasi spoke
#

and u dont have anything like discord or discord.py there only py-cord 2.1.3?

quasi spoke
#

oh because ur doing @bot.command which is only for prefixed? or is nothing working

neat nymph
#

nothing is working prefixed nor slash

stuck eagle
#

Show your pip freeze output

#

Also wdym by not working anymore

#

What happens when you run the bot

neat nymph
#

This is the output:

>pip freeze
aiohttp==3.8.3
aiosignal==1.2.0
async-timeout==4.0.2
attrs==22.1.0
beautifulsoup4==4.11.1
certifi==2022.9.14
charset-normalizer==2.1.1
colorama==0.4.5
frozenlist==1.3.1
greenlet==1.1.3
idna==3.4
iniconfig==1.1.1
multidict==6.0.2
nest-asyncio==1.5.5
packaging==21.3
playwright==1.26.0
pluggy==1.0.0
py==1.11.0
py-cord==2.1.3
pyee==8.1.0
pyparsing==3.0.9
pytest==7.1.3
pytest-base-url==2.0.0
pytest-playwright==0.3.0
python-dateutil==2.8.2
python-dotenv==0.21.0
python-slugify==6.1.2
requests==2.28.1
six==1.16.0
soupsieve==2.3.2.post1
text-unidecode==1.3
TikTokApi==5.2.2
tomli==2.0.1
Unidecode==1.3.4
urllib3==1.26.12
websockets==10.1
yarl==1.8.1```

My bot logs in and prints in console with the print in on_ready() function but when i go to my discord app and write `!time` or `/time` the bot doesn't respond at all.
ornate mossBOT
#

As of Pycord Beta 5, Discord API v10 requires message content intent to receive message content. This affects the traditional commands. Not enabling this intent will result in the messages' content, embeds, and components being empty.

You will need to enable the intent on the developer portal, as well as in your code:

intents = discord.Intents.default()
intents.message_content = True
bot = discord.Bot(intents=intents)

Docs: https://docs.pycord.dev/en/master/api.html#discord.Intents.message_content

neat nymph
#

I'll try this when I can, but i have a feeling this is it :DD

sharp tree
#

@neat nymph FYI. You're using ctx.respond in a prefixed command. That won't work.