mirror of
https://github.com/TotalFreedomMC/TotalFreedomBot.git
synced 2024-12-22 23:54:58 +00:00
Update events.py
This commit is contained in:
parent
bb7754f6d8
commit
07d49bc756
1 changed files with 5 additions and 10 deletions
15
events.py
15
events.py
|
@ -35,14 +35,9 @@ class Events(commands.Cog):
|
||||||
|
|
||||||
print(f'[{str(datetime.utcnow().replace(microsecond=0))[11:]} INFO]: [TELNET] Bot logged into Telnet as: {self.bot.telnet_object.username}')
|
print(f'[{str(datetime.utcnow().replace(microsecond=0))[11:]} INFO]: [TELNET] Bot logged into Telnet as: {self.bot.telnet_object.username}')
|
||||||
|
|
||||||
for file in ['reactionroles.txt']:
|
reaction_data = read_json('config')
|
||||||
async with aiofiles.open(file, mode='a') as temp:
|
self.bot.reaction_roles = reaction_data['reaction_roles']
|
||||||
pass
|
print(self.bot.reaction_roles)
|
||||||
async with aiofiles.open('reactionroles.txt', mode='r') as file:
|
|
||||||
lines = await file.readlines()
|
|
||||||
for line in lines:
|
|
||||||
data = line.split(' ')
|
|
||||||
self.bot.reaction_roles.append((int(data[0]), int(data[1]), data[2].strip('\n')))
|
|
||||||
|
|
||||||
print(f'[{str(datetime.utcnow().replace(microsecond=0))[11:]} INFO]: [Client] {self.bot.user.name} is online.')
|
print(f'[{str(datetime.utcnow().replace(microsecond=0))[11:]} INFO]: [Client] {self.bot.user.name} is online.')
|
||||||
game = discord.Game('play.totalfreedom.me')
|
game = discord.Game('play.totalfreedom.me')
|
||||||
|
@ -158,7 +153,7 @@ class Events(commands.Cog):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
for role_id, msg_id, emoji in self.bot.reaction_roles:
|
for role_id, msg_id, emoji in self.bot.reaction_roles:
|
||||||
if msg_id == payload.message_id and emoji == str(payload.emoji.name.encode('utf-8')):
|
if msg_id == payload.message_id and emoji == str(payload.emoji.name):
|
||||||
await payload.member.add_roles(self.bot.get_guild(payload.guild_id).get_role(role_id), reason='reaction')
|
await payload.member.add_roles(self.bot.get_guild(payload.guild_id).get_role(role_id), reason='reaction')
|
||||||
if payload.channel_id == reports_channel_id:
|
if payload.channel_id == reports_channel_id:
|
||||||
guild = self.bot.get_guild(guild_id)
|
guild = self.bot.get_guild(guild_id)
|
||||||
|
@ -183,7 +178,7 @@ class Events(commands.Cog):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
for role_id, msg_id, emoji in self.bot.reaction_roles:
|
for role_id, msg_id, emoji in self.bot.reaction_roles:
|
||||||
if msg_id == payload.message_id and emoji == str(payload.emoji.name.encode('utf-8')):
|
if msg_id == payload.message_id and emoji == str(payload.emoji.name):
|
||||||
await self.bot.get_guild(payload.guild_id).get_member(payload.user_id).remove_roles(self.bot.get_guild(payload.guild_id).get_role(role_id), reason='reaction')
|
await self.bot.get_guild(payload.guild_id).get_member(payload.user_id).remove_roles(self.bot.get_guild(payload.guild_id).get_role(role_id), reason='reaction')
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|
Loading…
Reference in a new issue