예제 #1
0
파일: fun.py 프로젝트: hiratanagis/Watora
    async def _add(self, ctx, command, *, content):
        """
            {command_prefix}cc add [command] [content]
            {command_prefix}cc add [command] >>>[my_command]

        {help}
        """
        command = command.lower()
        cmd = self.bot.get_command(command)
        if cmd:
            return await ctx.send(
                get_str(ctx, "cmd-customcommand-in-basic-command"))

        settings = await SettingsDB.get_instance().get_guild_settings(
            ctx.guild.id)

        if command not in settings.customcommands:
            content = format_mentions(content)
            settings.customcommands[command] = content
            await SettingsDB.get_instance().set_guild_settings(settings)
            await ctx.send(get_str(ctx, "cmd-customcommand-added"))
        else:
            await ctx.send(
                get_str(ctx, "cmd-customcommand-already-exists").format(
                    "`{}customcom edit`".format(
                        get_server_prefixes(ctx.bot, ctx.guild))))
예제 #2
0
파일: fun.py 프로젝트: hiratanagis/Watora
    async def _delete(self, ctx, command):
        """
            {command_prefix}cc delete [command]

        {help}
        """
        command = command.lower()

        settings = await SettingsDB.get_instance().get_guild_settings(
            ctx.guild.id)

        if not settings.customcommands:
            await ctx.send(
                get_str(ctx, "cmd-customcommand-raw-no-cc").format(
                    "`{}customcom add`".format(
                        get_server_prefixes(ctx.bot, ctx.guild))))

        elif command in settings.customcommands:
            settings.customcommands.pop(command, None)
            await SettingsDB.get_instance().set_guild_settings(settings)
            await ctx.send(get_str(ctx, "cmd-customcommand-deleted"))
        else:
            await ctx.send(
                get_str(ctx, "cmd-customcommand-failed-edit").format(
                    "`{}customcom add`".format(
                        get_server_prefixes(ctx.bot, ctx.guild))))
예제 #3
0
파일: fun.py 프로젝트: hiratanagis/Watora
    async def _edit(self, ctx, command, *, new_content):
        """
            {command_prefix}cc edit [command] [new_content]

        {help}
        """
        command = command.lower()

        settings = await SettingsDB.get_instance().get_guild_settings(
            ctx.guild.id)

        if not settings.customcommands:
            await ctx.send(
                get_str(ctx, "cmd-customcommand-raw-no-cc").format(
                    "`{}customcom add`".format(
                        get_server_prefixes(ctx.bot, ctx.guild))))

        elif command in settings.customcommands:
            settings.customcommands[command] = new_content
            await SettingsDB.get_instance().set_guild_settings(settings)
            await ctx.send(get_str(ctx, "cmd-customcommand-success-edit"))
        else:
            await ctx.send(
                get_str(ctx, "cmd-customcommand-failed-edit").format(
                    "`{}customcom add`".format(
                        get_server_prefixes(ctx.bot, ctx.guild))))
예제 #4
0
파일: fun.py 프로젝트: hiratanagis/Watora
    async def flip(self, ctx, *, user: discord.Member = None):
        """
            {command_prefix}flip [user]
            {command_prefix}flip

        {help}
        """
        if user:
            msg = ""
            if user.id == self.bot.user.id or await is_basicpatron(
                    self.bot, user):
                user = ctx.author
                msg = get_str(ctx, "cmd-flip-nice-try") + "\n\n"
            char = "abcdefghijklmnopqrstuvwxyz"
            tran = "ɐqɔpǝɟƃɥᴉɾʞlɯuodbɹsʇnʌʍxʎz"
            table = str.maketrans(char, tran)
            name = user.display_name.translate(table)
            char = char.upper()
            tran = "∀qƆpƎℲפHIſʞ˥WNOԀQᴚS┴∩ΛMX⅄Z"
            table = str.maketrans(char, tran)
            name = name.translate(table)
            await ctx.send(msg + "(╯°□°)╯︵ " + name[::-1])
        else:
            await ctx.send("*" + get_str(ctx, "cmd-flip-success") + " " +
                           random.choice([
                               get_str(ctx, "cmd-flip-heads"),
                               get_str(ctx, "cmd-flip-tails")
                           ]) + "*")
