So i just started coding and made a discord bot, the bot was for a D&D group to roll dices. But i wanted to add a feature to make it easier to know who rolled what. So my question is, how do i ping the user who called the command. Ive tried googling it but I dont get the answers i want. If you have an example, could you please explain what it means if its complicated, I really want to learn and not just copy someone elses code without understanding it if there are any other flaws, please point them out. thank you so much this is what i have so far
@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('!roll d20'):
ThrowD20 = random.randint(1, 20)
await message.channel.send (ThrowD20)
if message.content.startswith('!roll d12'):
ThrowD12 = random.randint(1, 12)
await message.channel.send (ThrowD12)
if message.content.startswith('!roll d10'):
ThrowD10 = random.randint(1, 10)
await message.channel.send (ThrowD10)
if message.content.startswith('!roll d8'):
ThrowD8 = random.randint(1, 8)
await message.channel.send (ThrowD8)
if message.content.startswith('!roll d6'):
ThrowD6 = random.randint(1, 6)
await message.channel.send (ThrowD6)
if message.content.startswith('!roll d4'):
ThrowD4 = random.randint(1, 4)
await message.channel.send (ThrowD4)
you can find a better explanation here but this will get the job done
await message.channel.send(f"{message.author.mention} your roll is {ThrowD4}")
and this is the discord.py docs where you can find the mention method