diff options
author | 2025-05-29 14:24:13 +0200 | |
---|---|---|
committer | 2025-05-29 14:24:13 +0200 | |
commit | f26d03a1f5d7a69e7130c0448587f6b0153d9065 (patch) | |
tree | 81c9244fc664603eb47d37af142cdb3f53bad0b1 | |
parent | Allow helpers to access rule 4 (diff) |
Add motivational voice chat messages (#325)
-rw-r--r-- | arthur/bot.py | 2 | ||||
-rw-r--r-- | arthur/exts/fun/motivation.py | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/arthur/bot.py b/arthur/bot.py index 32b0240..86db7f2 100644 --- a/arthur/bot.py +++ b/arthur/bot.py @@ -35,7 +35,7 @@ class KingArthur(BotBase): return CONFIG.devops_role in [r.id for r in ctx.user.roles] return False - if ctx.command.name in {"ed", "rules"}: + if ctx.command.name in {"ed", "rules", "monitor"}: return True if not ctx.guild: diff --git a/arthur/exts/fun/motivation.py b/arthur/exts/fun/motivation.py index 6ab209f..ec38a57 100644 --- a/arthur/exts/fun/motivation.py +++ b/arthur/exts/fun/motivation.py @@ -1,5 +1,6 @@ """Send motivating messages to the devops team.""" +import random import re from datetime import UTC, datetime, time @@ -77,6 +78,39 @@ class Motivation(commands.Cog): embed.set_image(url=image) await self.devops_channel.send(embed=embed) + @commands.command(name="monitor") + async def monitor( + self, + ctx: commands.Context, + channel: discord.VoiceChannel | discord.StageChannel | None = None, + ) -> None: + """Obey.""" + if not ctx.guild: + return + + if not channel and isinstance(ctx.author, discord.Member) and (vs := ctx.author.voice): + channel = vs.channel + + if not channel: + await ctx.send(":x: You will join a voice channel or pass one as argument!") + return + + vc = ctx.guild.voice_client + if vc is None: + vc = await channel.connect(self_deaf=True, self_mute=False) + else: + await vc.move_to(channel) + + selection = random.randint(1, 23) + monitor = f"https://pydis.wtf/~fredrick/monitor-{selection:03d}.mp3" + audio = await discord.FFmpegOpusAudio.from_probe(monitor) + vc.play(audio) + if random.random() < 0.1: # noqa: PLR2004 + for emoji in ("🇴", "🇧", "🇪", "🇾"): + await ctx.message.add_reaction(emoji) + else: + await ctx.message.add_reaction("🔊") + async def setup(bot: KingArthur) -> None: """Add cog to bot.""" |