예제 #5
0
 async def send_final_embed(self):
     e = discord.Embed(description=get_str(
         self.guild, "cmd-blindtest-enjoyed", bot=self.bot))
     e.description += "\n\n**[{}](https://www.patreon.com/watora)** {}".format(
         get_str(self.guild, "support-watora", bot=self.bot),
         get_str(self.guild, "support-watora-end", bot=self.bot))
     e.description += '\n' + get_str(
         self.guild, "suggest-features", bot=self.bot).format(
             f"`{get_server_prefixes(self.bot, self.guild)}suggestion`")
     await self.bt_channel.send(embed=e)
예제 #6
0
    async def send_to_channel(self):
        while True:
            try:
                if self.msg:
                    await self.msg.edit(embed=self.embed)
                    if self.pages_needed < 2:
                        await self.msg.clear_reactions()
                        break
                else:
                    self.msg = await self.ctx.send(embed=self.embed)
                    if self.pages_needed < 2:
                        break
                    for r in self.reactions:
                        await self.msg.add_reaction(r)

                try:
                    reaction, user = await self.bot.wait_for(
                        'reaction_add', check=self.check, timeout=self.timeout)
                except asyncio.TimeoutError:
                    await self.msg.clear_reactions()
                    break

                if reaction.emoji == ARROW_LEFT:
                    self.page -= 1
                    self.page %= self.pages_needed
                elif reaction.emoji == ARROW_RIGHT:
                    self.page += 1
                    self.page %= self.pages_needed
                elif reaction.emoji == STOP:
                    try:
                        await self.msg.clear_reactions()
                    except discord.HTTPException:
                        pass
                    break
                elif reaction.emoji == TRASH_BIN:
                    await self.msg.delete()
                    break

                await self.msg.remove_reaction(reaction.emoji, user)

            except discord.HTTPException:
                if self.ctx.channel.permissions_for(self.ctx.me).add_reactions:
                    await self.ctx.send(
                        get_str(self.ctx, 'need-manage-messages-permission'))
                elif self.ctx.channel.permissions_for(
                        self.ctx.me).manage_messages:
                    await self.ctx.send(get_str(self.ctx, 'need-add-emojis'))
                else:
                    await self.ctx.send(
                        get_str(self.ctx, 'need-manage-messages-permission') +
                        ' ' + get_str(self.ctx, 'need-add-emojis'))
                break
예제 #7
0
 async def welcomer(self, member, settings, goodbye=False):
     await self.bot.wait_until_ready()
     channels = [
         channel for channel in member.guild.channels
         if isinstance(channel, discord.TextChannel)
     ]
     if goodbye:
         dict = settings.goodbyes
     else:
         dict = settings.welcomes
     for channel in channels:
         if str(channel.id) in dict:
             text = dict[str(channel.id)]
             if "|" in text:
                 choices = [o for o in text.split("|") if o.strip()]
                 if choices:
                     text = random.choice(choices)
                     text = text.lstrip()
             text = text.replace('@mention', '<@%s>' % member.id)
             text = text.replace('@serv', member.guild.name)
             if 'discord.gg' in member.name.lower():
                 text = text.replace('@name', '[Removed Invite]')
             text = text.replace('@name', member.name)
             text = text.replace('@id', str(member.id))
             text = text.replace('@number', str(len(member.guild.members)))
             text = await self.format_cc(member, channel, text)
             pic = get_image_from_url(text)
             if pic:
                 e = discord.Embed()
                 e.set_image(url=pic)
                 text = text.replace(pic, '')
                 try:
                     await channel.send(embed=e, content=text)
                 except discord.Forbidden:
                     try:
                         if goodbye:
                             await channel.send(
                                 get_str(
                                     "need-embed-permission-for-goodbye",
                                     bot=self.bot))
                         else:
                             await channel.send(
                                 get_str(
                                     "need-embed-permission-for-welcome",
                                     bot=self.bot))
                     except discord.Forbidden:
                         pass
             else:
                 try:
                     await channel.send(text)
                 except discord.Forbidden:
                     pass
