I’ve done everything correct to the best of my knowledge as far as coding it. But when I type my “if” phrase which is ($trade) it doesn’t send any response at all in the discord. However when I press ‘Run’ it does say that my bot is online. Any suggestions?
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.startswith('$trade'):
await message.channel.send ('trade')
client.run(os.getenv('TOKEN'))
your code works for me… just make sure ur indentations are correct
client = discord.Client()
@client.event
async def on_ready():
print("Bot is ready")
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$trade'):
await message.channel.send ('trade')
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.