I am working on a project. Please, this should be a simple fix. Looking for a solution. It looks like I am getting an error with the ‘commands’ module in python “includes’
<code>import discord
from discord.ext import commands
TOKEN = "MTI2MDQzODcxMTM4NTE5ODY3Mg.GNBaaR.b6GiWjNrfplxaZB_X9KlBcYDZyhZ0wjBPTo4Eo"
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)
</code>
<code>import discord
from discord.ext import commands
TOKEN = "MTI2MDQzODcxMTM4NTE5ODY3Mg.GNBaaR.b6GiWjNrfplxaZB_X9KlBcYDZyhZ0wjBPTo4Eo"
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)
</code>
import discord
from discord.ext import commands
TOKEN = "MTI2MDQzODcxMTM4NTE5ODY3Mg.GNBaaR.b6GiWjNrfplxaZB_X9KlBcYDZyhZ0wjBPTo4Eo"
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)
debug output: % python3 main.py Traceback (most recent call last): File "/Users/jamiemorrissey/Downloads/discord_bot/main.py", line 5, in <module> bot = commands.Bot(command_prefix="!") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: BotBase.__init__() missing 1 required keyword-only argument: 'intents'