예제 #8
0
파일: fun.py 프로젝트: hiratanagis/Watora
    async def poll(self, ctx, *, question):
        """
            {command_prefix}poll [question]

        {help}
        """
        messages = [ctx.message
                    ]  # a list of messages to delete when we're all done
        question = format_mentions(question)
        answers = []
        for i in range(1, 11):
            messages.append(await ctx.send(
                get_str(ctx, "cmd-poll-init").format("`{}cancel`".format(
                    get_server_prefixes(ctx.bot, ctx.guild)))))
            try:
                entry = await self.bot.wait_for(
                    'message',
                    check=lambda m: len(m.content) <= 100 and m.author == ctx.
                    author and m.channel == ctx.channel,
                    timeout=60.0)
            except asyncio.TimeoutError:
                break

            if not entry:
                break

            prefixes = [
                get_server_prefixes(ctx.bot, ctx.guild),
                f"<@!{self.bot.user.id}>", self.bot.user.mention
            ]
            if any([entry.content.startswith(p) for p in prefixes]):
                break

            messages.append(entry)

            answers.append((self.to_keycap(i), entry.clean_content))

        try:
            await ctx.channel.delete_messages(messages)
        except discord.Forbidden:
            pass  # oh well

        answer = '\n'.join(map(lambda t: '%s - %s' % t, answers))
        if answer == "":
            return await ctx.send(get_str(ctx, "cmd-poll-cancelled"),
                                  delete_after=10)
        actual_poll = await ctx.send('**%s** {}:\n\n*- %s*\n\n%s'.format(
            get_str(ctx, "cmd-poll-someone-asks")) %
                                     (ctx.author, question, answer))
        for emoji, _ in answers:
            await actual_poll.add_reaction(emoji)
예제 #9
0
    async def on_message_check(self, message, settings, cmd_prefix):
        words = message.content[len(cmd_prefix):].split(' ')
        try:
            cmd = self.get_command(' '.join(words[:2]))
        except IndexError:
            cmd = None
        if not cmd:
            cmd = self.get_command(words[0])
        if cmd:
            command = cmd.name.lower()
            if cmd.parent:
                command = f'{cmd.parent.name.lower()} {command}'

        if str(message.channel.id) in settings.disabledchannels:
            if not settings.disabledchannels[str(message.channel.id)]:
                return False
            if cmd and command in settings.disabledchannels[str(
                    message.channel.id)]:
                return False

        if settings.blacklisted:
            if message.author.id in settings.blacklisted:
                return False
            if any(r for r in message.author.roles
                   if r.id in settings.blacklisted):
                return False

        if settings.disabledcommands:
            if cmd and command in settings.disabledcommands:
                try:
                    await message.channel.send("```c\n{}```".format(
                        get_str(message.guild, "bot-disabled-command", self)),
                                               delete_after=10)
                except discord.Forbidden:
                    pass
                return False

        if settings.bound:
            if settings.bound in [c.id for c in message.guild.channels]:
                if settings.bound != message.channel.id:
                    try:
                        await message.channel.send("```\n{}```".format(
                            get_str(message.guild, "bot-bind-mod", self)),
                                                   delete_after=10)
                    except discord.Forbidden:
                        pass
                    return False
        return True
