how can i code discord bot to delete "user pinned a message" message?

i attempted coding using python for my discord bot to automatically delete the "user pinned a message to this channel..." message every time someone pins a message to the channel but it's not working and i cannot figure out why :( please help if u can? tysm <3

my problem: the bot is not deleting "user pinned a message to this channel. see all pinned messages." message when i pin a msg

this is my code: what i tried :v

if message.type == "PINS_ADD" and message.author.bot: 
   await message.delete()

what am i doing wrong? i have to add that i am a beginner so-

Upvotes: 1

Views: 854

Answers (1)

Guddi
Guddi

Reputation: 644

message.author.bot is only True if the message is written by the Bot himself. Since the message you like to delete is a System message, this is not the case

just remove it and it should work

if message.type is discord.MessageType.pins_add:
   await message.delete()

# or i think this would also work
if str(message.type) == "pins_add"
    await message.delete()

Upvotes: 2

Related Questions