コード例 #1
0
ファイル: utility.py プロジェクト: MrLar/Godavaru
 async def dictionary(self, ctx, word: str):
     """Define a word."""
     r = requests.get(
         'http://api.pearson.com/v2/dictionaries/laes/entries?headword=' +
         word)
     js = r.json()
     if len(js['results']) > 0:
         try:
             define = js['results'][0]['senses'][0]['definition'][0]
             pos = js['results'][0]['part_of_speech']
             ex = js['results'][0]['senses'][0]['translations'][0][
                 'example'][0]['text']
             word = js['results'][0]['headword']
             em = discord.Embed(
                 description="**Part Of Speech:** `{1}`\n**Headword:** `{0}`"
                 .format(word, pos),
                 color=0x8181ff)
             em.set_thumbnail(
                 url=
                 "https://www.shareicon.net/download/2016/05/30/575440_dictionary_512x512.png"
             )
             em.set_footer(
                 text="Requested by {} | Powered by http://api.pearson.com/"
                 .format(str(ctx.message.author)))
             em.add_field(name="Definition", value="**{}**".format(define))
             em.add_field(name="Example", value="**{}**".format(ex))
             em.set_author(name="Definition for {}".format(word),
                           icon_url=ctx.message.author.avatar_url.replace(
                               '?size=1024', ''))
             await ctx.send(embed=em)
         except KeyError:
             await ctx.send(
                 resolve_emoji('ERROR', ctx) + " No results found.")
     else:
         await ctx.send(resolve_emoji('ERROR', ctx) + " No results found.")
コード例 #2
0
ファイル: utility.py プロジェクト: MrLar/Godavaru
 async def _8ball(self, ctx, *, question):
     """Consult the magic 8ball (tsundere edition) with a question!"""
     answers = [
         'Y-yes...',  # y
         'U-uh, sure!',  # y
         'I mean, n-not like I want to say y-yes or anything... b-baka!',  # y
         'S-Sure, you baka!',  # y
         'O-of course!',  # y
         'I-I don\'t know, b-baka!',  # i
         'I\'m not all-knowing, you baka tako!',  # i
         'Baka! How am I supposed to know that?',  # i
         'I-I\'m b-busy right now, you baka...',  # i
         'N-not like I want to g-give you an answer or anything!',  # i
         'B-baka!',  # i
         'B-Baka! Don\'t make me slap you!',  # n
         'N-no...',  # n
         'I t-told you no, b-baka!',  # n
         'Are you dumb?',  # n
         'N-no... I-it\'s not like I\'m s-sorry about that or anything!',  # n
         'No, you b-baka tako!',  # n
         'N-no, you baka!',  # n
         'Geez, stop pushing yourself! You\'re going to get yourself hurt one day, you idiot!'  # n
     ]
     if re.compile('will you go out with me\??').match(question.lower()):
         return await ctx.send(
             resolve_emoji('TSUNDERE', ctx) +
             ' W-why are y-you asking! I-it\'s not like I l-like you or anything...'
         )
     await ctx.send(
         resolve_emoji('TSUNDERE', ctx) + ' ' + random.choice(answers))
コード例 #3
0
ファイル: utility.py プロジェクト: MrLar/Godavaru
 async def iamnot(self, ctx, *, name: str):
     """Remove a self assignable role."""
     results = self.bot.query_db(
         f'''SELECT self_roles FROM settings WHERE guildid={ctx.guild.id};'''
     )
     selfroles = json.loads(results[0][0].replace(
         "'", '"')) if results and results[0][0] else json.loads('{}')
     try:
         role = discord.utils.get(ctx.guild.roles, id=selfroles[name])
         if role:
             if role in ctx.author.roles:
                 await ctx.author.remove_roles(
                     role, reason='Self Assignable Role')
                 await ctx.send(
                     resolve_emoji('SUCCESS', ctx) +
                     f' Removed the **{role}** role from you.')
             else:
                 await ctx.send(
                     resolve_emoji('ERROR', ctx) +
                     ' Silly, I can\'t take a role that you don\'t have.')
         else:
             await ctx.send(
                 resolve_emoji('ERROR', ctx) +
                 ' The role corresponding to this self role was deleted.')
     except discord.Forbidden:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             ' I could not take that role from you. Make sure to contact an admin to check that my highest role is above the role trying to be assigned.'
         )
     except KeyError:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             f' There is no self-role with the name `{name}`.')
