commit
Lets do this
diff --git a/commands/cogs/fun/incidents.py b/commands/cogs/fun/incidents.py
index e7cf908..7764f7e 100644
--- a/commands/cogs/fun/incidents.py
+++ b/commands/cogs/fun/incidents.py
@@ -1,8 +1,6 @@
-from commands.admin import ownerOnly
from commands.settings.incidents import isIgnored
from datetime import datetime, timedelta
import discord
-from discord import app_commands
from discord.ext import commands, tasks
from discord.utils import utcnow
import random
@@ -115,22 +113,6 @@ class Incidents(commands.Cog):
self.lastActivity = None
return True
- @app_commands.command(
- name="incident",
- description=(
- "(owner) Force a puppet incident in the last active channel"
- ),
- )
- @ownerOnly()
- async def incident(self, interaction: discord.Interaction) -> None:
- fired = await self.fireIncident()
- message = (
- "Incident dispatched."
- if fired
- else "No suitable active channel right now."
- )
- await interaction.response.send_message(message, ephemeral=True)
-
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(Incidents(bot))
diff --git a/sandrone/mood.py b/sandrone/mood.py
index 4329443..7574d57 100644
--- a/sandrone/mood.py
+++ b/sandrone/mood.py
@@ -4,14 +4,36 @@ import random
from sandrone import config
from utils import components
+SASSY_CHANCE = 5
+
+
+class ShuffleBag:
+ """Hands out every item once, in random order, before any repeat."""
+
+ def __init__(self, items: list[str]) -> None:
+ self.items = items
+ self.remaining: list[str] = []
+ self.last: str | None = None
+
+ def draw(self) -> str:
+ if not self.remaining:
+ self.remaining = random.sample(self.items, len(self.items))
+ # Don't repeat the last line straight across a refill.
+ if len(self.remaining) > 1 and self.remaining[-1] == self.last:
+ self.remaining[0], self.remaining[-1] = (
+ self.remaining[-1],
+ self.remaining[0],
+ )
+ self.last = self.remaining.pop()
+ return self.last
+
+
sassy_replies = [
"Sandrone has determined that this command is beneath her.",
(
"Sandrone is tired of your command usage. Ask again nicely and "
"she might do it."
),
- "No.",
- "Absolutely not.",
"Sandrone has decided that you have used enough commands today.",
"The puppet has reviewed your request. It has declined.",
(
@@ -21,19 +43,22 @@ sassy_replies = [
]
+sassy_bag = ShuffleBag(sassy_replies)
+
+
class SassyDenial(app_commands.CheckFailure):
pass
async def _sassyCheck(interaction: discord.Interaction) -> bool:
- if random.randint(1, 10) != 1:
+ if random.randint(1, SASSY_CHANCE) != 1:
return True
await interaction.response.send_message(
view=components.panel(
body=(
"<:sandrone_refuses:1546669792595939468> "
- f"{random.choice(sassy_replies)}"
+ f"{sassy_bag.draw()}"
),
color=discord.Color.gold(),
)
@@ -203,5 +228,8 @@ incident_replies = [
]
+incident_bag = ShuffleBag(incident_replies)
+
+
def randomIncident() -> str:
- return random.choice(incident_replies)
+ return incident_bag.draw()