Я работаю над проектом. Пожалуйста, это должно быть простое решение. Ищем решение. Похоже, я получаю сообщение об ошибке с модулем "команды" в Python "includes"
import discord
from discord.ext import commands
TOKEN = "mytoken"
bot = commands.Bot(command_prefix="!")
@bot.event
async def on_ready():
print(f'{bot.user} succesfully logged in!')
@bot.event
async def on_message(message):
if message.author == bot.user:
return
if message.content == 'hello':
await message.channel.send(f'Hi {message.author}')
if message.content == 'bye':
await message.channel.send(f'Goodbye {message.author}')
await bot.process_commands(message)
# Start each command with the @bot.command decorater
@bot.command()
async def square(ctx, arg): # The name of the function is the name of the command
print(arg) # this is the text that follows the command
await ctx.send(int(arg) ** 2) # ctx.send sends text in chat
@bot.command()
async def scrabblepoints(ctx, arg):
# Key for point values of each letter
score = {"a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2,
"f": 4, "i": 1, "h": 4, "k": 5, "j": 8, "m": 3,
"l": 1, "o": 1, "n": 1, "q": 10, "p": 3, "s": 1,
"r": 1, "u": 1, "t": 1, "w": 4, "v": 4, "y": 4,
"x": 8, "z": 10}
points = 0
# Sum the points for each letter
for c in arg:
points += score[c]
await ctx.send(points)
bot.run(TOKEN)
вывод отладки:
% python3 main.py
Traceback (most recent call last):
File "/Users/jamiemorrissey/Downloads/discord_bot/main.py", line 5, in
bot = commands.Bot(command_prefix="!")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents'
Подробнее здесь: https://stackoverflow.com/questions/787 ... lp-intents