コード例 #4
0
ファイル: utility.py プロジェクト: MrLar/Godavaru
 async def suggest(self, ctx, *, suggestion: str):
     """Suggest a feature to be added!
     Has a cooldown of 2 requests per day to prevent spamming."""
     request_channel = self.bot.get_channel(316674935898636289)
     no_suggest = discord.utils.get(
         self.bot.get_guild(315251940999299072).roles,
         id=470249555980582916)
     if request_channel is None:  # shouldn't happen but /shrug
         return await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " Um, I'm sorry? The suggestions channel seems to be missing. "
             + "My owner must have deleted it. Sorry. :/ " +
             "Feel free to suggest your idea in person at my support server "
             + "in **#suggestions**! (https://discord.gg/ewvvKHM)")
     if ctx.author in self.bot.get_guild(
             315251940999299072
     ).members and no_suggest in self.bot.get_guild(
             315251940999299072).get_member(ctx.author.id).roles:
         return await ctx.send(
             resolve_emoji('ERROR', ctx) +
             f' You have been barred from suggesting things. If you wish to appeal this, please DM {self.bot.get_user(267207628965281792)} with detailed information on why you should be allowed to suggest things.'
         )
     suggestion = suggestion.replace('@everyone',
                                     '@\u200Beveryone').replace(
                                         '@here', '@\u200Bhere')
     await request_channel.send(
         f"**User Suggestion By:** {ctx.author} ({ctx.author.id})\n" +
         f"**Guild:** {ctx.guild} ({ctx.guild.id})\n" +
         f"**Suggestion:** {suggestion}")
     await ctx.send(
         ":ok_hand: Got it! Your suggestion has been sent through cyberspace all the way to my owner!"
     )
コード例 #5
0
ファイル: action.py プロジェクト: MrLar/Godavaru
 async def kill(self, ctx, *, member: discord.Member):
     """Kill a user!
     Note this command is just for fun. Nobody died in the making of this command... well maybe. *runs*"""
     with open('killquotes.txt') as f:
         quotes = f.readlines()
     if ctx.author.id == member.id:
         return await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " Don't kill yourself! You're loved!")
     if member.id == ctx.me.id:
         return await ctx.send(
             resolve_emoji('ERROR', ctx) + " Nice try. <3")
     await ctx.send(":knife: " + random.choice(quotes).format(
         member.display_name, ctx.author.display_name))
コード例 #6
0
ファイル: fun.py プロジェクト: MrLar/Godavaru
 async def lyrics(self, ctx, *, song: str):
     """Search up the lyrics to a song on Genius!"""
     async with self.bot.session.get(
             'https://api.genius.com/search?q=' +
             urllib.parse.quote_plus(song).replace('+', '%20'),
             headers={'Authorization': config.genius_token}) as resp:
         r = await resp.json()
     try:
         song = r['response']['hits'][0]['result']
         em = discord.Embed(description='[' + song['title_with_featured'] +
                            '](' + song['url'] + ')',
                            color=ctx.author.color)
         em.add_field(name='Pyongs (Upvotes)', value=song['pyongs_count'])
         em.add_field(name='State', value=song['lyrics_state'])
         em.add_field(name='Artist',
                      value='[' + song['primary_artist']['name'] + '](' +
                      song['primary_artist']['url'] + ')')
         em.add_field(name='Annotations', value=song['annotation_count'])
         em.add_field(name='Hot?', value=song['stats']['hot'])
         em.add_field(name='Artist Verified?',
                      value=song['primary_artist']['is_verified'])
         em.set_author(name='Found song! (Click the hyperlink below!)',
                       icon_url=song['header_image_thumbnail_url'])
         em.set_thumbnail(url=song['song_art_image_thumbnail_url'])
         await ctx.send(embed=em)
     except IndexError:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             ' Sorry, I couldn\'t find that song.')