예제 #10
0
    async def mal(self, ctx, username: str = None):
        """
            {command_prefix}mal (username)

        {help}
        """
        if not username:
            username = ctx.author.name
        await ctx.trigger_typing()
        try:
            result = await self.bot.jikan.user(username=username)
        except (JikanException, aiohttp.ClientError):
            return await ctx.send(get_str(ctx, "no-result"))
        result = Jikan(result)
        embed = discord.Embed()
        stats = result.anime_stats
        embed.add_field(name='Completed', value=stats.completed)
        embed.add_field(name='Watching', value=stats.watching)
        embed.add_field(name='On hold', value=stats.on_hold)
        embed.add_field(name='Dropped', value=stats.dropped)
        embed.add_field(name='Plan to Watch', value=stats.plan_to_watch)
        embed.add_field(name='Rewatched', value=stats.rewatched)
        embed.add_field(name='Mean Score', value=stats.mean_score)
        embed.add_field(name='Total', value=stats.total_entries)
        embed.add_field(name='Episodes Watched', value=stats.episodes_watched)
        embed.add_field(name='Days Watched', value=stats.days_watched)

        embed.set_author(name=result.username,
                         url=result.url,
                         icon_url='https://i.imgur.com/vEy5Zaq.png')
        embed.set_thumbnail(url=result.image_url)
        await ctx.send(embed=embed)
예제 #11
0
    async def nodes(self, ctx):
        """
            {command_prefix}nodes

        Displays information about my nodes.
        """
        embed = discord.Embed(description="")
        for n in self.bot.lavalink.node_manager.nodes:
            if n.available:
                region = n.region
                if n.stats:
                    cpu = round(n.stats.system_load * 100, 2)
                    cpull = round(n.stats.lavalink_load * 100, 2)
                    node_uptime = str(
                        timedelta(milliseconds=n.stats.uptime)).split(".")[0]
                    core = n.stats.cpu_cores
                    llp = n.stats.players
                    llpp = n.stats.playing_players
                else:
                    cpu = cpull = node_uptime = 'No data'
                    core = llp = llpp = 0
                player = llp or len(n.players)
                playing = llpp or len([x for x in n.players if x.is_playing])
                description = (f"```fix\nNode {n.name}```\n*Region: {region}*\n*Uptime: {node_uptime}*\n\n**Cpu :**\nCore{'s' if core > 1 else ''} : {core}\n"
                               f"System Load : {cpu}% (lavalink {cpull}%)\n\n"
                               f"**Shard Players :**\nCreated: {player}\nPlaying : {playing}\n\n")
            else:
                description = (
                    f"```fix\nNode {n.name}```\n*{n.region}*\n\n**NOT AVAILABLE!**")
            embed.description += description

        try:
            await ctx.send(embed=embed)
        except discord.Forbidden:
            return await ctx.send(get_str(ctx, "need-embed-permission"), delete_after=20)
예제 #12
0
    async def active(self, ctx):
        """
            {command_prefix}active

        {help}
        """
        players = self.bot.lavalink.players
        embed = discord.Embed()

        connected = len(players.find_all(lambda p: p.is_connected))
        paused = len(players.find_all(lambda p: p.paused))
        playing = len(players.find_all(
            lambda p: p.is_playing and not p.paused))
        voice = len([g for g in self.bot.guilds if g.me and g.me.voice])
        volume = len(self.bot.lavalink.players.find_all(
            lambda p: p.volume != def_v))
        defeq = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
        equalizer = len(self.bot.lavalink.players.find_all(
            lambda p: any(p.equalizer)))

        embed.add_field(name="Players", value=len(players), inline=False)
        embed.add_field(name="Custom Volume", value=volume, inline=False)
        embed.add_field(name="Custom Equalizer", value=equalizer, inline=False)
        embed.add_field(name="Voice", value=voice, inline=False)
        embed.add_field(name="Connected", value=connected, inline=False)
        embed.add_field(name="Playing", value=playing, inline=False)
        embed.add_field(name="Paused", value=paused, inline=False)
        embed.add_field(name="Stopped", value=connected -
                        playing - paused, inline=False)

        try:
            await ctx.send(embed=embed)
        except discord.Forbidden:
            await ctx.send(get_str(ctx, "need-embed-permission"), delete_after=20)
