-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiscordBot.py
More file actions
80 lines (67 loc) · 2.88 KB
/
Copy pathDiscordBot.py
File metadata and controls
80 lines (67 loc) · 2.88 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import discord
from discord import app_commands
import os
import asyncio
import keep_alive
allowed = {"e", "え", "エ", "一"}
with open("channels.txt") as file:
channels = file.read().split("\n")
with open("reacts.txt") as file:
reacts = file.read().split("\n")
def check(msg):
return len(msg) and msg - allowed == set()
client = discord.Client(intents = discord.Intents.all())
tree = app_commands.CommandTree(client)
@tree.command(name = "eenable", description = "Toggles EEE bot responses on and off in this channel")
async def commandEenable(interaction):
id = str(interaction.channel_id)
if interaction.user.guild_permissions.administrator:
if id not in channels:
channels.append(id)
with open("channels.txt", "w") as file:
file.write("\n".join(channels))
await interaction.response.send_message("EEE bot responses turned on")
else:
channels.remove(id)
with open("channels.txt", "w") as file:
file.write("\n".join(channels))
await interaction.response.send_message("EEE bot responses turned off")
else:
await interaction.response.send_message("You need admin permissions for this command")
@tree.command(name = "reeact", description = "Toggles EEE bot reactions on and off in this channel")
async def commandReeact(interaction):
id = str(interaction.channel_id)
if interaction.user.guild_permissions.administrator:
if id not in reacts:
reacts.append(id)
with open("reacts.txt", "w") as file:
file.write("\n".join(reacts))
await interaction.response.send_message("EEE bot reactions turned on")
else:
reacts.remove(id)
with open("reacts.txt", "w") as file:
file.write("\n".join(reacts))
await interaction.response.send_message("EEE bot reactions turned off")
else:
await interaction.response.send_message("You need admin permissions for this command")
async def react(channel):
if len(channel) == 0: return
async for message in client.get_channel(int(channel)).history():
for reaction in message.reactions:
if reaction.me: return
await message.add_reaction("🇪")
await message.add_reaction("<:RushE:1012953390596247632>")
await message.add_reaction("<:EEE:1012954135387197562>")
@client.event
async def on_ready():
await tree.sync()
print('Logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
id = str(message.channel.id)
msg = message.content
msgletters = set( "".join( filter(str.isalpha, msg) ).lower() )
if message.author != client.user and id in channels and check(msgletters):
await message.channel.send(message.content)
asyncio.gather(*[react(channel) for channel in reacts])
client.run(os.environ['TOKEN'])