← Back to all posts
##### How do i add the prefix to the commands? [Discord.py]
ExoticCitron

So i need some help, whenever i try coding my bot to say somthing, such as &ping, i want it to be so that when i add the command, and i run it, the prefix '&' and the command 'ping' will show the ping. This shall go for any other commands too. How do i do this?

Voters
ExoticCitron
hotnewtop
AloegelhiPlaysR

Adding `&` before every command. So instead of checking for `help`, try checking for `&help`

ExoticCitron

@AloegelhiPlaysR so if i get this correctly

```.css-o0gntx{position:absolute;left:-9999px;}.css-1v1ju80{-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;border-width:0;border-style:solid;box-sizing:border-box;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-basis:auto;-ms-flex-preferred-size:auto;flex-basis:auto;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;position:relative;outline:none;min-height:0;min-width:0;position:absolute;left:-9999px;}@client.command()
async def on_message(message):
if message.content.startswith('&help'):
async def ping():
await client.say(f'Pong! {client.latency}')```

what i mean is, where and what do i add to make my commands display the command when inputting &ping?

Like for this command:

```.css-o0gntx{position:absolute;left:-9999px;}.css-1v1ju80{-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;border-width:0;border-style:solid;box-sizing:border-box;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-basis:auto;-ms-flex-preferred-size:auto;flex-basis:auto;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;position:relative;outline:none;min-height:0;min-width:0;position:absolute;left:-9999px;}@client.command()
async def who(ctx):
member = ctx.message.author
roles = [role.mention for role in member.roles[1:]]  # don't get @everyone
roles.append('@everyone')  # set string @everyone instead of role
await ctx.send(" ".join(roles))```

i want to add the prefix & to this but how?

tristans2

@Lumiscnt just replace "user_input" with whatever variable contains the user input

```.css-o0gntx{position:absolute;left:-9999px;}.css-1v1ju80{-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;border-width:0;border-style:solid;box-sizing:border-box;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-basis:auto;-ms-flex-preferred-size:auto;flex-basis:auto;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;position:relative;outline:none;min-height:0;min-width:0;position:absolute;left:-9999px;}if user_input[0] != "&":
# enter some failure state and return
user_input = ''.join(user_input[1:])```
ExoticCitron

@tristans2 thanks, i figured it out anyways!