Discord.py How to ping users?
How do I let my discord bot ping users? I'm using it for a welcome style message. I still need to figure out how to add channel ID but the pinging problem has stopped me before
@client.event
async def on_member_join(member):
await member.send(f"{member.name} has joined")
This is what I used
Voters
Coder100 (16983)
@client.event
async def on_member_join(member):
await member.send(f"@{member.name} has joined")
if that doesn't work, maybe try
@client.event
async def on_member_join(member):
await member.send(f"<@!{member.id}> has joined")
Coder100 (16983)
yeah so i encapsulated with the ping <@!
and >
@LD1
slavstic (0)
So i tried those commands and also kind of combined it with LD1's response, and now i think it's the channel id that's the problem.
@client.event
async def on_member_join(welcomeChannel, member):
welcomeChannel = client.get_channel(490042165926428672)
await welcomeChannel.send("<@" + str({member.name}) + ">")
Do you know how to make it message the specific channel?
Coder100
slavstic (0)
@LD1 Nope. No error or anything. Pretty odd
LD1 (53)
Try this then
@client.event
async def on_member_join(welcomeChannel, member):
try:
print("Event Called")
welcomeChannel = client.get_channel(490042165926428672)
print("Welcome Channel": welcomeChannel)
await welcomeChannel.send(member.mention)
print("Sent")
except Exception as e:
print(type(e), e)
Discord uses special formatting for pings:
<@user_id>
. With discord.py, there are two easy ways to ping a user:Thank you! Now I just need to figure out how to use it in the on_member_join event @LD1