Apster137
Apster137

Reputation: 63

bot.command not responding

I have looked through several similar threads however after trying everything I could find I have gotten to a point where I do not have any error messages but nothing is happening. The events are not the problem, the command is not working as supposed. I wanted to implement the bot joining a voice channel but I switched it out for this simple command to see what I need to do to get commands working. I copied it from the discord documentation so I would guess that it should work but nope... EDIT: I just realized that there actually are error codes, which appeared after I added the "await bot.process_commands(message)" here is my Terminal:

Logged in as
DerBesondereBot
818165441616281672
------
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 74, in on_message
    await bot.process_commands(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 938, in process_commands
    ctx = await self.get_context(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 849, in get_context
    if self._skip_check(message.author.id, self.user.id):
AttributeError: 'NoneType' object has no attribute 'id'
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 74, in on_message
    await bot.process_commands(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 938, in process_commands
    ctx = await self.get_context(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 849, in get_context
    if self._skip_check(message.author.id, self.user.id):
AttributeError: 'NoneType' object has no attribute 'id'
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 74, in on_message
    await bot.process_commands(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 938, in process_commands
    ctx = await self.get_context(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 849, in get_context
    if self._skip_check(message.author.id, self.user.id):
AttributeError: 'NoneType' object has no attribute 'id'
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 74, in on_message
    await bot.process_commands(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 938, in process_commands
    ctx = await self.get_context(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 849, in get_context
    if self._skip_check(message.author.id, self.user.id):
AttributeError: 'NoneType' object has no attribute 'id'
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 74, in on_message
    await bot.process_commands(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 938, in process_commands
    ctx = await self.get_context(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 849, in get_context
    if self._skip_check(message.author.id, self.user.id):
AttributeError: 'NoneType' object has no attribute 'id'
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 74, in on_message
    await bot.process_commands(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 938, in process_commands
    ctx = await self.get_context(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 849, in get_context
    if self._skip_check(message.author.id, self.user.id):
AttributeError: 'NoneType' object has no attribute 'id'
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 74, in on_message
    await bot.process_commands(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 938, in process_commands
    ctx = await self.get_context(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 849, in get_context
    if self._skip_check(message.author.id, self.user.id):
AttributeError: 'NoneType' object has no attribute 'id'
Ignoring exception in on_message
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 74, in on_message
    await bot.process_commands(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 938, in process_commands
    ctx = await self.get_context(message)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 849, in get_context
    if self._skip_check(message.author.id, self.user.id):
AttributeError: 'NoneType' object has no attribute 'id'
import discord
import os
import requests
import json
import random
from discord.ext import commands

client = discord.Client()
bot = commands.Bot(command_prefix='§')

def get_quote():
    response = requests.get("https://zenquotes.io/api/random")
    json_data = json.loads(response.text)
    quote = json_data[0]["q"] + "\n-" + json_data[0]["a"]
    return (quote)

bad_words = ["list of bad words"]

horny_words = ["list of words"]

zuegelungen = [
  "Also hömma, sowat will ich hier net lesen!",
  "ich glaub ich seh net richtig, was ist das den für ne Ausdrucksweise",
  "Ja lecko mio, wat lief den in deiner Erziehung falsch, sowat sacht man doch nicht."
]

@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')

@bot.command()
async def test(ctx, arg):
    await ctx.send(arg)

@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if "inspirier" in message.content.lower():
        quote = get_quote()
        await message.channel.send(quote)
        return

    for word in bad_words:
        if word in message.content.lower():
          if "louis" in message.content.lower():
            await message.channel.send("Das ist alles Lügenpresse!\nLouis ist eine der besten, wenn nicht die beste Person die ich je treffen durfte!")
            return
          else:
            await message.channel.send(random.choice(zuegelungen)) 
            return  

    for hword in horny_words:
      if hword in message.content.lower():
        await message.channel.send("https://tenor.com/view/horny-jail-bonk-dog-hit-head-stop-being-horny-gif-17298755")
        return

    if "koks" in message.content.lower():
        await message.channel.send("MIT NUTTEN!")
        return

    if ".cookie" in message.content.lower():
        await message.delete()
        await message.channel.send(":cookie:")
        return

    if "louis" in message.content.lower():
        await message.channel.send("Habe ich da Louis gehört?\nDas ist schon nen geiler Typ...")
        return
    await bot.process_commands(message)

@client.event
async def on_member_join(member):
    msg = "Your Message goes here"
    await member.send(msg)

client.run(os.getenv("TOKEN"))

Upvotes: 0

Views: 475

Answers (1)

thegamecracks
thegamecracks

Reputation: 584

You are incorrectly using both discord.Client and commands.Bot. The latter is a subclass which provides everything Client does along with its own command handler, and as such, you should only have one of those (i.e. remove client = discord.Client() and replace all usages of client with bot).

Upvotes: 3

Related Questions