コード例 #7
0
ファイル: info.py プロジェクト: MrLar/Godavaru
    async def weather(self, ctx, *, city: str):
        """Get weather information for a specified city."""
        r = await self.bot.session.get(
            f"http://api.openweathermap.org/data/2.5/weather/?q={city}&APPID={config.weather_token}"
        )
        if (await r.text()).startswith('{"coord"'):
            j = await r.json()
            em = discord.Embed(
                title=
                f":flag_{j['sys']['country'].lower()}: Weather for {j['name']}, {j['sys']['country']}",
                description=
                f"{j['weather'][0]['main']} ({j['clouds']['all']}% clouds)",
                color=ctx.author.color)

            em.add_field(
                name="🌡 Temperature",
                value=f"Current: { get_temp(j['main']['temp'])}\n" +
                f"Max: { get_temp(j['main']['temp_max'])}\n" +
                f"Min: { get_temp(j['main']['temp_min'])}"
            ).add_field(
                name="💧 Humidity", value=f"{j['main']['humidity']}%"
            ).add_field(
                name="💨 Wind Speeds", value=get_wind(j['wind']['speed'])
            ).add_field(
                name="🎐 Pressure", value=get_pressure(j['main']['pressure'])
            ).set_thumbnail(
                url=
                f"http://openweathermap.org/img/w/{j['weather'][0]['icon']}.png"
            )
            await ctx.send(embed=em)
        else:
            await ctx.send(
                resolve_emoji('ERROR', ctx) +
                " U-uh, I'm sorry, but that c-city doesn't seem to exist!")
コード例 #8
0
ファイル: utility.py プロジェクト: MrLar/Godavaru
 async def jumbo(self, ctx, emote: str):
     """Get a larger version of a custom emote."""
     match = re.compile(r"<(a)?:(\w*):(\d*)>").match(emote)
     if match:
         anim = False if not match.group(1) else True
         suffix = ".png" if not anim else ".gif"
         url = f"https://cdn.discordapp.com/emojis/{match.group(3)}{suffix}?size=1024"
         img = await (await self.bot.session.get(url)).read()
         await ctx.send(
             file=discord.File(img, filename=f'{match.group(2)}{suffix}'))
     else:
         try:
             em = str(emote.encode('unicode_escape'))
             uni = em[2:len(em) - 1].replace('\\\\u',
                                             '-').replace('\\\\U000',
                                                          '-')[1:]
             cairosvg.svg2png(
                 url="https://twemoji.maxcdn.com/2/svg/{}.svg".format(uni),
                 write_to="./images/emote.png",
                 parent_width=256,
                 parent_height=256)
             await ctx.send(file=discord.File('./images/emote.png'))
             os.remove('./images/emote.png')
         except urllib.error.HTTPError:
             await ctx.send(
                 resolve_emoji('ERROR', ctx) +
                 " That is not a custom or unicode emoji!")
コード例 #9
0
ファイル: utility.py プロジェクト: MrLar/Godavaru
 async def iam(self, ctx, *, name: str):
     """Claim a self assignable role.
     Do `iam list` for a list of all."""
     results = self.bot.query_db(
         f'''SELECT self_roles FROM settings WHERE guildid={ctx.guild.id};'''
     )
     selfroles = json.loads(results[0][0].replace(
         "'", '"')) if results and results[0][0] else json.loads('{}')
     if name in ['list', 'ls']:
         msg = ''
         for key in selfroles.keys():
             if discord.utils.get(ctx.guild.roles, id=selfroles[key]):
                 msg += f'**Self role name:** {key} | **Gives:** {discord.utils.get(ctx.guild.roles, id=selfroles[key])}\n'
         em = discord.Embed(
             title='All Self Assignable Roles',
             description=(msg if msg != '' else 'None (yet!)')
             if len(msg) < 2000 else '[Click me!](' +
             (await self.bot.post_to_haste(msg)) + ')',
             color=ctx.author.color)
         em.set_footer(text='Requested by ' + ctx.author.display_name)
         return await ctx.send(embed=em)
     try:
         role = discord.utils.get(ctx.guild.roles, id=selfroles[name])
         if role:
             if role not in ctx.author.roles:
                 await ctx.author.add_roles(role,
                                            reason='Self Assignable Role')
                 await ctx.send(
                     resolve_emoji('SUCCESS', ctx) +
                     f' Gave you the **{role}** role.')
             else:
                 await ctx.send(
                     resolve_emoji('ERROR', ctx) +
                     ' Silly, I can\'t give you a role you already have.')
         else:
             await ctx.send(
                 resolve_emoji('ERROR', ctx) +
                 ' The role corresponding to this self role was deleted.')
     except discord.Forbidden:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             ' I could not give you that role. Make sure to contact an admin to check that my highest role is above the role trying to be assigned.'
         )
     except KeyError:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             f' There is no self-role with the name `{name}`.')
