-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSelf_Bot.py
88 lines (71 loc) · 2.42 KB
/
Self_Bot.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
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
81
82
83
84
85
86
87
88
from discord import Embed
from discord.errors import HTTPException
from discord.ext.commands import Bot
from util import misc
bot = Bot(command_prefix="self_", self_bot=True)
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
extensions = ['cogs.base',
'cogs.chart',
'cogs.owner',
'cogs.server',
'cogs.stars']
for extension in extensions:
try:
bot.load_extension(extension)
except Exception as e:
print('Failed to load extension {}.'.format(extension))
print(e)
@bot.event
async def on_message(message):
try:
await bot.process_commands(message)
except HTTPException as err:
await message.channel.send(err)
raise
@bot.event
async def on_reaction_add(reaction, user):
if user.id == bot.user.id:
# print("Reaction at " + datetime.now().strftime("%H:%M:%S"))
global reaction_text
if reaction.emoji == '\U0001F643' and reaction_text != '':
await reaction.message.remove_reaction(reaction.emoji, user)
for a in reaction_text.lower():
if a.isalpha():
emoji = misc.get_alpha_emoji(a)
await reaction.message.add_reaction(emoji)
reaction_text = ''
@bot.command()
async def prime(ctx, *, react: str = None):
if react is not None:
global reaction_text
reaction_text = react
# await bot.edit_message(ctx.message, 'Reaction primed. Trigger with \U0001F643')
# await asyncio.sleep(1)
await ctx.message.delete()
@bot.command()
async def unprime(ctx):
global reaction_text
reaction_text = ""
await ctx.message.delete()
@bot.command()
async def embed(ctx):
split = ctx.message.content.split(" ", 1)
if len(split) > 1:
parts = split[1].split(" | ")
if len(parts) == 3:
em = Embed(title=parts[0], color=0xff0000)
em.add_field(name=parts[1], value=parts[2])
await ctx.send(embed=em)
if len(parts) == 4:
em = Embed(title=parts[0], color=int(parts[3]))
em.add_field(name=parts[1], value=parts[2])
await ctx.send(embed=em)
await ctx.message.delete()
with open('selftoken.txt', 'r') as token_file:
token = token_file.readline().strip()
bot.run(token, bot=False)