-
Notifications
You must be signed in to change notification settings - Fork 0
/
react.py
34 lines (28 loc) · 827 Bytes
/
react.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import discord
import os
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('TOKEN')
SERVER_ID = os.getenv('SERVER')
CHANNEL_ID = os.getenv('CHANNEL')
TARGET_WORD = os.getenv('TARGET')
REACTION_EMOJI = os.getenv('EMOJI')
client = discord.Client()
@client.event
async def on_ready():
print(f'We have logged in as {client.user.name}')
@client.event
async def on_message(message):
try:
if (
message.guild.id == SERVER_ID
and message.channel.id == CHANNEL_ID
and TARGET_WORD in message.content.lower()
):
print(f"Received target message: {message.content}")
emoji = REACTION_EMOJI
await message.add_reaction(emoji)
print("Reacted to message")
except Exception as e:
print(e)
client.run(TOKEN)