コード例 #10
0
ファイル: utility.py プロジェクト: MrLar/Godavaru
 async def length(self, ctx, *, string: str):
     """Determine the length of a string.
     Note that this does have a joke if the word "dick" is included. To avoid this, end the string with '--bypass'"""
     if 'dick' in string.lower():
         if not string.lower().endswith('--bypass'):
             await ctx.send(
                 resolve_emoji('ERROR', ctx) + " That is too " +
                 ("small" if 'lars' not in string.lower() else 'long'))
         else:
             await ctx.send(
                 resolve_emoji('SUCCESS', ctx) +
                 f" That string is `{len(string) - 9}` characters long "
                 "(excluding the bypass)")
     else:
         await ctx.send(
             resolve_emoji('SUCCESS', ctx) +
             f" The string you gave me is `{len(string)}` characters long.")
コード例 #11
0
ファイル: utility.py プロジェクト: MrLar/Godavaru
 async def urban(self, ctx, *, params):
     """Search up a word on urban dictionary.
     To get another result for the same argument, simply use `urban <word> -number <int>`"""
     params = params.split(' -number ')
     word = params[0]
     if len(params) > 1:
         try:
             num = int(params[1]) - 1
         except:
             await ctx.send(
                 resolve_emoji('ERROR', ctx) +
                 " You gave me an improper number!")
             return
     else:
         num = 0
     r = await self.bot.session.get(
         f"http://api.urbandictionary.com/v0/define?term={word}")
     j = await r.json()
     try:
         request = j['list'][num]
     except IndexError:
         await ctx.send(
             resolve_emoji('ERROR', ctx) + " There are no more results.")
         return
     definition = request['definition']
     if len(definition) > 1000:
         definition = definition[:997] + "..."
     if definition == "":
         definition = "None"
     example = request['example']
     if len(example) > 1000:
         example = example[:997] + "..."
     if example == "":
         example = "None"
     em = discord.Embed(description=f"Definition #{num+1}",
                        color=ctx.author.color)
     em.add_field(name="Definition", value=definition, inline=False)
     em.add_field(name="Example", value=example, inline=False)
     em.add_field(name="👍", value=request['thumbs_up'], inline=True)
     em.add_field(name="👎", value=request['thumbs_down'], inline=True)
     em.set_author(name=f"Urban dictionary definition for {word}",
                   url=request['permalink'])
     em.set_footer(text=f"Author: {request['author']}")
     await ctx.send(embed=em)
コード例 #12
0
ファイル: utility.py プロジェクト: MrLar/Godavaru
 async def choose(self, ctx, *choices):
     """Choose a random item from a list."""
     if len(choices) < 2:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " I-I need at least two things to choose!")
         return
     await ctx.send(
         f":thinking: O-oh, you want me to choose? I guess I choose `{random.choice(choices)}`"
     )
コード例 #13
0
ファイル: utility.py プロジェクト: MrLar/Godavaru
 async def math(self, ctx, *, expression: str):
     """Evaluate complex mathematical equations (or simple ones, whatever you prefer).
     The available operations are as follows:
     `simplify, factor, derive, integrate, zeroes, tangent, area, cos, tan, arccos, arcsin, arctan, abs, log`"""
     available_endpoints = [
         "simplify", "factor", "derive", "integrate", "zeroes", "tangent",
         "area", "cos", "tan", "arccos", "arcsin", "arctan", "abs", "log"
     ]
     oper = expression.split(' -operation ')
     op = "simplify"
     if len(oper) > 1:
         try:
             if oper[1].lower() in available_endpoints:
                 op = oper[1].lower()
             else:
                 return await ctx.send(
                     resolve_emoji('ERROR', ctx) +
                     " S-Sorry! That operation seems invalid")
         except:
             return await ctx.send(
                 resolve_emoji('ERROR', ctx) +
                 " Y-you need to give me a valid operation! I made a list for you in the command help."
             )
     expr = oper[0].replace('/', '%2F')
     r = requests.get("https://newton.now.sh/" + op + "/" + expr)
     try:
         js = r.json()
     except json.decoder.JSONDecodeError:
         return await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " I-I'm sorry! Something happened with the api.")
     result = js['result']
     em = discord.Embed(title="Expression Evaluation",
                        color=ctx.message.author.color)
     em.add_field(name="Operation", value=js['operation'], inline=False)
     em.add_field(name="Expression", value=js['expression'], inline=False)
     em.add_field(name="Result",
                  value=result if result else 'No result',
                  inline=False)
     em.set_footer(text="Requested by " + str(ctx.message.author))
     em.timestamp = datetime.datetime.now()
     await ctx.send(embed=em)
