Ask coding questions

← Back to all posts
Discord bot doesn't respond to !command
UnvalidC

Even though I enabled send messages for the bot and even gave it admin it won't respond to it's command !alive.
It keeps giving me this:
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 14, in on_message
if message.content.startwith('!alive'):
AttributeError: 'str' object has no attribute 'startwith'

This is my current code for it btw:
import discord
import os

client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))

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

if message.content.startwith('!alive'):
await message.channel.send('Sup')

client.run (os.environ['TOKEN'])

Voters
UnvalidC
Comments
hotnewtop
UnvalidC

Ahh guys nvm I fixed it now