Skip to content

Instantly share code, notes, and snippets.

@yhay81
Last active April 12, 2022 11:32
Show Gist options
  • Save yhay81/31d1402e29d4f635d1c878909b30f82a to your computer and use it in GitHub Desktop.
Save yhay81/31d1402e29d4f635d1c878909b30f82a to your computer and use it in GitHub Desktop.
Discord bot who can pin messages with just adding reaction πŸ“Œ
import discord
client = discord.Client()
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
@client.event
async def on_server_join(server):
return await client.send_message(
server.default_channel,
""" Just add reaction of πŸ“Œ, and the message pinned! """
)
@client.event
async def on_reaction_add(reaction, user):
if str(reaction.emoji) == "πŸ“Œ":
await client.pin_message(reaction.message)
@client.event
async def on_reaction_remove(reaction, user):
if reaction.emoji == "πŸ“Œ":
if not ":pushpin:" in [ reaction.emoji for reaction in reaction.message.reactions]:
await client.unpin_message(reaction.message)
if __name__ == '__main__':
client.run('YOUR CLIENT SECRET')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment