1446 lines
55 KiB
Python
Raw Permalink Normal View History

2025-02-13 14:51:35 -05:00
import os
import traceback
import urllib
import datetime
import random
2025-03-12 09:37:44 -04:00
from typing import Optional
2025-02-13 14:51:35 -05:00
import logging
import discord
import aiosqlite as sqlite3
2025-03-12 09:37:44 -04:00
from sh import cowsay as cow_say, fortune
from discord.ext import bridge, commands
2025-02-15 08:36:45 -05:00
from disc_havoc import Havoc
from util.misc_util import Util
2025-02-15 13:57:47 -05:00
from constructors import MiscException
2025-02-13 14:51:35 -05:00
"""
This plugin encompasses numerous tiny commands/functions that
do not necessitate their own cogs
"""
DRUGS_CHANID = 1172247451047034910
2025-04-17 14:35:56 -04:00
BOT_CHANIDS = []
2025-02-13 14:51:35 -05:00
2025-04-17 14:35:56 -04:00
class Misc(commands.Cog):
2025-02-13 14:51:35 -05:00
"""Misc/Assorted Cog for Havoc"""
2025-04-17 14:35:56 -04:00
2025-02-15 08:36:45 -05:00
def __init__(self, bot: Havoc):
self.bot: Havoc = bot
2025-02-13 14:51:35 -05:00
self.util = Util()
2025-04-17 14:35:56 -04:00
self.COWS: list[str] = os.listdir(
os.path.join("/", "usr", "share", "cowsay", "cows")
)
self.FATES: list[str] = [
"into a pile of white dog shit, face first",
"onto the floor",
"into a volcano",
"into a toaster bath",
"into a pit of venomous snakes",
"into oncoming traffic",
"off a bridge",
"into the roaring 20's",
"into an unknown orifice",
"into the large hadron collider",
"into an awkward nude group hug",
"into a swinger party",
"into an adoption agency, because even their parents didn't want them",
"into the gas chamber for a shower",
"into a tub of Jello",
"into a trap full of Devils Snare",
"down the stairs",
"into Uranus",
"into an enthralling and extended conversation about berries",
"directly into Mordor",
"into a giant mousetrap",
"into a room full of exploding balloons",
"into a giant blender",
"into a giant microwave",
]
2025-02-13 14:51:35 -05:00
self.DRUGS_CHANID = DRUGS_CHANID
global BOT_CHANIDS
BOT_CHANIDS = self.bot.BOT_CHANIDS
2025-04-17 14:35:56 -04:00
def is_spamchan() -> bool: # type: ignore
2025-02-13 14:51:35 -05:00
"""Check if channel is spamchan"""
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
def predicate(ctx):
try:
if not ctx.channel.id in BOT_CHANIDS:
logging.debug("%s not found in %s", ctx.channel.id, BOT_CHANIDS)
return ctx.channel.id in BOT_CHANIDS
except:
traceback.print_exc()
return False
2025-04-17 14:35:56 -04:00
return commands.check(predicate) # type: ignore
def is_spamchan_or_drugs() -> bool: # type: ignore
2025-02-13 14:51:35 -05:00
"""Check if channel is spamchan or drugs chan"""
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
def predicate(ctx):
try:
2025-04-17 14:35:56 -04:00
if (
not ctx.channel.id in BOT_CHANIDS
and not ctx.channel.id == DRUGS_CHANID
):
logging.debug(
"%s not found in %s and it isnt %s",
ctx.channel.id,
BOT_CHANIDS,
DRUGS_CHANID,
)
2025-02-13 14:51:35 -05:00
return ctx.channel.id in BOT_CHANIDS or ctx.channel.id == DRUGS_CHANID
except:
traceback.print_exc()
return False
2025-04-17 14:35:56 -04:00
return commands.check(predicate) # type: ignore
async def get_random_guild_member(
self, online_only: Optional[bool] = False
) -> Optional[str]:
2025-02-13 14:51:35 -05:00
"""
Get Random Guild Member
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
Args:
online_only (Optional[bool])
Returns:
str
"""
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(1145182936002482196)
if not guild:
return None
2025-02-13 14:51:35 -05:00
if not online_only:
2025-04-17 14:35:56 -04:00
guild_members = [
str(member.display_name) for member in guild.members if not member.bot
]
2025-02-13 14:51:35 -05:00
else:
2025-04-17 14:35:56 -04:00
guild_members = [
str(member.display_name)
for member in guild.members
if not member.bot
and member.status in [discord.Status.online, discord.Status.idle]
]
2025-02-13 14:51:35 -05:00
return random.choice(guild_members)
@bridge.bridge_command()
async def stats(self, ctx) -> None:
"""
Get Stats
"""
try:
2025-02-15 13:57:47 -05:00
stats_embed: Optional[discord.Embed] = await self.util.get_stats_embed()
if not stats_embed:
return
2025-02-13 14:51:35 -05:00
return await ctx.respond(embed=stats_embed)
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Error: {str(e)}")
2025-04-17 14:35:56 -04:00
@bridge.bridge_command() # type: ignore
@is_spamchan_or_drugs()
2025-02-13 14:51:35 -05:00
async def listcoffees(self, ctx) -> None:
"""
List Available Coffees
"""
coffees: str = ""
try:
for coffee in self.util.COFFEES:
coffees += f"**- {coffee}**\n"
2025-04-17 14:35:56 -04:00
embed: discord.Embed = discord.Embed(
title="Available Coffees", description=coffees.strip()
)
2025-02-13 14:51:35 -05:00
return await ctx.respond(embed=embed)
except Exception as e:
2025-04-17 14:35:56 -04:00
traceback.print_exc()
2025-02-13 14:51:35 -05:00
return await ctx.respond(f"Error: {str(e)}")
2025-04-17 14:35:56 -04:00
@bridge.bridge_command() # type: ignore
@is_spamchan_or_drugs()
2025-02-13 14:51:35 -05:00
async def listshoves(self, ctx) -> None:
"""
List Available Fates for shove command
"""
fates: str = ""
try:
for fate in self.FATES:
fates += f"**- {fate}**\n"
2025-04-17 14:35:56 -04:00
embed: discord.Embed = discord.Embed(
title="Available Fates (for .shove)", description=fates.strip()
)
2025-02-13 14:51:35 -05:00
return await ctx.respond(embed=embed)
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Error: {str(e)}")
@bridge.bridge_command()
async def xmas(self, ctx) -> None:
"""
Countdown til xmas!
"""
try:
emojis: dict = {
2025-04-17 14:35:56 -04:00
"0": "0",
"1": "1",
"2": "2",
"3": "3",
"4": "4",
"5": "5",
"6": "6",
"7": "7",
"8": "8",
"9": "9",
2025-02-13 14:51:35 -05:00
}
with ctx.channel.typing():
2025-02-15 13:57:47 -05:00
countdown = self.util.get_days_to_xmas()
if not isinstance(countdown, tuple) or len(countdown) < 6:
2025-04-17 14:35:56 -04:00
return await ctx.respond(
"Oops, Christmas is cancelled."
) # Invalid countdown from util
2025-02-15 13:57:47 -05:00
(days, hours, minutes, seconds, ms, _) = countdown
2025-02-13 14:51:35 -05:00
now: datetime.datetime = datetime.datetime.now()
if now.month == 12 and now.day == 25:
2025-04-17 14:35:56 -04:00
return await ctx.respond(
"# IT IS CHRISTMAS!!!!!!!!\n-# keep the change, you filthy animal"
)
2025-02-13 14:51:35 -05:00
if days > 200 or days < 0:
return await ctx.respond("We ain't fuckin talkin bout that yet")
xmas_trans: dict = str.maketrans(emojis)
try:
await ctx.message.add_reaction(emoji="🎄")
except Exception as e:
2025-04-17 14:35:56 -04:00
logging.debug("Failed to add xmas reaction: %s", str(e))
await ctx.respond(
f"Only {days} days, {hours} hours, {minutes} minutes,\
{seconds} seconds and {ms} ms left! (UTC)".translate(
xmas_trans
)
)
2025-02-13 14:51:35 -05:00
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Error: {str(e)}")
@bridge.bridge_command()
async def randfact(self, ctx) -> None:
"""
Get a random (useless) fact!
"""
try:
with ctx.channel.typing():
fact: str = await self.util.get_random_fact()
return await ctx.respond(discord.utils.escape_markdown(fact.strip()))
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Error: {str(e)}")
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def insult(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Insult Someone (or yourself)
"""
try:
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-13 14:51:35 -05:00
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-13 14:51:35 -05:00
else:
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
2025-04-17 14:35:56 -04:00
return
2025-02-15 13:57:47 -05:00
recipient = recipient_member.display_name
2025-02-13 14:51:35 -05:00
else:
2025-04-17 14:35:56 -04:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
with ctx.channel.typing():
insult: str = await self.util.get_insult(recipient)
if insult:
return await ctx.respond(insult)
return await ctx.respond("Insult failed :(")
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Insult failed :(\nError: {str(e)}")
2025-04-17 14:35:56 -04:00
2025-02-14 07:10:09 -05:00
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def compliment(
self, ctx, *, recipient: Optional[str] = None, language: Optional[str] = "en"
) -> None:
2025-02-14 07:10:09 -05:00
"""
Compliment someone (or yourself)
"""
try:
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-14 07:10:09 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-14 07:10:09 -05:00
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-14 07:10:09 -05:00
else:
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
2025-02-14 07:10:09 -05:00
else:
2025-04-17 14:35:56 -04:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-14 07:10:09 -05:00
with ctx.channel.typing():
2025-03-24 15:14:38 -04:00
compliment: str = await self.util.get_compliment(recipient, language)
2025-02-14 07:10:09 -05:00
if compliment:
return await ctx.respond(compliment)
return await ctx.respond("Compliment failed :(")
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Compliment failed :(\nError: {str(e)}")
2025-02-13 14:51:35 -05:00
2025-04-17 14:35:56 -04:00
@bridge.bridge_command(aliases=["whiskey"])
async def whisky(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Get a whisky for yourself or a friend!
"""
try:
if not recipient:
2025-02-15 13:57:47 -05:00
recipient = ctx.author.display_name
2025-02-13 14:51:35 -05:00
else:
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-04-17 14:35:56 -04:00
2025-02-15 13:57:47 -05:00
whisky: Optional[tuple] = await self.util.get_whisky()
if not whisky:
raise MiscException("Failed to get whisky from db")
(choice_name, choice_category, choice_description) = whisky
2025-04-17 14:35:56 -04:00
embed: discord.Embed = discord.Embed(
title=f"Whisky for {recipient}: {choice_name}",
description=choice_description.strip(),
)
2025-02-13 14:51:35 -05:00
embed.add_field(name="Category", value=choice_category, inline=True)
embed.set_footer(text=f"Cheers, {recipient}!")
2025-04-17 14:35:56 -04:00
await self.util.increment_counter("whiskeys")
2025-02-13 14:51:35 -05:00
return await ctx.respond(embed=embed)
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Error: {str(e)}")
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def drink(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Get a cocktail for yourself or a friend!
"""
try:
if not recipient:
2025-02-15 13:57:47 -05:00
recipient = ctx.author.display_name
2025-02-13 14:51:35 -05:00
else:
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-04-17 14:35:56 -04:00
2025-02-15 13:57:47 -05:00
if not recipient:
return
drink: Optional[tuple] = await self.util.get_drink()
if not drink:
raise MiscException("Failed to get drink from db.")
(choice_name, choice_ingredients) = drink
2025-04-17 14:35:56 -04:00
await ctx.respond(
f"*is mixing up **{choice_name}** for {recipient.strip()}*"
)
embed: discord.Embed = discord.Embed(
title=f"Cocktail for {recipient}", description=choice_name
)
embed.add_field(
name="Ingredients",
value=discord.utils.escape_markdown(choice_ingredients),
inline=True,
)
2025-02-13 14:51:35 -05:00
embed.set_footer(text=f"Cheers, {recipient}!")
2025-04-17 14:35:56 -04:00
await self.util.increment_counter("mixed_drinks")
return await ctx.respond(embed=embed)
2025-02-13 14:51:35 -05:00
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def spray(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Spray someone with water!
"""
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-13 14:51:35 -05:00
recipient_normal: str = ctx.author.mention
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
await ctx.respond(f"*sprays **{recipient_normal}** with water*")
2025-04-17 14:35:56 -04:00
await self.util.increment_counter("water_sprays")
2025-02-13 14:51:35 -05:00
except Exception as e:
traceback.print_exc()
2025-04-17 14:35:56 -04:00
return await ctx.respond(f"Failed: {str(e)}")
2025-02-13 14:51:35 -05:00
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def barfbag(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Pass someone (or yourself) a barf bag!
"""
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
recipient_normal = ctx.author.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
2025-04-17 14:35:56 -04:00
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
await ctx.respond(f"*passes **{recipient_normal}** a barf bag*")
2025-04-17 14:35:56 -04:00
await self.util.increment_counter("barf_bags")
2025-02-13 14:51:35 -05:00
except Exception as e:
traceback.print_exc()
2025-04-17 14:35:56 -04:00
return await ctx.respond(f"Failed: {str(e)}")
2025-02-13 14:51:35 -05:00
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def tea(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Tea!
"""
tea: str = "a cup of tea"
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-13 14:51:35 -05:00
recipient_normal: str = ctx.author.mention
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
if recipient == "rhodes":
2025-02-15 13:57:47 -05:00
tea = "a cup of Harney & Sons Hot Cinnamon Spice Tea"
2025-04-17 14:35:56 -04:00
elif ctx.author.id == 992437729927376996 or recipient.lower() in [
"kriegerin",
"traurigkeit",
"krieg",
"kriegs",
"cyberkrieg",
"ck",
]:
2025-02-15 13:57:47 -05:00
tea = "a cup of earl grey, light and sweet"
2025-02-13 14:51:35 -05:00
response = await ctx.respond(f"*hands **{recipient_normal}** {tea}*")
2025-04-17 14:35:56 -04:00
await self.util.increment_counter("teas")
2025-02-13 14:51:35 -05:00
try:
return await response.add_reaction(emoji="🫖")
except Exception as e:
2025-04-17 14:35:56 -04:00
logging.debug("Failed to add tea reaction: %s", str(e))
2025-02-13 14:51:35 -05:00
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
@bridge.bridge_command() # type: ignore
@is_spamchan_or_drugs()
async def cowsay(self, ctx, *, message: str) -> None:
2025-02-13 14:51:35 -05:00
"""
Cowsay!
2025-04-17 14:35:56 -04:00
"""
2025-02-13 14:51:35 -05:00
try:
cowfile: str = random.choice(self.COWS).replace(".cow", "")
2025-04-17 14:35:56 -04:00
cow_said: str = cow_say(f"-f{cowfile}", message)
2025-02-13 14:51:35 -05:00
response: str = f"```{cow_said}```\n-# Chosen cow: {cowfile}"
return await ctx.respond(response)
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
@bridge.bridge_command() # type: ignore
2025-02-15 13:57:47 -05:00
@is_spamchan_or_drugs()
2025-04-17 14:35:56 -04:00
async def fortune(self, ctx, cowfile: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Fortune | Cowsay!
"""
try:
if not cowfile:
2025-02-15 13:57:47 -05:00
cowfile = random.choice(self.COWS).replace(".cow", "")
2025-02-13 14:51:35 -05:00
2025-04-17 14:35:56 -04:00
if not f"{cowfile}.cow" in self.COWS:
2025-02-13 14:51:35 -05:00
return await ctx.respond(f"Unknown cow {cowfile}, who dat?")
2025-04-17 14:35:56 -04:00
fortune_said: str = str(fortune("-n1000", "-s"))
cow_said: str = cow_say(f"-f{cowfile}", fortune_said)
2025-02-13 14:51:35 -05:00
response: str = f"```{cow_said}```\n-# Chosen cow: {cowfile}"
return await ctx.respond(response)
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
@bridge.bridge_command() # type: ignore
@is_spamchan_or_drugs()
2025-02-13 14:51:35 -05:00
async def listcows(self, ctx) -> None:
"""
List available .cow files (for cowsay)
"""
cow_list: str = ""
try:
for cow in self.COWS:
2025-02-15 13:57:47 -05:00
cow = cow.replace(".cow", "")
2025-02-13 14:51:35 -05:00
cow_list += f"- **{cow}**\n"
2025-04-17 14:35:56 -04:00
embed: discord.Embed = discord.Embed(
title="List of .cows", description=cow_list.strip()
)
2025-02-13 14:51:35 -05:00
return await ctx.respond(embed=embed)
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def cyanide(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Cyanide!
"""
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-13 14:51:35 -05:00
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-13 14:51:35 -05:00
recipient_normal: str = ctx.author.mention
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
2025-04-17 14:35:56 -04:00
response = await ctx.respond(
f"*doses **{recipient_normal}** with Zyklon-B*"
)
await self.util.increment_counter("cyanides")
2025-02-13 14:51:35 -05:00
try:
await response.add_reaction(emoji="☠️")
return await response.add_reaction(emoji="🇩🇪")
except Exception as e:
2025-04-17 14:35:56 -04:00
logging.debug("Failed to add cynaide reaction: %s", str(e))
2025-02-15 13:57:47 -05:00
except Exception as e:
2025-02-13 14:51:35 -05:00
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def gravy(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
School gravy! (It's deadly)
"""
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-13 14:51:35 -05:00
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-13 14:51:35 -05:00
recipient_normal: str = ctx.author.mention
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
2025-04-17 14:35:56 -04:00
response = await ctx.respond(
f"*doses **{recipient_normal}** with school gravy*"
)
await self.util.increment_counter("gravies")
2025-02-13 14:51:35 -05:00
try:
await response.add_reaction(emoji="☠️")
return await response.add_reaction(emoji="🏫")
except Exception as e:
2025-04-17 14:35:56 -04:00
logging.debug("Failed to add gravy reaction: %s", str(e))
2025-02-13 14:51:35 -05:00
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def water(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Cold water! Drink up.
"""
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-13 14:51:35 -05:00
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-13 14:51:35 -05:00
recipient_normal: str = ctx.author.mention
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
2025-04-17 14:35:56 -04:00
response = await ctx.respond(
f"*hands **{recipient_normal}** a cold glass of water*"
)
await self.util.increment_counter("waters")
2025-02-13 14:51:35 -05:00
try:
return await response.add_reaction(emoji="💧")
except Exception as e:
2025-04-17 14:35:56 -04:00
logging.debug("Failed to add water reaction: %s", str(e))
2025-02-13 14:51:35 -05:00
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
@bridge.bridge_command(aliases=["bully"])
async def shove(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Shove someone! (Or yourself)
"""
chosen_fate: str = random.choice(self.FATES)
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-13 14:51:35 -05:00
recipient_normal: str = ctx.author.mention
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
await ctx.respond(f"*shoves **{recipient_normal}** {chosen_fate}*")
await self.util.increment_counter("shoves")
except Exception as e:
traceback.print_exc()
2025-04-17 14:35:56 -04:00
return await ctx.respond(f"Failed: {str(e)}")
2025-02-13 14:51:35 -05:00
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def coffee(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Coffee!
"""
2025-04-17 14:35:56 -04:00
2025-02-24 06:21:56 -05:00
recipient_allergic: bool = False
2025-02-26 20:48:05 -05:00
recipient_id: Optional[int] = None # Used for mentions
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-13 14:51:35 -05:00
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-13 14:51:35 -05:00
recipient_normal: str = ctx.author.mention
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id = discord.utils.raw_mentions(recipient)[0] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
2025-04-17 14:35:56 -04:00
if (
"pudding" in recipient
or recipient_id
and recipient_id in [898332028007751741]
):
2025-02-24 06:21:56 -05:00
recipient_allergic = True
chosen_coffee: Optional[str] = self.util.get_coffee(recipient_allergic)
2025-02-15 13:57:47 -05:00
if not chosen_coffee:
return
2025-04-17 14:35:56 -04:00
response = await ctx.respond(
f"*hands **{recipient_normal}** {chosen_coffee}*"
)
2025-02-13 14:51:35 -05:00
await self.util.increment_counter("coffees")
try:
return await response.add_reaction(emoji="")
except Exception as e:
2025-04-17 14:35:56 -04:00
logging.debug("Failed to add coffee reaction: %s", str(e))
2025-02-13 14:51:35 -05:00
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
@bridge.bridge_command(aliases=["cookies"])
async def cookie(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Cookies!
"""
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-13 14:51:35 -05:00
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-13 14:51:35 -05:00
else:
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
2025-02-13 14:51:35 -05:00
else:
2025-04-17 14:35:56 -04:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
2025-02-15 13:57:47 -05:00
chosen_cookie: Optional[dict] = await self.util.get_cookie()
if not chosen_cookie:
raise MiscException("Failed to get cookie from db.")
2025-04-17 14:35:56 -04:00
embed: discord.Embed = discord.Embed(
title=f"Cookie for {recipient}",
description=f"Have a {chosen_cookie.get('name')}",
colour=discord.Colour.orange(),
image=chosen_cookie.get("image_url"),
)
embed.add_field(name="Origin", value=chosen_cookie.get("origin", "N/A"))
2025-02-13 14:51:35 -05:00
await ctx.respond(embed=embed)
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
@bridge.bridge_command(aliases=["hashbrowns", "potato"])
async def hashbrown(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Hashbrowns!
"""
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-13 14:51:35 -05:00
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-13 14:51:35 -05:00
recipient_normal: str = ctx.author.mention
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
await ctx.respond(f"*hands **{recipient_normal}** 2 warm hashbrowns*")
await self.util.increment_counter("hashbrowns")
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def ritalini(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Ritalini!
"""
2025-04-17 14:35:56 -04:00
authorDisplay = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-13 14:51:35 -05:00
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-13 14:51:35 -05:00
recipient_normal: str = ctx.author.mention
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
2025-04-17 14:35:56 -04:00
response = await ctx.respond(
f"*serves **{recipient_normal}** a plate of ritalini* 😉"
)
2025-02-13 14:51:35 -05:00
await response.add_reaction(emoji="💊")
await response.add_reaction(emoji="🍝")
await self.util.increment_counter("ritalinis")
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
@bridge.bridge_command(aliases=["gc"])
async def grilledcheese(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Grilled Cheese!
"""
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-13 14:51:35 -05:00
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-13 14:51:35 -05:00
recipient_normal: str = ctx.author.mention
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
await ctx.respond(f"*hands **{recipient_normal}** a grilled cheese*")
await self.util.increment_counter("grilled_cheeses")
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def soup(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Soup!
"""
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-13 14:51:35 -05:00
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-13 14:51:35 -05:00
recipient_normal: str = ctx.author.mention
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
await ctx.respond(f"*hands **{recipient_normal}** a hot bowl of soup*")
await self.util.increment_counter("soups")
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def muffin(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Muffins!
"""
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-13 14:51:35 -05:00
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-13 14:51:35 -05:00
recipient_normal: str = ctx.author.mention
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
recipient = discord.utils.escape_mentions(recipient.strip())
try:
response = await ctx.respond(f"*hands **{recipient_normal}** a muffin*")
try:
await response.add_reaction(emoji="<:muffin:1314233635586707456>")
except Exception as e:
2025-04-17 14:35:56 -04:00
logging.debug(
"Failed to add muffin reaction: %s", str(e)
) # known: cannot react to interaction
2025-02-13 14:51:35 -05:00
await self.util.increment_counter("muffins")
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def bacon(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Bacon!
"""
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-13 14:51:35 -05:00
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-13 14:51:35 -05:00
recipient_normal: str = ctx.author.mention
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
2025-04-17 14:35:56 -04:00
response = await ctx.respond(
f"*hands **{recipient_normal}** a side of bacon*"
)
try:
await response.add_reaction(emoji="🥓")
except Exception as e:
2025-04-17 14:35:56 -04:00
logging.debug(
"Failed to add bacon reaction: %s", str(e)
) # known: cannot react to interactions
2025-02-13 14:51:35 -05:00
await self.util.increment_counter("bacon_sides")
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def hang(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Hang someone!
"""
2025-04-17 14:35:56 -04:00
authorDisplay = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-13 14:51:35 -05:00
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-02-13 14:51:35 -05:00
recipient_normal: str = ctx.author.mention
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
2025-04-17 14:35:56 -04:00
response = await ctx.respond(
f"*sends **{recipient_normal}** to the Gallows to be hanged asynchronely*"
)
2025-02-13 14:51:35 -05:00
await self.util.increment_counter("hangings")
try:
return await response.add_reaction(emoji="☠️")
except Exception as e:
2025-04-17 14:35:56 -04:00
logging.debug("Failed to add hang reaction: %s", str(e))
2025-02-13 14:51:35 -05:00
except Exception as e:
await ctx.respond(f"Failed: {str(e)}")
traceback.print_exc()
2025-04-17 14:35:56 -04:00
return
2025-02-13 14:51:35 -05:00
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def touch(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Touch someone!
"""
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-02-13 14:51:35 -05:00
no_self_touch: str = ", don't fucking touch yourself here. You disgust me."
2025-02-15 13:57:47 -05:00
if not recipient:
2025-02-13 14:51:35 -05:00
recipient_normal: str = ctx.author.mention
await ctx.respond(f"{recipient_normal}{no_self_touch}")
try:
await ctx.message.add_reaction(emoji="🤮")
except Exception as e:
2025-04-17 14:35:56 -04:00
logging.debug(
"Failed to add puke reactin for touch command: %s", str(e)
)
2025-02-15 13:57:47 -05:00
await self.util.increment_counter("touch_denials")
2025-03-20 20:49:23 -04:00
return
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
2025-04-17 14:35:56 -04:00
response = await ctx.respond(
f"*touches **{recipient_normal}** for **{ctx.author.mention}** because they wouldn't touch them with a shitty stick!*"
)
2025-02-13 14:51:35 -05:00
await self.util.increment_counter("touches")
try:
return await response.add_reaction(emoji="👉")
except Exception as e:
2025-04-17 14:35:56 -04:00
logging.debug("Failed to add touch reaction: %s", str(e))
2025-02-13 14:51:35 -05:00
except Exception as e:
traceback.print_exc()
2025-04-17 14:35:56 -04:00
return await ctx.respond(f"Failed: {str(e)}")
@bridge.bridge_command() # type: ignore
2025-02-15 13:57:47 -05:00
@is_spamchan_or_drugs()
2025-02-13 14:51:35 -05:00
async def qajoke(self, ctx) -> None:
"""
Get a joke in Q/A Form!
"""
try:
2025-02-15 13:57:47 -05:00
qajoke: Optional[tuple] = await self.util.get_qajoke()
2025-04-17 14:35:56 -04:00
if not qajoke:
2025-02-15 13:57:47 -05:00
return
(question, answer) = qajoke
2025-02-13 14:51:35 -05:00
escaped_question = discord.utils.escape_markdown(question)
escasped_answer = discord.utils.escape_markdown(answer)
2025-04-17 14:35:56 -04:00
embed: discord.Embed = discord.Embed(
title=escaped_question, description=escasped_answer
)
2025-02-13 14:51:35 -05:00
return await ctx.respond(embed=embed)
except Exception as e:
await ctx.respond(f"Error: {str(e)}")
2025-04-17 14:35:56 -04:00
@bridge.bridge_command() # type: ignore
@is_spamchan_or_drugs()
2025-02-13 14:51:35 -05:00
async def rjoke(self, ctx) -> None:
"""
Get a joke! (from r/jokes scrape)
"""
try:
2025-02-15 13:57:47 -05:00
rjoke: Optional[tuple] = await self.util.get_rjoke()
if not rjoke:
raise MiscException("Failed to get rjoke from db.")
(title, body, score) = rjoke
2025-02-13 14:51:35 -05:00
escaped_title = discord.utils.escape_markdown(title)
escaped_body = discord.utils.escape_markdown(body)
2025-04-17 14:35:56 -04:00
embed: discord.Embed = discord.Embed(
title=escaped_title, description=escaped_body
)
2025-02-13 14:51:35 -05:00
embed.add_field(name="Score", value=score)
return await ctx.respond(embed=embed)
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Error: {str(e)}")
2025-04-17 14:35:56 -04:00
@bridge.bridge_command() # type: ignore
@is_spamchan_or_drugs()
async def joint(self, ctx, *, recipient: Optional[str] = None) -> None:
2025-02-13 14:51:35 -05:00
"""
Joints!
"""
2025-04-17 14:35:56 -04:00
authorDisplay: str = (
ctx.author.display_name
if not (ctx.author.display_name is None)
2025-02-13 14:51:35 -05:00
else ctx.message.author.display_name
2025-04-17 14:35:56 -04:00
)
2025-02-13 14:51:35 -05:00
2025-02-15 13:57:47 -05:00
if not recipient:
recipient = authorDisplay.strip()
2025-03-21 16:12:44 -04:00
recipient_normal: str = ctx.author.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient_normal = recipient
2025-02-13 14:51:35 -05:00
if discord.utils.raw_mentions(recipient):
# There are mentions
2025-04-17 14:35:56 -04:00
recipient_id: int = discord.utils.raw_mentions(recipient)[
0
] # First mention
2025-02-15 13:57:47 -05:00
guild: Optional[discord.Guild] = self.bot.get_guild(ctx.guild.id)
if not guild:
return
2025-04-17 14:35:56 -04:00
recipient_member: Optional[discord.Member] = guild.get_member(
recipient_id
)
2025-02-15 13:57:47 -05:00
if not recipient_member:
return
recipient = recipient_member.display_name
recipient_normal = recipient_member.mention
2025-02-13 14:51:35 -05:00
else:
2025-02-15 13:57:47 -05:00
recipient = discord.utils.escape_mentions(recipient.strip())
2025-02-13 14:51:35 -05:00
try:
2025-02-15 13:57:47 -05:00
strain: Optional[tuple] = await self.util.get_strain()
if not strain:
raise MiscException("Failed to get strain from db.")
(choice_strain, choice_desc) = strain
2025-02-13 14:51:35 -05:00
escaped_description = discord.utils.escape_markdown(choice_desc.strip())
2025-04-17 14:35:56 -04:00
await ctx.respond(
f"*hands **{recipient_normal}** a joint rolled up with some **{choice_strain}***"
)
embed: discord.Embed = discord.Embed(
title=choice_strain, description=f"*{escaped_description}*"
)
2025-02-13 14:51:35 -05:00
await self.util.increment_counter("joints")
2025-03-21 16:12:44 -04:00
return await ctx.respond(embed=embed)
2025-02-13 14:51:35 -05:00
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
@bridge.bridge_command()
async def isitfriday(self, ctx) -> None:
"""
IS IT FRIDAY!?
"""
try:
2025-04-17 14:35:56 -04:00
today: datetime.datetime = datetime.datetime.today()
2025-02-13 14:51:35 -05:00
today_weekday: int = today.weekday()
if int(today_weekday) == 4:
return await ctx.respond("# FUCK YEAH IT'S FRIDAY!")
else:
return await ctx.respond("# IT AINT FUCKIN FRIDAY! GOD DAMN IT!")
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
@bridge.bridge_command(aliases=["flyday"])
2025-02-13 14:51:35 -05:00
async def isitflyday(self, ctx) -> None:
"""
IS IT FLYDAY!?
"""
try:
today: datetime.datetime = datetime.datetime.today()
today_weekday: int = today.weekday()
pony_uid: int = 1090545395110785085
if ctx.author.id == pony_uid:
return await ctx.respond("# FUCK YEAH, IT'S ALWAYS FLYDAY FOR U BBY")
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
if int(today_weekday) == 1:
return await ctx.respond("# FUCK YEAH IT'S FLYDAY!")
else:
2025-04-17 14:35:56 -04:00
return await ctx.respond(
"# IT AINT FUCKIN FLYDAY! GOD DAMN IT!\n-# Pony may turn into a fly anyway, never any guarantees"
)
2025-02-13 14:51:35 -05:00
except Exception as e:
traceback.print_exc()
return await ctx.respond(f"Failed: {str(e)}")
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
@bridge.bridge_command()
2025-04-17 14:35:56 -04:00
async def ud(self, ctx, *, term: str) -> None:
2025-02-13 14:51:35 -05:00
"""
Not sure what that term means? UD prolly knows.
"""
try:
with ctx.channel.typing():
(ud_word, ud_def) = await self.util.get_ud_def(term=term)
term_encoded: str = urllib.parse.quote(ud_word, encoding="utf-8")
ud_link = f"https://urbandictionary.com/define.php?term={term_encoded}"
2025-04-17 14:35:56 -04:00
embed: discord.Embed = discord.Embed(
title=ud_word.strip(), description=f"{ud_def.strip()}\n{ud_link}"
)
2025-02-13 14:51:35 -05:00
return await ctx.respond(embed=embed)
2025-04-17 14:35:56 -04:00
except Exception as e:
2025-02-13 14:51:35 -05:00
traceback.print_exc()
return await ctx.respond(f"Error: {str(e)}")
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
""" User Commands """
2025-04-17 14:35:56 -04:00
@commands.user_command(name="Give Joint") # type: ignore
2025-02-15 13:57:47 -05:00
@is_spamchan()
2025-02-13 14:51:35 -05:00
async def joint_context_menu(self, ctx, member: discord.Member) -> None:
"""
Joint Context Menu
"""
2025-02-15 13:57:47 -05:00
strain: Optional[tuple] = await self.util.get_strain()
if not strain:
raise MiscException("Failed to get strain from db.")
(choice_strain, choice_desc) = strain
2025-02-13 14:51:35 -05:00
escaped_desc = discord.utils.escape_markdown(choice_desc.strip())
2025-04-17 14:35:56 -04:00
await ctx.interaction.respond(
f"*hands **<@{member.id}>** a joint rolled up with some **{choice_strain}***"
)
embed: discord.Embed = discord.Embed(
title=choice_strain, description=f"*{escaped_desc}*"
)
2025-02-13 14:51:35 -05:00
await self.util.increment_counter("joints")
return await ctx.send(embed=embed)
2025-04-17 14:35:56 -04:00
2025-02-13 14:51:35 -05:00
@commands.user_command(name="Give Coffee")
async def coffee_context_menu(self, ctx, member: discord.Member) -> None:
"""
2025-04-17 14:35:56 -04:00
Coffee Context Menu
2025-02-13 14:51:35 -05:00
"""
2025-02-24 06:21:56 -05:00
recipient_allergic: bool = False
if member.id in [898332028007751741]:
recipient_allergic = True
chosen_coffee = self.util.get_coffee(recipient_allergic)
2025-04-17 14:35:56 -04:00
response = await ctx.interaction.respond(
f"*hands <@{member.id}> {chosen_coffee}*"
)
2025-02-13 14:51:35 -05:00
await self.util.increment_counter("coffees")
try:
await response.add_reaction(emoji="")
except Exception as e:
2025-04-17 14:35:56 -04:00
logging.debug(
"Failed to add coffee reaction: %s", str(e)
) # known: cannot react to interaction
2025-02-13 14:51:35 -05:00
def cog_unload(self) -> None:
"""Run on Cog Unload"""
2025-02-15 13:57:47 -05:00
pass
2025-02-13 14:51:35 -05:00
2025-04-17 14:35:56 -04:00
def setup(bot) -> None:
2025-02-13 14:51:35 -05:00
"""Run on Cog Load"""
2025-04-17 14:35:56 -04:00
bot.add_cog(Misc(bot))