Skip to content

Instantly share code, notes, and snippets.

@burturt
Forked from yhay81/pin-bot.py
Created October 14, 2020 16:49
Show Gist options
  • Save burturt/69d88d133558a70145ce796541329a39 to your computer and use it in GitHub Desktop.
Save burturt/69d88d133558a70145ce796541329a39 to your computer and use it in GitHub Desktop.
Discord bot who can pin messages with just adding reaction πŸ“Œ (:pushpin:)
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):
# print(reaction.emoji)
# print("reaction added")
try:
if str(reaction.emoji) == "πŸ“Œ":
await reaction.message.pin()
except:
print("Failed to add emoji")
@client.event
async def on_reaction_remove(reaction, user):
if reaction.emoji == "πŸ“Œ":
try:
if not ":pushpin:" in [ reaction.emoji.name for reaction in reaction.message.reactions]:
await reaction.message.unpin()
except:
print("Failed to remove emoji")
if __name__ == '__main__':
client.run('BOTTOKEN')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment