Making the bot say something but failing please help

So like I was trying to make a discord bot using repl.it and i made the bot online but when I try to use this command:
if message.content.startswith(’$hello’):
await message.channel.send(‘Sup!’)
It just doesn’t work.

hey inclarition,

welcome to the FCC community, we are happy to have you here!

Could you link the code challenge that you worked on and perhaps also your replit project? It helps us to understand the context in which you built your application.

It would also be nice if you use the syntax highlighting support of the forum.
Here is a nice tutorial that shows you how you can highlight your code:

best
Dennis

Hello gdennci, thank you for coming to help me and for telling me how to give my codes. And for the project I’ve been working on, https://replit.com/@Salmatory/discord-bot#main.py here is the link.

if message.content.startswith('$inspire'):
  await message.channel.send(quote)

You need and indent before the await. If that’s not the problem can you copy your code and send it with 3 ` at the start before you send

Get rid of the line:

cmd_prefix "|"

It is completely unnecessary for the code you have written so far

I removed the prefix and

import discord

client = discord.Client()

@client.event
async def on_ready():
 print('We are now ready to use {0.user}'.format(client))

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

     if message.content.startswith('|hello'):
       await message.channel.send('Sup!')


client.run(os.getenv('TOKEN'))

Have you placed your ‘TOKEN’ in the secrets bar at the side?

yes as I said i can make the bot come online but sadly it doesn’t say anything when I type “|hello”

add me to the code please using the +invite

I’m Dxvil6354

Sure give me a second

There is no one called Dxvil6354 but there is only one Dxvil is that you?

@Dxvil6354
i have the same problem and I also don’t know how to add a .env file from the sidebar ?

Yes i can help you with .env So when you click on the secret thing on the siidebar like the thing that has the emoji of a lock. When you click on that, you will see two things ine is a “key” and the other one is “value”. So what you want to do is write “TOKEN” in the “key” section. Note: By “TOKEN” I do NOT mean the bot token i just mean you have to write the word TOKEN. And then in the value section, now you have to write the BOT TOKEN here. I am sorry if my explanation is bad but I hope ylu will understand.

Yes. Most Likely is me!

helppp me too icant fix this :frowning: the

await ting :frowning:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.