Compare commits

...

2 Commits

Author SHA1 Message Date
f360566824
refactor: minor changes 2025-03-28 21:22:19 -04:00
b0c96a11cd
feat(fun): add more reactions 2025-03-28 21:22:19 -04:00
5 changed files with 20 additions and 10 deletions

View File

@ -14,13 +14,13 @@ async def lookup(message):
tokens = commands.tokenize(message.content) tokens = commands.tokenize(message.content)
parser = arguments.ArgumentParser( parser = arguments.ArgumentParser(
tokens[0], tokens[0],
"look up a user or application on discord by their ID", "look up a discord user or application by ID",
) )
parser.add_argument( parser.add_argument(
"-a", "-a",
"--application", "--application",
action="store_true", action="store_true",
help="search for applications instead of users", help="look up applications instead of users",
) )
parser.add_argument( parser.add_argument(
"id", "id",

View File

@ -24,6 +24,12 @@ SPONSORBLOCK_CATEGORY_NAMES = {
"selfpromo": "self promotion", "selfpromo": "self promotion",
"sponsor": "sponsored", "sponsor": "sponsored",
} }
REACTIONS = {
"cat": ["🐈"],
"dog": ["🐕"],
"gn": ["💤", "😪", "😴", "🛌"],
"pizza": ["🍕"],
}
RELOADABLE_MODULES = [ RELOADABLE_MODULES = [
"arguments", "arguments",
"audio", "audio",

View File

@ -166,6 +166,7 @@ async def on_voice_state_update(_, before, after):
channel = before.channel channel = before.channel
elif is_empty(after.channel): elif is_empty(after.channel):
channel = after.channel channel = after.channel
if channel: if channel:
await channel.guild.voice_client.disconnect() await channel.guild.voice_client.disconnect()
@ -174,9 +175,9 @@ def rreload(reloaded_modules, module):
reloaded_modules.add(module.__name__) reloaded_modules.add(module.__name__)
for submodule in filter( for submodule in filter(
lambda v: inspect.ismodule(v) lambda sm: inspect.ismodule(sm)
and v.__name__ in RELOADABLE_MODULES and sm.__name__ in RELOADABLE_MODULES
and v.__name__ not in reloaded_modules, and sm.__name__ not in reloaded_modules,
vars(module).values(), vars(module).values(),
): ):
rreload(reloaded_modules, submodule) rreload(reloaded_modules, submodule)

11
fun.py
View File

@ -1,10 +1,13 @@
import random import random
import commands import commands
from constants import REACTIONS
async def on_message(message): async def on_message(message):
if random.random() < 0.01 and "gn" in commands.tokenize( if random.random() < 0.01:
message.content, remove_prefix=False tokens = commands.tokenize(message.content, remove_prefix=False)
): for keyword, options in REACTIONS.items():
await message.add_reaction(random.choice(["💤", "😪", "😴", "🛌"])) if keyword in tokens:
await message.add_reaction(random.choice(options))
break

View File

@ -19,7 +19,7 @@ async def cleanup():
targets.append(guild_id) targets.append(guild_id)
for target in targets: for target in targets:
del players[target] del players[target]
debug(f"cleanup removed {len(targets)} empty players") debug(f"cleanup thread removed {len(targets)} empty players")
if ( if (
not idle_tracker["is_idle"] not idle_tracker["is_idle"]