diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/teawie_bot/bot.py | 16 | ||||
| -rw-r--r-- | src/teawie_bot/utils.py | 33 |
2 files changed, 24 insertions, 25 deletions
diff --git a/src/teawie_bot/bot.py b/src/teawie_bot/bot.py index cb90804..415c931 100644 --- a/src/teawie_bot/bot.py +++ b/src/teawie_bot/bot.py @@ -2,8 +2,8 @@ import discord from discord import app_commands from discord.ext import commands -from teawie_bot.apis import guzzle from teawie_bot import utils +from teawie_bot.apis import guzzle SERVER_ID = discord.Object(id=1055663552679137310) intents = discord.Intents.default() @@ -17,6 +17,7 @@ bot = commands.Bot(command_prefix="m!", async def on_ready(): print(f"logged in as {bot.user}") await bot.tree.sync(guild=SERVER_ID) + bot.teawies = utils.Teawies(bot) print("ready!") @@ -28,7 +29,7 @@ async def on_message(message: discord.Message): echo_messages = [ "🗿", ] - echo_messages = echo_messages + utils.Teawies(bot).emojis + echo_messages = echo_messages + bot.teawies.emojis try: index = echo_messages.index(message.content.lower()) await message.channel.send(echo_messages[index]) @@ -40,7 +41,7 @@ async def on_message(message: discord.Message): @bot.command() async def ask(ctx: commands.Context): - await ctx.send(utils.get_random_response(bot, utils.Teawies(bot))) + await ctx.send(utils.get_random_response(bot)) @bot.tree.command( @@ -48,19 +49,16 @@ async def ask(ctx: commands.Context): description="ask lord teawie a question and they shall respond", guild=SERVER_ID) async def ask_slash_command(interaction: discord.Interaction): - msg = utils.get_random_response(bot, utils.Teawies(bot)) - while not msg: - msg = utils.get_random_response(bot, utils.Teawies(bot)) + msg = utils.get_random_response(bot) await interaction.response.send_message(msg) @bot.command() async def teawiespam(ctx: commands.Context): - if not discord.utils.get(bot.emojis, name="teawiesmile"): - return + emoji = str(discord.utils.get(bot.emojis, name="teawiesmile")) msg = str() for _ in range(50): - msg += str(discord.utils.get(bot.emojis, name="teawiesmile")) + msg += emoji await ctx.send(msg) diff --git a/src/teawie_bot/utils.py b/src/teawie_bot/utils.py index 99f2a13..c75135b 100644 --- a/src/teawie_bot/utils.py +++ b/src/teawie_bot/utils.py @@ -2,52 +2,53 @@ import importlib.resources import random from math import ceil -from discord.ext import commands import discord +from discord.ext import commands from teawie_bot import copypastas CHAR_LIMIT: int = 2000 +# pylint: disable-next=too-few-public-methods class Teawies: """ - wrapper class around list[discord.Emoji] - """ + wrapper class around list[discord.Emoji] + """ def __init__(self, bot: commands.Bot): names = [ "teawiecry", "teawiederp", "teawiedizzy", "teawienerdcroppedanddownsized", "teawieneutral", "teawiepet", "teawiepetfast", "teawiepop", "teawiesmile", "teawiesmug", - "teawiestarstruck", "tei", "wavy", "wie", "wie~1", - "manythoughtsheadfull" + "teawiestarstruck", "tei", "wavy", "wie", "manythoughtsheadfull" ] - self.emojis: list[str] = [] - for name in names: - emoji = discord.utils.get(bot.emojis, name=name) - if emoji: - self.emojis.append(str(emoji)) + self.emojis: list[str] = [ + str(discord.utils.get(bot.emojis, name=name)) for name in names + ] def random(self) -> str: return random.choice(self.emojis) -def get_random_response(bot: commands.Bot, teawies: Teawies) -> str: +def get_random_response(bot: commands.Bot) -> str: responses = [ - "soon", "maybe", "perhaps", "elaborate", + "soon", + "maybe", + "perhaps", + "elaborate", str(discord.utils.get(bot.emojis, name="moyai")), ] - responses = responses + teawies.emojis + responses = responses + bot.teawies.emojis return random.choice(responses) def split_msg(msg: str) -> list[str]: """ - splits a message into multiple parts so that it - can fit into the discord character limit - """ + splits a message into multiple parts so that it + can fit into the discord character limit + """ split = ceil(len(msg) / ceil(len(msg) / CHAR_LIMIT)) return [msg[i:i + split] for i in range(0, len(msg), split)] |
