-
-
Save burturt/69d88d133558a70145ce796541329a39 to your computer and use it in GitHub Desktop.
Discord bot who can pin messages with just adding reaction π (:pushpin:)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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