remind: add cooldowns; also add botlog channel
This commit is contained in:
parent
c79093eb57
commit
203761856e
4 changed files with 18 additions and 10 deletions
16
Robocop.py
16
Robocop.py
|
@ -83,19 +83,19 @@ async def on_ready():
|
|||
aioh = {"User-Agent": f"{script_name}/1.0'"}
|
||||
bot.aiosession = aiohttp.ClientSession(headers=aioh)
|
||||
bot.app_info = await bot.application_info()
|
||||
bot.botlog_channel = bot.get_channel(config.botlog_channel)
|
||||
|
||||
log.info(f'\nLogged in as: {bot.user.name} - '
|
||||
f'{bot.user.id}\ndpy version: {discord.__version__}\n')
|
||||
game_name = f"{config.prefixes[0]}help"
|
||||
|
||||
# Send "Robocop has started! x has y members!"
|
||||
log_channel = bot.get_channel(config.log_channel)
|
||||
guild = log_channel.guild
|
||||
guild = bot.botlog_channel.guild
|
||||
msg = f"{bot.user.name} has started! "\
|
||||
f"{guild.name} has {guild.member_count} members!"
|
||||
|
||||
data_files = [discord.File(fpath) for fpath in wanted_jsons]
|
||||
await log_channel.send(msg, files=data_files)
|
||||
await bot.botlog_channel.send(msg, files=data_files)
|
||||
|
||||
await bot.change_presence(activity=discord.Game(name=game_name))
|
||||
|
||||
|
@ -121,9 +121,13 @@ async def on_error(event_method, *args, **kwargs):
|
|||
async def on_command_error(ctx, error):
|
||||
error_text = str(error)
|
||||
|
||||
log.error(f"Error with \"{ctx.message.content}\" from "
|
||||
f"\"{ctx.message.author} ({ctx.message.author.id}) "
|
||||
f"of type {type(error)}: {error_text}")
|
||||
err_msg = f"Error with \"{ctx.message.content}\" from "\
|
||||
f"\"{ctx.message.author} ({ctx.message.author.id}) "\
|
||||
f"of type {type(error)}: {error_text}"
|
||||
|
||||
log.error(err_msg)
|
||||
|
||||
await bot.botlog_channel.send(err_msg)
|
||||
|
||||
if isinstance(error, commands.NoPrivateMessage):
|
||||
return await ctx.send("This command doesn't work on DMs.")
|
||||
|
|
|
@ -10,6 +10,7 @@ class Remind:
|
|||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.cooldown(1, 60, type=commands.BucketType.user)
|
||||
@commands.command()
|
||||
async def remindlist(self, ctx):
|
||||
"""Lists your reminders."""
|
||||
|
@ -25,6 +26,7 @@ class Remind:
|
|||
inline=False)
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
@commands.cooldown(1, 60, type=commands.BucketType.user)
|
||||
@commands.command()
|
||||
async def remind(self, ctx, when: str, *, text: str = "something"):
|
||||
"""Reminds you about something."""
|
||||
|
@ -37,6 +39,7 @@ class Remind:
|
|||
"remind interval is 5 seconds.")
|
||||
await asyncio.sleep(5)
|
||||
await msg.delete()
|
||||
return
|
||||
|
||||
expiry_datetime = datetime.utcfromtimestamp(expiry_timestamp)
|
||||
duration_text = self.bot.get_relative_timestamp(time_to=expiry_datetime,
|
||||
|
|
|
@ -17,7 +17,7 @@ class Robocronp:
|
|||
|
||||
async def send_data(self):
|
||||
data_files = [discord.File(fpath) for fpath in self.bot.wanted_jsons]
|
||||
log_channel = self.bot.get_channel(config.log_channel)
|
||||
log_channel = self.bot.get_channel(config.botlog_channel)
|
||||
await log_channel.send("Hourly data backups:", files=data_files)
|
||||
|
||||
@commands.guild_only()
|
||||
|
@ -54,7 +54,7 @@ class Robocronp:
|
|||
await ctx.send(f"{ctx.author.mention}: Deleted!")
|
||||
|
||||
async def do_jobs(self, ctab, jobtype, timestamp):
|
||||
log_channel = self.bot.get_channel(config.log_channel)
|
||||
log_channel = self.bot.get_channel(config.botlog_channel)
|
||||
for job_name in ctab[jobtype][timestamp]:
|
||||
try:
|
||||
job_details = ctab[jobtype][timestamp][job_name]
|
||||
|
@ -90,7 +90,7 @@ class Robocronp:
|
|||
|
||||
async def minutely(self):
|
||||
await self.bot.wait_until_ready()
|
||||
log_channel = self.bot.get_channel(config.log_channel)
|
||||
log_channel = self.bot.get_channel(config.botlog_channel)
|
||||
while not self.bot.is_closed():
|
||||
try:
|
||||
ctab = get_crontab()
|
||||
|
@ -107,7 +107,7 @@ class Robocronp:
|
|||
|
||||
async def hourly(self):
|
||||
await self.bot.wait_until_ready()
|
||||
log_channel = self.bot.get_channel(config.log_channel)
|
||||
log_channel = self.bot.get_channel(config.botlog_channel)
|
||||
while not self.bot.is_closed():
|
||||
# Your stuff that should run at boot
|
||||
# and after that every hour goes here
|
||||
|
|
|
@ -37,6 +37,7 @@ staff_role_ids = [526384077679624192, # Team role in NotSwitched
|
|||
526383985430102016] # Wizard role in NotSwitched
|
||||
|
||||
log_channel = 526377735908491284 # Log channel in NotSwitched
|
||||
botlog_channel = 529070401704296460 # Botlog channel in NotSwitched
|
||||
welcome_channel = 526372470752673792 # rules-info channel in NotSwitched
|
||||
|
||||
community_channels = [526378423468425236] # Channels requiring community role
|
||||
|
|
Loading…
Reference in a new issue