コード例 #14
0
ファイル: info.py プロジェクト: MrLar/Godavaru
 async def avatar(self, ctx, *, user: discord.Member = None):
     """Get the avatar of a user!
     If the user is none, it will grab your avatar. If the user is not found, this message will be shown."""
     if user is None:
         user = ctx.author
     img = await (await self.bot.session.get(user.avatar_url)).read()
     await ctx.send(
         content=resolve_emoji('SUCCESS', ctx) +
         f' **{user.display_name}**\'s avatar!',
         file=discord.File(
             img,
             filename=
             f'{user.avatar}.{"png" if not user.avatar or not user.avatar.startswith("a_") else "gif"}'
         ))
コード例 #15
0
ファイル: action.py プロジェクト: MrLar/Godavaru
 async def hug(self, ctx):
     """Give a person a big fat hug! Awww!"""
     if len(ctx.message.mentions) == 0:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " You must mention at least one user.")
         return
     msg = f"**{ctx.author.display_name}** is hugging **{(', '.join([m.display_name for m in ctx.message.mentions])).replace(', '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name, ' and '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name)}**"
     if ctx.author in ctx.message.mentions:
         msg = f'***hugs*** Are you okay now, **{ctx.author.display_name}**?'
     img = await self.bot.session.get(url=(
         await self.bot.weeb.get_image(imgtype="hug", filetype="gif"))[0])
     await ctx.send(content=msg,
                    file=discord.File(await img.read(), filename="hug.gif"))
コード例 #16
0
ファイル: action.py プロジェクト: MrLar/Godavaru
 async def kiss(self, ctx):
     """Give that special someone a kiss! <3"""
     if len(ctx.message.mentions) == 0:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " You must mention at least one user.")
         return
     msg = f"**{ctx.author.display_name}** is kissing **{(', '.join([m.display_name for m in ctx.message.mentions])).replace(', '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name, ' and '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name)}**"
     if ctx.author in ctx.message.mentions:
         msg = f'I\'ll kiss you! *kisses*'
     img = await self.bot.session.get(url=(
         await self.bot.weeb.get_image(imgtype="kiss", filetype="gif"))[0])
     await ctx.send(content=msg,
                    file=discord.File(await img.read(),
                                      filename="kiss.gif"))
コード例 #17
0
ファイル: action.py プロジェクト: MrLar/Godavaru
 async def stare(self, ctx):
     """The command for when you have no clue what to say to someone, so you just stare..."""
     if len(ctx.message.mentions) == 0:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " You must mention at least one user.")
         return
     msg = f"**{ctx.author.display_name}** is staring at **{(', '.join([m.display_name for m in ctx.message.mentions])).replace(', '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name, ' and '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name)}**..."
     if ctx.author in ctx.message.mentions:
         msg = f'***stares at you***'
     img = await self.bot.session.get(url=(
         await self.bot.weeb.get_image(imgtype="stare", filetype="gif"))[0])
     await ctx.send(content=msg,
                    file=discord.File(await img.read(),
                                      filename="stare.gif"))
