Few days ago I decided to move all commands in my Discord Bot into an extension/cog file. After that Discord completely ignore any command (even these declared in main file). Logs are fine, there's no error or crashes. I tried many methods, that I found here, on youtube, github etc
Here is the main code:
import discord
from discord.ext import commands
import asyncio
import random
import string
import requests
import json
import os
bot = commands.Bot(command_prefix = '?')
extensions = ['cogs.com']
if __name__ == '__main__':
for extension in extensions:
try:
bot.load_extension(extension)
except Exception as error:
print('{} cannot load the file. [{}]'.format(extension, error))
@bot.event
async def on_ready():
await bot.change_presence(game=discord.Game(name="type `?help` for help"))
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
@bot.event
async def on_message(message):
# here I've got a lot of bot events (responding, sending funny memes etc). Surprisingly this part works absolutely fine
bot.run("TOKEN", bot=True, reconnect=True)
And the cog file (com.py). Here I've got a lot of commands, but I decided to leave only the basic one:
import discord
from discord.ext import commands
class Com():
def __init__(self, bot):
self.bot = bot
@commands.command()
async def test(self):
print('TEST') # Logs don't show anything after my command. It looks like bot doesn't even read it... or read it and doesn't send anything back?
await self.bot.send('test')
def setup(bot):
bot.add_cog(Com(bot))
(discord.py ver = 0.16.12)
If anyone could help, that would be awesome. Thanks