- Updates to bot responses
- Added BotResources.py - Updates to saving and loading of config file - Updated how you call the save config function - Allowed saving of one variable
This commit is contained in:
@@ -3,13 +3,14 @@ import datetime
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from discord.ext.tasks import loop
|
||||
from BotResources import write_config_file
|
||||
|
||||
|
||||
class WillieTimer(commands.Cog):
|
||||
def __init__(self, bot, mention_group='Superadmins', channel_id=757379843792044102):
|
||||
def __init__(self, bot): #, mention_group='Superadmins', channel_id=757379843792044102):
|
||||
self.bot = bot
|
||||
self.mention_group = str(mention_group)
|
||||
self.channel_id = int(channel_id)
|
||||
self.mention_group = str(self.bot.Default_Mention_Group)
|
||||
self.channel_id = int(self.bot.Default_Channel_ID)
|
||||
|
||||
@loop(minutes=1)
|
||||
async def bg_timer(self):
|
||||
@@ -20,11 +21,7 @@ class WillieTimer(commands.Cog):
|
||||
if datetime.datetime.now().strftime('%H:%M') in ("04:20", "16:20"):
|
||||
print(f"It's {datetime.datetime.now().strftime('%H:%M:%S')}!")
|
||||
channel = self.bot.get_channel(id=self.channel_id)
|
||||
guild = channel.guild
|
||||
role_id = discord.utils.get(guild.roles, name=self.mention_group)
|
||||
print(role_id)
|
||||
print(role_id.id)
|
||||
await channel.send(f"<@&{role_id.id}> It's 4:20! It's time to light up!")
|
||||
await channel.send(f"<@&{self.bot_get_role().id}> It's 4:20! It's time to light up!")
|
||||
|
||||
@commands.command(help="Use this command to start the background task to wait for 4:20",
|
||||
brief="Starts the 4:20 clock")
|
||||
@@ -47,8 +44,12 @@ class WillieTimer(commands.Cog):
|
||||
message = int(message)
|
||||
if message and len(str(message)) == len(str(self.channel_id)):
|
||||
self.channel_id = message
|
||||
print(message)
|
||||
except:
|
||||
await ctx.send(f"Ok {member}, I'll let Willie know to reach you in "
|
||||
f"{self.bot.get_channel(id=self.channel_id)}")
|
||||
print(message)
|
||||
write_config_file(Channel_ID=self.channel_id)
|
||||
except Exception as e:
|
||||
print(f"Exception in chchn:\t{e}")
|
||||
await ctx.send(f"{member}, {message} is not a valid channel ID, please try again")
|
||||
pass
|
||||
|
||||
@@ -58,13 +59,22 @@ class WillieTimer(commands.Cog):
|
||||
member = member or ctx.author.display_name
|
||||
try:
|
||||
message = str(message)
|
||||
if message and len(str(message)) == len(str(self.channel_id)):
|
||||
if message:
|
||||
self.mention_group = message
|
||||
print(message)
|
||||
except:
|
||||
await ctx.send(f"Ok {member}, I'll let Willie know to tell {self.bot_get_role()}")
|
||||
print(message)
|
||||
write_config_file(mention_group=self)
|
||||
except Exception as e:
|
||||
print(f"Exception in chmtn:\t{e}")
|
||||
await ctx.send(f"{member}, {message} is not a valid role, please try again")
|
||||
pass
|
||||
|
||||
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)
|
||||
return role
|
||||
|
||||
|
||||
def setup(bot: commands.Bot):
|
||||
bot.add_cog(WillieTimer(bot))
|
||||
|
||||
Reference in New Issue
Block a user