コード例 #18
0
ファイル: action.py プロジェクト: MrLar/Godavaru
 async def pat(self, ctx):
     """Send a pat over to a person or a few people. Sometimes a pat speaks words that words cannot.
     Or maybe I just really like pats so I endorse them. Whichever one it is."""
     if len(ctx.message.mentions) == 0:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " You must mention at least one user.")
         return
     msg = f"**{ctx.author.display_name}** is patting **{(', '.join([m.display_name for m in ctx.message.mentions])).replace(', '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name, ' and '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name)}**"
     if ctx.author in ctx.message.mentions:
         msg = f'***pats you***'
     img = await self.bot.session.get(url=(
         await self.bot.weeb.get_image(imgtype="pat", filetype="gif"))[0])
     await ctx.send(content=msg,
                    file=discord.File(await img.read(), filename="pat.gif"))
コード例 #19
0
ファイル: action.py プロジェクト: MrLar/Godavaru
 async def slap(self, ctx):
     """What the hell did you just say to me? I'm gonna slap you to the moon for that comment!"""
     if len(ctx.message.mentions) == 0:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " You must mention at least one user.")
         return
     msg = f"**{ctx.author.display_name}** is slapping **{(', '.join([m.display_name for m in ctx.message.mentions])).replace(', '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name, ' and '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name)}**"
     if ctx.author in ctx.message.mentions:
         msg = f'**Uh, okay. Sure. _slaps_**'
     img = await self.bot.session.get(url=(
         await self.bot.weeb.get_image(imgtype="slap", filetype="gif"))[0])
     await ctx.send(content=msg,
                    file=discord.File(await img.read(),
                                      filename="slap.gif"))
コード例 #20
0
ファイル: utility.py プロジェクト: MrLar/Godavaru
 async def colour(self, ctx, hexcode: str):
     """Show a preview of a hex colour."""
     if hexcode.startswith("0x") or hexcode.startswith("#"):
         hexcode = hexcode.strip("0x#")
     match = re.compile(r'^[^g-zG-Z]{6}$').match(hexcode)
     if not match:
         return await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " I-I'm sorry, that doesn't look like a hex colour to me.")
     hexcode = f'{match.group()}'
     try:
         rgb = ImageColor.getrgb('#' + hexcode)
     except ValueError:
         return await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " S-sorry! Something happened parsing this hexcode. I'll be better next time!"
         )
     c = discord.Color(int(match.group(), 16))
     em = discord.Embed(color=c)
     em.set_image(url="https://crimsonxv.pro/rendercolour?rgb={r},{g},{b}".
                  format(r=rgb[0], g=rgb[1], b=rgb[2]))
     em.set_author(name="Here's the colour you wanted!",
                   icon_url=ctx.author.avatar_url_as(format='png'))
     await ctx.send(embed=em)
コード例 #21
0
ファイル: action.py プロジェクト: MrLar/Godavaru
 async def poke(self, ctx):
     """Do you ever have a friend who just wont stop ignoring you? Just poke them. :eyes:"""
     if len(ctx.message.mentions) == 0:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " You must mention at least one user.")
         return
     msg = f"**{ctx.author.display_name}** is poking **{(', '.join([m.display_name for m in ctx.message.mentions])).replace(', '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name, ' and '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name)}**"
     if ctx.author in ctx.message.mentions:
         msg = f'*pokes you* hi. *pokes more*'
     img = await self.bot.session.get(url=(
         await self.bot.weeb.get_image(imgtype="poke", filetype="gif"))[0])
     await ctx.send(content=msg,
                    file=discord.File(await img.read(),
                                      filename="poke.gif"))
コード例 #22
0
ファイル: action.py プロジェクト: MrLar/Godavaru
 async def sleep(self, ctx):
     """The literal opposite of wakeup. This is also based off of my best friend, Kitty#4867, who would always tell me to go to bed. Love ya, Kat! ~Desii"""
     if len(ctx.message.mentions) == 0:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " You must mention at least one user.")
         return
     msg = f"**{ctx.author.display_name}** is telling **{(', '.join([m.display_name for m in ctx.message.mentions])).replace(', '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name, ' and '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name)}** to sleep!"
     if ctx.author in ctx.message.mentions:
         msg = f'**Self-discipline! I like it! Go sleep!**'
     img = await self.bot.session.get(url=(
         await self.bot.weeb.get_image(imgtype="sleepy", filetype="gif"))[0]
                                      )
     await ctx.send(content=msg,
                    file=discord.File(await img.read(),
                                      filename="sleep.gif"))
