Python bot.com命令没有响应
我已经浏览了几个类似的线程,但是在尝试了我能找到的一切之后,我已经达到了一个点,我没有任何错误消息,但什么都没有发生。事件不是问题,命令没有按预期工作。我想实现加入语音频道的机器人,但为了这个简单的命令,我把它关掉了,看看我需要做什么才能让命令正常工作。我从discord文档中复制了它,所以我想它应该可以工作,但是没有。。。 编辑:我刚刚意识到实际上有错误代码,在我添加wait bot.process_命令后出现。消息这是我的终端:Python bot.com命令没有响应,python,python-3.x,discord,discord.py,Python,Python 3.x,Discord,Discord.py,我已经浏览了几个类似的线程,但是在尝试了我能找到的一切之后,我已经达到了一个点,我没有任何错误消息,但什么都没有发生。事件不是问题,命令没有按预期工作。我想实现加入语音频道的机器人,但为了这个简单的命令,我把它关掉了,看看我需要做什么才能让命令正常工作。我从discord文档中复制了它,所以我想它应该可以工作,但是没有。。。 编辑:我刚刚意识到实际上有错误代码,在我添加wait bot.process_命令后出现。消息这是我的终端: Logged in as DerBesondereBot 81
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'
您错误地使用了discord.Client和commands.Bot。后者是一个子类,它提供客户端所做的一切以及它自己的命令处理程序,因此,您应该只有其中一个,即删除Client=discord.Client并用bot替换客户端的所有用法。您错误地使用了discord.Client和commands.bot。后者是一个子类,它提供客户端所做的一切以及它自己的命令处理程序,因此,您应该只拥有其中一个,即remove Client=discord.Client,并用bot替换客户端的所有用法
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"))