C
C
cataclysm882021-06-17 17:40:31
Python
cataclysm88, 2021-06-17 17:40:31

How to make 2 pings via Discord py?

There is this code:

async def report(ctx, member: discord.Member,  *, arg):
    role = ctx.guild.get_role(999999999999) # Представьте, что 9999999 id роли модератора
    members = ctx.guild.members
    await ctx.channel.send('Your complaint was sent to moderators!', delete_after=10)
    for member in members:
        if role in member.roles:
            await member.send(f'{ctx.author.mention} оставил жалобу на {member.mention} с причиной:\n**{arg}**')
            await ctx.message.delete()


What the code does:
When we write $report @user the reason is that all people who have the moderator role i.e. id 999999999999, a private message is sent to them that @Author left a complaint against @Intruder with the reason: Reason.
And here is such a problem that instead of the name of the Violator, the name of the moderator is sent to the PM, to whom this message is sent to the PM.
Those. if the moderator's name is John, for example, then he receives this in the PM:
@The author left a complaint against @John, although he left it against another.
Here's how to fix it, I've been trying to do it for 2 days now.
I need the moderator to receive this in the PM, and without any bugs:unknown.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-06-17
@cataclysm88

You pass the offender's name into a variable. member
Then, in a loop, overwrite the value of that variable with the name of the person with the moderator role
for member in members:
. Either do for user in users:and , respectively await user.send, or come up with a different parameter name for the offender.
In general, correct the variable names so that they do not intersect. To do this, it is worth making more explicit names of variables, the same memberdefinition has too general.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question