mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 18:16:34 +01:00
Fix on)command_error
This commit is contained in:
parent
14a6b62cb9
commit
2898d263ff
2 changed files with 19 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import typing
|
import aiosqlite
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
@ -29,29 +29,36 @@ class McDonaldsCog(commands.Cog):
|
||||||
)
|
)
|
||||||
self.targets[message.author] = message.created_at.timestamp()
|
self.targets[message.author] = message.created_at.timestamp()
|
||||||
else:
|
else:
|
||||||
await message.reply(
|
|
||||||
"Thank you. You may now resume your activity.",
|
|
||||||
delete_after=60
|
|
||||||
)
|
|
||||||
self.targets.pop(message.author, None)
|
self.targets.pop(message.author, None)
|
||||||
self.cooldown[message.author] = message.created_at.timestamp()
|
self.cooldown[message.author] = message.created_at.timestamp()
|
||||||
|
await message.reply(
|
||||||
|
"Thank you. You may now resume your activity.",
|
||||||
|
delete_after=120
|
||||||
|
)
|
||||||
|
|
||||||
@commands.user_command(name="Commercial Break")
|
@commands.user_command(name="Commercial Break")
|
||||||
async def commercial_break(self, ctx: discord.ApplicationContext, member: discord.Member):
|
async def commercial_break(self, ctx: discord.ApplicationContext, member: discord.Member):
|
||||||
await ctx.defer(ephemeral=True)
|
await ctx.defer(ephemeral=True)
|
||||||
|
|
||||||
if not ctx.channel.permissions_for(ctx.me).manage_messages:
|
if not ctx.channel.permissions_for(ctx.me).manage_messages:
|
||||||
return await ctx.respond("I don't have permission to manage messages in this channel.", ephemeral=True)
|
return await ctx.respond("I don't have permission to manage messages in this channel.", ephemeral=True)
|
||||||
|
|
||||||
if member.bot or member == ctx.user:
|
if member.bot or member == ctx.user:
|
||||||
return await ctx.respond("No.", ephemeral=True)
|
return await ctx.respond("No.", ephemeral=True)
|
||||||
|
|
||||||
if member in self.targets.keys():
|
if member in self.targets.keys():
|
||||||
await ctx.respond(f"{member.mention} is already in a commercial break.")
|
await ctx.respond(f"{member.mention} is already in a commercial break.")
|
||||||
return
|
return
|
||||||
elif member in self.cooldown.keys() and self.cooldown[member] + 300 > discord.utils.utcnow().timestamp():
|
elif member in self.cooldown.keys():
|
||||||
await ctx.respond(
|
expires = self.cooldown[member] + 300
|
||||||
f"{member.mention} is not due another ad break yet. Their next commercial break will start "
|
if expires > discord.utils.utcnow().timestamp():
|
||||||
f"<t:{int(self.cooldown[member] + 300)}:R> at the earliest."
|
await ctx.respond(
|
||||||
)
|
f"{member.mention} is not due another ad break yet. Their next commercial break will start "
|
||||||
return
|
f"<t:{int(expires)}:R> at the earliest."
|
||||||
|
)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
self.cooldown.pop(member, None)
|
||||||
|
|
||||||
self.targets[member] = discord.utils.utcnow().timestamp()
|
self.targets[member] = discord.utils.utcnow().timestamp()
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
|
|
2
main.py
2
main.py
|
@ -60,7 +60,7 @@ async def on_command_error(ctx: commands.Context, error: Exception):
|
||||||
return
|
return
|
||||||
elif isinstance(error, JimmyBanException):
|
elif isinstance(error, JimmyBanException):
|
||||||
return await ctx.reply(str(error))
|
return await ctx.reply(str(error))
|
||||||
await ctx.reply("Command Error: `%r`" % error)
|
await ctx.reply(textwrap.shorten("Command Error: `%r`" % error, 2000))
|
||||||
raise error
|
raise error
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue