Skip to content
Sign upLog in
← Back to Community

Discord Commands

Profile icon
ReshiramWolfu

I want to make a discord bot respond to commands, and i have this code so far, can anyone help me do a command so that it will respond to anything after an exclamation mark, like this !respond
https://repl.it/@ReshiramWolfu/Alter-Ego-Bot-Discord

Voters
Profile icon
aguirremarialou
Profile icon
moalsaidi20009
Profile icon
contaboot99872
Profile icon
ScroudTtv
Profile icon
napsGD
Profile icon
FGJepperi
Profile icon
nsxcsphat77
Profile icon
ShanRocky
Profile icon
Dogey1
Profile icon
ElitixJohan
Comments
hotnewtop
Profile icon
TheDrone7

I might not be able to help you with something like that, since all you need to do is add a little logic, I can provide you with a few links for reference though: -
Discord.py documentation - http://discordpy.readthedocs.io/en/async/
A tutorial: https://pythonprogramming.net/discordpy-basic-bot-tutorial-introduction/
( This is part 1 that you've probably already completed. Still you should go through it.)
Part 2 is what you really need - https://pythonprogramming.net/building-bot-commands-discordpy-bot-tutorial/?completed=/discordpy-basic-bot-tutorial-introduction/

You might also want to go through this if you're planning to keep your bot on repl.it - https://repl.it/talk/learn/Hosting-discordpy-bots-with-replit/11008

Also, you are using discord.py-async , I recommend shifting to discord.py-rewrite, it's newer and already better than discord.py-async in many aspects and is also being improved!

Profile icon
ChristinaSchw

Constants are a https://chinesebuffetnearmenow.net/ special type of variable. Once declared, the value cannot be changed (unless you change the value when initializing it). In JS you use the const keyword: const pi = 3.14159

Profile icon
Textcrafter101

you could do something like this:
if message.content.startswith('!'): (for some reason it wouldn't let me go to the next line) await message.channel.send('this is where the stuff you want it to say would be')
if this helps, please upvote, though you've probably already gotten an answer since this was from 3 years ago

Profile icon
Abdul-azeemaze2

Hh

Profile icon
xnfdeveloper

eample if (message.content.startsWith('beep')) {
message.channel.send('Boop.');
}