Bugfix: WillieTimer
This commit is contained in:
@@ -14,6 +14,8 @@ class WillieTimer(commands.Cog):
|
||||
self.bot = bot
|
||||
self.mention_group = str(self.bot.Default_Mention_Group)
|
||||
self.channel_id = int(self.bot.Default_Channel_ID)
|
||||
self.channel = self.bot.get_channel(id=self.channel_id)
|
||||
self.guild = self.channel.guild
|
||||
self.lock = False
|
||||
self.current_phrase = None
|
||||
self.caller_name = None
|
||||
@@ -24,7 +26,6 @@ class WillieTimer(commands.Cog):
|
||||
async def bg_timer(self):
|
||||
# Get variables ready before waiting for the next minute, might take a few seconds
|
||||
await self.bot.wait_until_ready()
|
||||
channel = self.bot.get_channel(id=self.channel_id)
|
||||
output_string = self.get_output_string()
|
||||
|
||||
seconds_until_next_minute = int(60 - int(datetime.datetime.now().strftime('%S')))
|
||||
@@ -35,12 +36,12 @@ class WillieTimer(commands.Cog):
|
||||
# If it is 4:20pm
|
||||
if datetime.datetime.now().strftime('%H:%M') in "16:20":
|
||||
print(f"It's {datetime.datetime.now().strftime('%H:%M:%S')}!")
|
||||
await channel.send(output_string['420'])
|
||||
await self.channel.send(output_string['420'])
|
||||
|
||||
# A warm up to 4:20pm
|
||||
if datetime.datetime.now().strftime('%H:%M') in "16:17":
|
||||
print(f"It's {datetime.datetime.now().strftime('%H:%M:%S')}!")
|
||||
await channel.send(output_string['warm up'])
|
||||
await self.channel.send(output_string['warm up'])
|
||||
|
||||
@commands.command(help="Use this command to start the background task to wait for 4:20",
|
||||
brief="Starts the 4:20 clock")
|
||||
@@ -105,22 +106,16 @@ class WillieTimer(commands.Cog):
|
||||
await ctx.send(f"420:\t{strings_dict['420']}\nWarning:\t{strings_dict['warm up']}", tts=True)
|
||||
|
||||
def bot_get_role(self):
|
||||
channel = self.bot.get_channel(id=self.channel_id)
|
||||
guild = channel.guild
|
||||
role = discord.utils.get(guild.roles, name=self.mention_group)
|
||||
role = discord.utils.get(self.guild.roles, name=self.mention_group)
|
||||
return role
|
||||
|
||||
def bot_get_user(self, input_user=None):
|
||||
if self.caller_name is not None:
|
||||
channel = self.bot.get_channel(id=self.channel_id)
|
||||
guild = channel.guild
|
||||
user = discord.utils.get(guild.members, name=self.caller_name)
|
||||
user = discord.utils.get(self.guild.members, name=self.caller_name)
|
||||
print(f"Got user: {user}")
|
||||
return user
|
||||
elif input_user is not None:
|
||||
channel = self.bot.get_channel(id=self.channel_id)
|
||||
guild = channel.guild
|
||||
user = discord.utils.get(guild.members, name=input_user)
|
||||
user = discord.utils.get(self.guild.members, name=input_user)
|
||||
print(f"Got user: {user}")
|
||||
return user
|
||||
|
||||
@@ -159,8 +154,8 @@ class WillieTimer(commands.Cog):
|
||||
willie_time_string = ""
|
||||
warm_up_string = ""
|
||||
if self.caller_name is not None:
|
||||
willie_time_string += f"<@&{self.bot_get_user().id}> & "
|
||||
warm_up_string += f"<@&{self.bot_get_user().id}> & "
|
||||
willie_time_string += f"<@&{self.bot_get_user()}> & "
|
||||
warm_up_string += f"<@&{self.bot_get_user()}> & "
|
||||
|
||||
willie_time_string += f"<@&{self.bot_get_role().id}>! "\
|
||||
f"Willie wanted me to tell you:\n" \
|
||||
|
||||
Reference in New Issue
Block a user