예제 #13
0
    async def linux(self, ctx):
        """
            {command_prefix}linux

        Displays some cool informations.
        """
        embed = discord.Embed()
        embed.set_author(name=self.bot.user.name,
                         icon_url=self.bot.user.avatar_url)
        if not ctx.guild:
            embed.color = 0x71368a
        else:
            embed.color = ctx.me.color
        embed.add_field(name="Platform", value=str(
            platform.platform()), inline=False)
        embed.add_field(name="CPU", value=str(
            f"{psutil.cpu_percent()}%"), inline=False)
        embed.add_field(
            name="Memory", value=f"{bytes2human(psutil.virtual_memory().used)}/{bytes2human(psutil.virtual_memory().total)} ({psutil.virtual_memory().percent}%)", inline=False)
        embed.add_field(
            name="Swap", value=f"{bytes2human(psutil.swap_memory().used)}/{bytes2human(psutil.swap_memory().total)} ({psutil.swap_memory().percent}%)", inline=False)
        embed.add_field(
            name="Disk", value=f"{bytes2human(psutil.disk_usage('/').used)}/{bytes2human(psutil.disk_usage('/').total)} ({psutil.disk_usage('/').percent}%)", inline=False)
        try:
            await ctx.send(embed=embed)
        except discord.Forbidden:
            return await ctx.send(get_str(ctx, "need-embed-permission"), delete_after=20)
예제 #14
0
    async def stare(self, ctx, target: discord.Member):
        """
            {command_prefix}stare [user]

        Allows to stare someone.
        """
        author = ctx.author
        if target == ctx.author:
            return await ctx.send(get_str(ctx, "cmd-weeb-alone"))
        pic = await self.bot.weebsh.get_random(image_type="stare")
        embed = discord.Embed(description=get_str(ctx, "cmd-stare").format(
            f'**{author.name}**', f'**{target.name}**'))
        embed.set_image(url=pic)
        try:
            await ctx.send(embed=embed)
        except discord.Forbidden:
            await ctx.send(get_str(ctx, "need-embed-permission"))
예제 #15
0
파일: fun.py 프로젝트: hiratanagis/Watora
    async def _ily(self, ctx, more=None):
        """
            {command_prefix}ily

        {help}
        """
        fetched_member = await is_lover(self.bot, ctx.author, fetch=True)
        if more and not fetched_member:
            await ctx.send(get_str(ctx, "cmd-ily-nope"))
        elif more:
            await ctx.send("<:WatoraCry:458349266495078413>")
        elif fetched_member:
            await ctx.send(
                random.choice(get_str(ctx, "cmd-ily-yes").split("|")))
        else:
            await ctx.send(random.choice(
                get_str(ctx, "cmd-ily-no").split("|")))
예제 #16
0
파일: fun.py 프로젝트: hiratanagis/Watora
    async def _8ball(self, ctx, *, more: str):
        """
            {command_prefix}8ball [question]

        {help}
        """
        await ctx.send(
            random.choice(get_str(ctx, "cmd-8ball-options").split("|")))
예제 #17
0
파일: fun.py 프로젝트: hiratanagis/Watora
    async def choice(self, ctx, *, name: str):
        """
            {command_prefix}choice [option_1] | [option_2] | [option_3] | ...
            {command_prefix}choice >>>[command_option_1] | >>>[command_option_2] | [option_3] | ...

        {help}
        """
        choices = [o for o in name.split("|") if o.strip()]
        if choices:
            opt = random.choice(choices)
        else:
            return await ctx.send(get_str(ctx, "cmd-choice-empty-option"))

        opt = opt.strip()
        opt = await self.bot.format_cc(opt, ctx.message)
        if "&&" in opt:
            all = opt.split("&&")
            if len(all) > 9:
                return await ctx.send(get_str(ctx, "cmd-choice-too-much-cmds"))
            for m in all:
                m = m.lstrip()
                m = m[3:]
                ctx.message.content = f"{get_server_prefixes(ctx.bot, ctx.guild)}{m}"
                await self.bot.process_commands(ctx.message)
            return

        if ">>>" in opt:
            while ">>> " in opt:
                opt = opt.replace(">>> ", ">>>")
            opt = ''.join(opt.split(">>>")[1:])
            ctx.message.content = f"{get_server_prefixes(ctx.bot, ctx.guild)}{opt}"

            return await self.bot.process_commands(ctx.message)

        opt = format_mentions(opt)
        pic = get_image_from_url(opt)
        if pic:
            e = discord.Embed()
            e.set_image(url=pic)
            opts = opt.replace(pic, "")
            try:
                return await ctx.send(embed=e, content=opts)
            except discord.Forbidden:
                return await ctx.send(get_str(ctx, "need-embed-permission"))

        await ctx.send(opt)
