1
votes

I am making a custom discord bot in python. I am trying to add a !report command. I am very confused and cant find the answer anywhere. Can anyone help me make it?

I want any user to be able to do !report @example reason. and save it in a database such as excel or sql3 or preferably in a staff channel. how would I do this?

I have tried to use on_message()

1

1 Answers

1
votes

You could use the on_message() command:

@client.event
async def on_message(message):
    if message.content.startswith("!report"):
        report_channel = client.get_channel(channel id)
        member = text.split(" ")[1]
        reason = ' '.join(text.split(" ")[1:])
        await report_channel.send(f"Member: {member}, Reason: {reason}")

So the first thing is to look to see if the person used the "!report" command with an if statement.

Next, you find the member by taking the second word of the message.

After that, you find the reason by taking the rest of the words in the message.

Then you send it to the pre-defined report channel on discord.