Программа Discord-py-api полностью не работаетPython

Программы на Python
Anonymous
Программа Discord-py-api полностью не работает

Сообщение Anonymous »

Когда я написал автоответчик Discord с помощью Python lib discord-py-api, похоже, он не обнаружил полученное сообщение...
Мой код:

Код: Выделить всё

import discord

class MyClient(discord.Client):
async def on_ready(self):
print('Logged on as', self.user)

async def on_message(self, message):
if message.author == self.user:
return

else:
await message.channel.send(self.user + ' is not here now. Please message later. Thank you.')
print('One message replied to ' + message.author)

print("""
---------------------------------------------------------------------------
Discord-auto-replier
By orangetheorange
https://github.com/orangetheorange/discord-replier
---------------------------------------------------------------------------

[*] Thank you for using, if you find any bugs, please report to me.
[*] Please read token.md for your discord token.

[!] If you enter a token, please keep it secretly, if someone has it he can
have full access to your account.
""")

global token
token = ""
with open('token.txt', 'r', encoding='utf-8') as tok:
if tok.read() == "":
with open('token.txt', 'w', encoding='utf-8') as tok:
token = input('Put your discord token here: ')
tok.write(token)
else:
with open('token.txt', 'r', encoding='utf-8') as toke:
token = toke.read()
print('Used token: ' + token)
intents = discord.Intents.default()
intents.message_content = True
client = MyClient(intents=intents)
client.run(token)

Я пытался изменить некоторые мелкие детали, например удалить «.channel», но ничего не получилось. Он даже не распечатал ответное сообщение при получении сообщения... Я ожидая, что он будет работать правильно, он ответит автоматически.

Подробнее здесь: https://stackoverflow.com/questions/786 ... y-not-work

Вернуться в «Python»