Ejemplo n.º 1
0
                    def retype_check(message: discord.Message) -> bool:

                        if (
                            message.author != ctx.author
                            or message.channel != ctx.channel
                        ):
                            return False

                        if message.content.lower() != sentence.lower():
                            nonlocal attempts_left
                            attempts_left -= 1

                            if message.content == uncopyable_sentence:
                                self.bot.loop.create_task(
                                    message.reply(
                                        f"Did you really think you could get away with copy-pasting? LMAO, you have **{attempts_left} attempts** left"
                                    )
                                )
                            else:
                                self.bot.loop.create_task(
                                    message.reply(
                                        f"That's not the correct answer lol. You have **{attempts_left} attempts** left"
                                    )
                                )
                            if not attempts_left:
                                raise asyncio.TimeoutError
                            return False

                        return True
Ejemplo n.º 2
0
async def combo(message: discord.Message):
    try:
        combo_emojis = combos[get_fields(message)[0]]
        message_to_combo: discord.Message = message.reference.resolved
        if message_to_combo is None:
            return
        for emoji in combo_emojis:
            await message_to_combo.add_reaction(emoji)
    except KeyError:
        message.reply(content='You must give a valid combo name!')
Ejemplo n.º 3
0
async def handleWaifuAddCSV(message : discord.Message, args):
    attachments = message.attachments
    if len(attachments) == 0:
        await handleError(message, args)
        return
    baseDir = os.path.dirname(__file__)
    csvPath = os.path.join(baseDir, f'waifu{message.guild.id}.csv')
    await attachments[0].save(csvPath)
    with open(csvPath, 'r') as f:
        for line in f.readlines():
            print(line)
            args = line.split(',')
            code = waifuAdd(message, args)
    message.reply(REPLY['waifuaddcsv'])
Ejemplo n.º 4
0
    async def sticker(self, message_context: discord.Message, params: str,
                      **kwargs) -> None:
        tag = params

        if tag == None:
            await message_context.reply(
                BotMessages.command_exceptions['UNKNOWN_SYNTAX'],
                mention_author=True)

        else:
            tag = tag.lower().strip()

            cached_sticker = await self.database.stickers_cache.find_sticker_url(
                tag)

            url = None

            if cached_sticker == None:
                result = await self.apis.get_sticker_from_tag(tag)

                result_handlers = {
                    BotAPIs.NOT_FOUND:
                    lambda: message_context.reply(BotMessages.
                                                  command_exceptions['FUN'][
                                                      'STICKER_NOT_FOUND'],
                                                  mention_author=True),
                    BotAPIs.RATE_LIMITED:
                    lambda: message_context.reply(BotMessages.
                                                  command_exceptions['FUN'][
                                                      'STICKER_RATE_LIMITED'],
                                                  mention_author=True)
                }

                if isinstance(result, int):
                    await result_handlers.get(result)()

                else:
                    url = result
                    await self.database.stickers_cache.add_sticker(tag, url)

            else:
                url = cached_sticker

            embed = discord.Embed()
            embed.set_image(url=url)
            await self.utils.messages.replace_message(message_context,
                                                      params,
                                                      embed=embed)
Ejemplo n.º 5
0
    async def weather(self, message_context: discord.Message, params: str,
                      **kwargs) -> None:
        if params == None:
            await message_context.reply(
                BotMessages.command_exceptions['UNKNOWN_SYNTAX'],
                mention_author=True)

        else:
            city = params.strip()
            result = await self.apis.get_weather(city)

            result_handlers = {
                BotAPIs.NOT_FOUND:
                lambda: message_context.reply(BotMessages.command_exceptions[
                    'FUN']['CITY_NOT_FOUND'],
                                              mention_author=True)
            }

            if isinstance(result, int):
                await result_handlers.get(result)()

            else:
                embed = discord.Embed(
                    title=result.get('city'),
                    description=BotMessages.command_responses['FUN']
                    ['WEATHER_RESPONSE'](result))
                embed.set_image(url=result.get('icon_url'))
                await self.utils.messages.replace_message(message_context,
                                                          '',
                                                          add_dash=False,
                                                          embed=embed)
Ejemplo n.º 6
0
    async def joke_random(self, message_context: discord.Message, params: str,
                          **kwargs) -> None:
        result = await self.apis.get_random_joke()

        result_handlers = {
            BotAPIs.NOT_FOUND:
            lambda: message_context.reply(BotMessages.command_exceptions['FUN']
                                          ['JOKE_NOT_FOUND'],
                                          mention_author=True)
        }

        result_handler = result_handlers.get(result)

        if result_handler == None:
            await self.utils.messages.replace_message(message_context, result)

        else:
            await result_handler()
Ejemplo n.º 7
0
                    def scramble_check(message: discord.Message) -> bool:

                        if (
                            message.author != ctx.author
                            or message.channel != ctx.channel
                        ):
                            return False

                        if message.content.lower() != unscrambled.lower():
                            nonlocal attempts_left
                            attempts_left -= 1
                            self.bot.loop.create_task(
                                message.reply(
                                    f"That's not the correct answer lol. You have **{attempts_left} attempts** left"
                                )
                            )
                            if not attempts_left:
                                raise asyncio.TimeoutError
                            return False

                        return True