diff --git a/bot.py b/bot.py index cedd792..82cf8d4 100644 --- a/bot.py +++ b/bot.py @@ -84,7 +84,8 @@ async def on_message(message: discord.Message): cooldown = config_get('och-cooldown', message.guild.id) t = time.time() - _get_last_och_time(message.guild) 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 _set_last_och_time(message.guild) @@ -246,7 +247,7 @@ async def flip_pipelin_command(ctx: commands.Context): @bot.command(name='quote', brief='Get a random quote or add new ones') async def quote_command(ctx: commands.Context, author: Optional[str], *, quote: Optional[str]): - quotes: Optional[dict[str,List[str]]] = config_get("guild_quotes", guild=ctx.guild.id) + quotes: Optional[dict[str, List[str]]] = config_get("guild_quotes", guild=ctx.guild.id) if quotes is None: quotes = {} config_set_raw("guild_quotes", quotes, ctx.guild.id) @@ -291,6 +292,27 @@ async def quote_command(ctx: commands.Context, author: Optional[str], *, quote: 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: if message.clean_content.strip() == '': return False