0
votes

My AFK command works great except for the fact that I can only use one word reasons. Example, I would say -afk walking the dog. Whenever someone pings me in the discord server that I went AFK in it would only say (user) if afk. Reason: Walking. I'm trying to figure out how to make it say multiple words instead of just one. Here is some of my afk command

@client.event async def on_message(message): global afkdict if message.author in afkdict: afkdict.pop(message.author)

for member in message.mentions:  
    if member != message.author:  
        if member in afkdict:  
            afkmsg = afkdict[member]  
            await message.channel.send(f" {member} is afk. Reason: {afkmsg}")
await client.process_commands(message)
1

1 Answers

2
votes

Sadly I don't have 50 rep yet, else I would just comment You forgot to provide the afk command.

I can imagine your mistake tho:

@client.command()
async def afk(ctx, *, reason):
    global afkdict
    afkdict[ctx.author] = reason

The important thing is the *, which means that everything after that point in the message is pushed into the argument parameter.

e.g -afk Walking the dog

---> reason is "Walking the Dog"