예제 #18
0
    async def hentai(self, ctx):
        """
            {command_prefix}hentai

        Displays a random hentai gif.
        """
        if ctx.guild and not ctx.channel.is_nsfw():
            return await ctx.send(get_str(ctx, "need-nsfw-channel-to-be-used"))
        embed = discord.Embed()
        embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)
        img = await self.get_image_ksoft('hentai_gif')
        embed.set_image(url=img)
        embed.set_footer(text="Powered by KSoft.Si API")
        try:
            await ctx.send(embed=embed)
        except discord.Forbidden:
            await ctx.send(get_str(ctx, "need-embed-permission"))
예제 #19
0
    async def nextep(self, ctx, *, anime: str):
        """
            {command_prefix}nextep [anime_title]

        {help}
        """
        search = await ctx.send(get_str(ctx, "is-searching"))
        await ctx.trigger_typing()
        found = await self.google_results('anime', anime)
        if not found:
            return await ctx.send(get_str(ctx, "no-result"))
        try:
            selection = await self.bot.jikan.anime(found)
            anime = Jikan(selection)
        except (JikanException, aiohttp.ClientError):
            return await ctx.send(get_str(ctx, "no-result"))

        if anime.status == "Finished Airing":
            aired = anime.aired
            a = getattr(aired, 'from').split('T')[0]
            if aired.to:
                b = getattr(aired, 'to').split('T')[0]
            else:
                b = '?'
            aired = get_str(ctx, "cmd-anime-aired") + \
                f" : **{a}** " + get_str(ctx, "cmd-anime-to") + f" **{b}**"
            remaining = get_str(ctx, "cmd-nextep-not-airing") + f"\n{aired}"
        else:
            try:
                remaining = await self.get_remaining_time(anime, ctx)
            except ValueError:
                remaining = '?'
        embed = discord.Embed(title=get_str(ctx, "cmd-nextep"),
                              description=remaining,
                              color=0x0066CC)
        embed.set_author(name='{}'.format(anime.title),
                         url=anime.url,
                         icon_url='https://i.imgur.com/vEy5Zaq.png')
        embed.set_thumbnail(url=anime.image_url)

        embed.set_footer(text=get_str(ctx, "cmd-anime-aired", can_owo=False) +
                         " : " + (anime.broadcast or '?'))
        try:
            await search.delete()
        except discord.HTTPException:
            pass
        try:
            await ctx.send(embed=embed)
        except discord.Forbidden:
            return await ctx.send(get_str(ctx, "need-embed-permission"))
예제 #20
0
    async def bang(self, ctx, target: discord.Member):
        """
            {command_prefix}shoot [user]

        Allows to shoot someone.
        """
        author = ctx.author
        if target == ctx.author:
            return await ctx.send(get_str(ctx, "cmd-shoot-yourself"))
        if target == ctx.me and not await is_lover(self.bot, author):
            return await ctx.send(get_str(ctx, "cmd-shoot-watora"))
        pic = await self.bot.weebsh.get_random(image_type="bang")
        embed = discord.Embed(description=get_str(ctx, "cmd-shoot").format(
            f'**{author.name}**', f'**{target.name}**'))
        embed.set_image(url=pic)
        try:
            await ctx.send(embed=embed)
        except discord.Forbidden:
            await ctx.send(get_str(ctx, "need-embed-permission"))
예제 #21
0
 async def cog_command_error(self, ctx, error):
     """A local error handler for all errors arising from commands in this cog"""
     if hasattr(error, 'original'):
         if isinstance(error.original, aiohttp.ClientError) or isinstance(
                 error.original, asyncio.futures.TimeoutError):
             try:
                 await ctx.send(":exclamation: " +
                                get_str(ctx, "cmd-nextep-error"),
                                delete_after=20)
             except discord.HTTPException:
                 pass