コード例 #23
0
ファイル: action.py プロジェクト: MrLar/Godavaru
 async def cuddle(self, ctx):
     """For when you just need to cuddle someone uwu"""
     if len(ctx.message.mentions) == 0:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " You must mention at least one user.")
         return
     msg = f"**{ctx.author.display_name}** is cuddling **{(', '.join([m.display_name for m in ctx.message.mentions])).replace(', '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name, ' and '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name)}**"
     if ctx.author in ctx.message.mentions:
         msg = f'***cuddles with you***'
     img = await self.bot.session.get(url=(
         await self.bot.weeb.get_image(imgtype="cuddle", filetype="gif"))[0]
                                      )
     await ctx.send(content=msg,
                    file=discord.File(await img.read(),
                                      filename='cuddle.gif'))
コード例 #24
0
ファイル: action.py プロジェクト: MrLar/Godavaru
 async def tease(self, ctx):
     """Hehe. The command for when you want to be a little joker and tease someone."""
     if len(ctx.message.mentions) == 0:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " You must mention at least one user.")
         return
     msg = f"**{ctx.author.display_name}** is teasing **{(', '.join([m.display_name for m in ctx.message.mentions])).replace(', '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name, ' and '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name)}**"
     if ctx.author in ctx.message.mentions:
         msg = f'*teases you* hehe'
     img = await self.bot.session.get(url=(
         await self.bot.weeb.get_image(imgtype="teehee", filetype="gif"))[0]
                                      )
     await ctx.send(content=msg,
                    file=discord.File(await img.read(),
                                      filename="tease.gif"))
コード例 #25
0
ファイル: utility.py プロジェクト: MrLar/Godavaru
 async def snipe(self, ctx):
     """Snipe a recently deleted message in this channel."""
     try:
         snipe = self.bot.snipes[str(ctx.channel.id)]
     except KeyError:
         return await ctx.send(
             resolve_emoji('ERROR', ctx) +
             f' No recently deleted messages found here.')
     em = discord.Embed(description=snipe['message'],
                        color=ctx.author.color)
     em.set_author(name=str(snipe['author']),
                   icon_url=snipe['author'].avatar_url)
     em.set_footer(text=f'Sniped by {ctx.author} | Sniped at',
                   icon_url=ctx.author.avatar_url)
     em.timestamp = datetime.datetime.utcnow()
     await ctx.send(embed=em)
コード例 #26
0
ファイル: action.py プロジェクト: MrLar/Godavaru
 async def wakeup(self, ctx):
     """A way to get your friends off of their lazy butts and wake up."""
     imgs = [
         "./images/wakeupa.gif", "./images/wakeupb.gif",
         "./images/wakeupc.gif", "./images/wakeupd.gif",
         "./images/wakeupe.gif", "./images/wakeupf.gif",
         "./images/wakeupg.gif", "./images/wakeuph.gif"
     ]
     if len(ctx.message.mentions) == 0:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " You must mention at least one user.")
         return
     msg = f"**{ctx.author.display_name}** is telling **{(', '.join([m.display_name for m in ctx.message.mentions])).replace(', '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name, ' and '+ctx.message.mentions[len(ctx.message.mentions)-1].display_name)}** to wake up!"
     if ctx.author in ctx.message.mentions:
         msg = 'Uh, don\'t you need to be awake to send a message? Oh well. Wake up!'
     await ctx.send(content=msg, file=discord.File(random.choice(imgs)))
