Add quote remove command
This commit is contained in:
24
bot.py
24
bot.py
@@ -84,7 +84,8 @@ async def on_message(message: discord.Message):
|
|||||||
cooldown = config_get('och-cooldown', message.guild.id)
|
cooldown = config_get('och-cooldown', message.guild.id)
|
||||||
t = time.time() - _get_last_och_time(message.guild)
|
t = time.time() - _get_last_och_time(message.guild)
|
||||||
if t <= cooldown:
|
if t <= cooldown:
|
||||||
await message.channel.send('429: Too many requests - Wait ' + str(int(cooldown - t)) + ' more seconds!')
|
await message.channel.send(
|
||||||
|
'429: Too many requests - Wait ' + str(int(cooldown - t)) + ' more seconds!')
|
||||||
return
|
return
|
||||||
_set_last_och_time(message.guild)
|
_set_last_och_time(message.guild)
|
||||||
|
|
||||||
@@ -291,6 +292,27 @@ async def quote_command(ctx: commands.Context, author: Optional[str], *, quote:
|
|||||||
await ctx.channel.send("Unknown author!")
|
await ctx.channel.send("Unknown author!")
|
||||||
|
|
||||||
|
|
||||||
|
@bot.command(name='quote_remove', brief='Remove a quote')
|
||||||
|
async def quote_remove_command(ctx: discord.Context, author: str, quote: str):
|
||||||
|
quotes: Optional[dict[str, List[str]]] = config_get("guild_access", guild=ctx.guild.id)
|
||||||
|
if quotes is None:
|
||||||
|
await ctx.channel.send("No quotes available!")
|
||||||
|
|
||||||
|
else:
|
||||||
|
quote = quote.strip().lower()
|
||||||
|
author = author.strip().title()
|
||||||
|
if author in quotes:
|
||||||
|
for q in quotes[author]:
|
||||||
|
if q.lower() == quote:
|
||||||
|
quotes[author].remove(q)
|
||||||
|
if not quotes[author]:
|
||||||
|
quotes.pop(author)
|
||||||
|
await ctx.channel.send("Successfully removed quote!")
|
||||||
|
return
|
||||||
|
|
||||||
|
await ctx.channel.send("No such quote found!")
|
||||||
|
|
||||||
|
|
||||||
def _is_message_valid_for_selection(message: discord.Message, reaction_filter: Optional[str] = None) -> bool:
|
def _is_message_valid_for_selection(message: discord.Message, reaction_filter: Optional[str] = None) -> bool:
|
||||||
if message.clean_content.strip() == '':
|
if message.clean_content.strip() == '':
|
||||||
return False
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user