예제 #22
0
    async def send_cmd_help(self, ctx, command=None):

        if not command:
            command = ctx.command
        cname = str(command).replace(" ", "-").lower()
        cname = str(cname).replace('pl-', 'pl')
        if command.help:
            prefix = get_server_prefixes(ctx.bot, ctx.guild)
            help_msg = get_str(ctx, f"cmd-{cname}-help")
            if ctx.channel.permissions_for(ctx.me).embed_links:
                embed = discord.Embed(title=f'{prefix}{str(command)}')
                help_msg = '\n'.join(
                    command.help.split('\n\n')[1:]).format(help=help_msg)
                embed.description = help_msg
                cmds = '\n'.join([
                    f'`{cmd.strip()}`'
                    for cmd in command.help.split('\n\n')[0].format(
                        command_prefix=prefix).split('\n')
                ])
                embed.add_field(name='Usage', value=cmds, inline=False)
                if not ctx.guild:
                    embed.color = 0x71368a
                else:
                    embed.color = ctx.me.color
                if command.aliases:
                    aliases = '\n'.join([
                        f'`{prefix}{(str(command.parent) + " ") if command.parent else ""}{a}`'
                        for a in command.aliases
                    ])
                    embed.add_field(name="Aliases",
                                    value=aliases,
                                    inline=False)
                return await ctx.send(embed=embed)
            else:
                return await ctx.send("```%s```" % dedent(
                    ctx.command.help.format(command_prefix=get_server_prefixes(
                        ctx.bot, ctx.guild),
                                            help=help_msg)))
        else:
            return await ctx.send(get_str(ctx, "cmd-help-help-not-found"))
            log.warning(f"MissingHelpError : {cname}")
예제 #23
0
    async def punch(self, ctx, target: discord.Member):
        """
            {command_prefix}punch [user]

        Allows to punch someone.
        """
        author = ctx.author
        if target == ctx.me and not await is_lover(self.bot, author):
            return await ctx.send(get_str(ctx, "cmd-weeb-dont-touch-me"))
        pic = await self.bot.weebsh.get_random(image_type="punch")
        embed = discord.Embed(description=get_str(ctx, "cmd-punch").format(
            f'**{target.name}**', f'**{author.name}**'))
        if target == ctx.author:
            pic = "https://s.put.re/1JQqwNT.gif"
            embed = discord.Embed(description=get_str(
                ctx, "cmd-punch-yourself").format(f'**{author.name}**'))
        embed.set_image(url=pic)
        try:
            await ctx.send(embed=embed)
        except discord.Forbidden:
            await ctx.send(get_str(ctx, "need-embed-permission"))
예제 #24
0
    async def _ily(self, ctx, more=None):
        """
            {command_prefix}ily

        {help}
        """
        fetched_member = await is_lover(self.bot, ctx.author, fetch=True)
        if more and not fetched_member:
            await ctx.send(get_str(ctx, "cmd-ily-nope"))
        elif more:
            #await ctx.send("<:WatoraCry:458349266495078413>")
            embed = discord.Embed(color=13596669)
            embed.set_image(
                url="https://cdn.discordapp.com/emojis/458349266495078413.png")
            await ctx.send(content=None, embed=embed)
        elif fetched_member:
            await ctx.send(
                random.choice(get_str(ctx, "cmd-ily-yes").split("|")))
        else:
            await ctx.send(random.choice(
                get_str(ctx, "cmd-ily-no").split("|")))
예제 #25
0
    async def cat(self, ctx):
        """
            {command_prefix}cat

        {help}
        """
        image = await self.bot.weebsh.get_random(image_type="animal_cat")
        embed = discord.Embed().set_image(url=image)
        try:
            await ctx.send(embed=embed)
        except discord.Forbidden:
            await ctx.send(get_str(ctx, "need-embed-permission"))