コード例 #27
0
ファイル: utility.py プロジェクト: MrLar/Godavaru
 async def remindme(self, ctx, time: str, *, msg: str):
     """Remind yourself of something!"""
     days_match = re.search("(\d*) ?d", time)
     hours_match = re.search("(\d*) ?h", time)
     minutes_match = re.search("(\d*) ?m", time)
     seconds_match = re.search("(\d*) ?s", time)
     days = int(
         days_match[1]
     ) if days_match is not None and days_match[1].isdigit() else 0
     hours = int(
         hours_match[1]
     ) if hours_match is not None and hours_match[1].isdigit() else 0
     minutes = int(
         minutes_match[1]
     ) if minutes_match is not None and minutes_match[1].isdigit() else 0
     seconds = int(
         seconds_match[1]
     ) if seconds_match is not None and seconds_match[1].isdigit() else 0
     total = (days * 86400) + (hours * 3600) + (minutes * 60) + seconds
     if total <= 10:
         return await ctx.send(
             resolve_emoji('ERROR', ctx) + " That's too little time!")
     m, s = divmod(total, 60)
     h, m = divmod(m, 60)
     d, h = divmod(h, 24)
     dys = round(d)
     hrs = round(h)
     mnts = round(m)
     scnds = round(s)
     t = (f"{dys} day{'s' if dys > 1 else ''} " if dys > 0 else "") + (
         f"{hrs} hour{'s' if hrs > 1 else ''} " if hrs > 0 else
         "") + (f"{mnts} minute{'s' if mnts > 1 else ''} " if mnts > 0 else
                "") + (f"{scnds} second{'s' if scnds > 1 else ''} "
                       if scnds > 0 else "")
     await ctx.send(f":ok_hand: Okay! I'll remind you in " + t)
     await asyncio.sleep(total)
     try:
         await ctx.author.send(":wave: You asked me to remind you of: " +
                               msg)
     except:
         await ctx.send(
             ctx.author.mention +
             ': Sorry, I couldn\'t DM you, but you asked to be reminded of: '
             + msg)
コード例 #28
0
ファイル: fun.py プロジェクト: MrLar/Godavaru
 async def rps(self, ctx, choice: str):
     """Play a game of rock paper scissors against the bot.
     The choice parameter should be either rock, paper, or scissors, case insensitive."""
     opts = ["rock", "paper", "scissors"]
     emotes = ["🗿", "📰", "✂"]
     bot_choice = random.choice(opts)
     user_choice = choice.lower()
     if user_choice not in opts:
         return await ctx.send(
             resolve_emoji('ERROR', ctx) +
             " That is not rock, paper, or scissors.")
     bot_index = opts.index(bot_choice)
     user_index = opts.index(user_choice)
     win = False
     if bot_index < user_index != 2:
         win = True
     elif user_index == 2 and bot_index == 1:
         win = True
     await ctx.send(
         f"{emotes[bot_index]} You {'won' if win is True else 'lost'}!")
コード例 #29
0
ファイル: utility.py プロジェクト: MrLar/Godavaru
 async def _time(self, ctx, *, timezone: str):
     """Determine the current time in a timezone specified.
     The timezone is case sensitive as seen in [this list](https://pastebin.com/B5tLQdEY)."""
     try:
         if timezone.startswith('GMT'):
             t = timezone
             if timezone.startswith('GMT+'):
                 t = timezone.replace('+', '-')
             elif timezone.startswith('GMT-'):
                 t = timezone.replace('-', '+')
             tz = pytz.timezone('Etc/' + t)
         else:
             tz = pytz.timezone(timezone)
         await ctx.send("The time in **{0}** is {1}".format(
             timezone,
             datetime.datetime.now(tz).strftime("`%H:%M:%S` on `%d-%b-%Y`"))
                        )
     except pytz.UnknownTimeZoneError:
         await ctx.send(
             resolve_emoji('ERROR', ctx) +
             ' Couldn\'t find that timezone, make sure to use one from this list: <https://pastebin.com/B5tLQdEY>\nAlso remember that timezones are case sensitive.'
         )
コード例 #30
0
ファイル: utility.py プロジェクト: MrLar/Godavaru
 async def cat(self, ctx):
     """Get a random cat image!"""
     content = [
         ";w; Don't be sad, here's a cat!",
         "You seem lonely, {0.display_name}. Here, have a cat".format(
             ctx.author), "Meeeooowwww!",
         "Awww, so cute! Look at the kitty!!1!",
         "Woof... wait wrong animal."
     ]
     async with self.bot.session.get(
             'https://nekos.life/api/v2/img/meow') as resp:
         try:
             js = await resp.json()
             em = discord.Embed(color=discord.Colour(
                 int(
                     ''.join([
                         random.choice('0123456789ABCDEF') for _ in range(6)
                     ]), 16)))
             em.set_image(url=js['url'])
             await ctx.send(content=random.choice(content), embed=em)
         except:
             await ctx.send(
                 resolve_emoji('ERROR', ctx) +
                 " Error retrieving cat image :<")