예제 #26
0
    async def poke(self, ctx, target: discord.Member):
        """
            {command_prefix}poke [user]

        Allows to poke someone.
        """
        author = ctx.author
        if target == ctx.author:
            if await is_lover(self.bot, ctx.author):
                author = ctx.me
            else:
                return await ctx.send(get_str(ctx, "cmd-weeb-alone"))
        if target == ctx.me and not await is_lover(self.bot, ctx.author):
            return await ctx.send(get_str(ctx, "cmd-weeb-dont-touch-me"))
        pic = await self.bot.weebsh.get_random(image_type="poke")
        embed = discord.Embed(description=get_str(ctx, "cmd-poke").format(
            f'**{target.name}**', f'**{author.name}**'))
        embed.set_image(url=pic)
        try:
            await ctx.send(embed=embed)
        except discord.Forbidden:
            await ctx.send(get_str(ctx, "need-embed-permission"))
예제 #27
0
파일: fun.py 프로젝트: hiratanagis/Watora
    async def ascii(self, ctx, *, text):
        """
            {command_prefix}ascii [text]

        {help}
        """
        text = unidecode.unidecode(text)
        msg = str(figlet_format(text.strip(), font="standard"))
        if len(msg) > 2000:
            await ctx.send(get_str(ctx, "cmd-ascii-too-long"))
        else:
            mseg = '```{}```'.format(msg)
            if mseg != "``````":
                await ctx.send(mseg)
예제 #28
0
파일: fun.py 프로젝트: hiratanagis/Watora
    async def customcommand(self, ctx):
        """
            {command_prefix}cc add [command] [content]
            {command_prefix}cc edit [command] [new_content]
            {command_prefix}cc delete [command]
            {command_prefix}cc list
            {command_prefix}cc raw [command]

        {help}
        """
        if not ctx.invoked_subcommand:
            await ctx.send(
                get_str(ctx,
                        "command-invalid-usage").format("{}help cc".format(
                            get_server_prefixes(ctx.bot, ctx.guild))))
예제 #29
0
파일: fun.py 프로젝트: hiratanagis/Watora
    async def _list(self, ctx):
        """
            {command_prefix}cc list

        {help}
        """
        msg = [get_str(ctx, "cmd-customcommand-list")]

        settings = await SettingsDB.get_instance().get_guild_settings(
            ctx.guild.id)

        if not settings.customcommands:
            return await ctx.send(
                get_str(ctx, "cmd-customcommand-raw-no-cc").format(
                    "`{}customcom add`".format(
                        get_server_prefixes(ctx.bot, ctx.guild))))

        for n, command in enumerate(settings.customcommands, start=1):
            msg.append("``{}`` {}\n".format(n, command))

        if len(msg) == 1:
            return await ctx.send(
                get_str(ctx, "cmd-customcommand-raw-no-cc").format(
                    "`{}customcom add`".format(
                        get_server_prefixes(ctx.bot, ctx.guild))))

        to_send = ""
        for line in msg:
            if len(to_send) + len(
                    line) > 1980:  # TODO find a better way to do this
                await ctx.send(to_send)  # This is ugly
                to_send = ""
            to_send += line

        if to_send:
            await ctx.send(to_send)
예제 #30
0
파일: fun.py 프로젝트: hiratanagis/Watora
    async def _raw(self, ctx, command):
        """
            {command_prefix}cc raw [command]

        {help}
        """
        command = command.lower()

        settings = await SettingsDB.get_instance().get_guild_settings(
            ctx.guild.id)

        if not settings.customcommands:
            await ctx.send(
                get_str(ctx, "cmd-customcommand-raw-no-cc").format(
                    "`{}customcom add`".format(
                        get_server_prefixes(ctx.bot, ctx.guild))))

        elif command in settings.customcommands:
            await ctx.send(
                get_str(ctx, "cmd-customcommand-raw-content").format(
                    f"`{command}`") +
                "\n{}".format(settings.customcommands[command]))
        else:
            await ctx.send(get_str(ctx, "cmd-customcommand-raw-dont-exist"))