Example #1
0
    async def wiki(self, ctx, *, search: str):
        """ Grabs Wikipedia Article """
        searchlist = wikipedia.search(search)
        if len(searchlist) < 1:
            author = ctx.message.author
            title = "Searched for: " + search
            desc = 'No Results Found'
            em = dmbd.newembed(author, title, desc)
            await self.bot.say(embed=em)
        else:
            page = wikipedia.page(searchlist[0])

            author = ctx.message.author
            title = page.title
            desc = wikipedia.summary(searchlist[0], 3)
            url = page.url
            em = dmbd.newembed(author, title, desc, url)

            em.set_image(url=page.images[0])
            em.set_thumbnail(
                url=
                "https://upload.wikimedia.org/wikipedia/commons/thumb/b/b3/Wikipedia-logo-v2-en.svg/250px-Wikipedia-logo-v2-en.svg.png"
            )
            self.bot.cogs['WordDB'].cmdcount('wiki')
            await self.bot.say(embed=em)
Example #2
0
    async def avatar(self, ctx, *, name: str):
        """ Grabbing an avatar of a person """
        if ctx.message.mentions:
            user = ctx.message.mentions[0]
        else:
            user = ctx.message.server.get_member_named(name)
        if not user:
            name = name.lower()
            for x in ctx.message.server.members:
                if x.name.lower() == name:
                    user = x
                elif x.nick:
                    if x.nick.lower() == name:
                        user = x

        if not user:
            return
        author = ctx.message.author
        em = dmbd.newembed(author, u=user.avatar_url)
        em.set_image(url=user.avatar_url)
        grade = random.randint(1, 11)
        em.add_field(name=user.name + '#' + user.discriminator + '\'s Avatar',
                     value=str(grade) + "/10")

        await self.bot.say(embed=em)
        self.bot.cogs['WordDB'].cmdcount('avatar')
Example #3
0
    async def osusig(self, ctx, *, args: str):
        """
        Look up an osu player:
        Usage: osusig [UserID/Username] [Optional:Mode(default Osu!)]
        Modes:
            0 - Default Osu!
            1 - Taiko
            2 - ChitogeBot
            3 - Osu!mania
        """

        memes = args.split(' ')
        if len(memes) == 2:
            peppy = memes[0]
            kek = memes[1]
        elif len(memes) == 1:
            peppy = memes[0]
            kek = "0"
        else:
            await self.bot.say('Wrong Syntax!')
            return
        author = ctx.message.author
        em = dmbd.newembed(author)
        em.set_image(
            url="http://lemmmy.pw/osusig/sig.php?colour=hex66ccff&uname=" +
            peppy + "&mode=" + kek)

        await self.bot.say(embed=em)
        self.bot.cogs['WordDB'].cmdcount('osusig')
Example #4
0
    def getlink(self, mon, author, index):
        title = mon['name']
        description = mon["name_jp"] + "\n" + "*" * mon["rarity"]
        url = 'http://puzzledragonx.com/en/monster.asp?n=' + str(mon['id'])
        em = dmbd.newembed(author, title, description, url)
        em.set_image(url='https://www.padherder.com' + mon['image60_href'])
        em.add_field(name='Type',
                     value=self.gettype(mon['type'], mon['type2'],
                                        mon['type3']))
        em.add_field(name='Cost', value=mon['team_cost'])
        em.add_field(name='MaxLv',
                     value="{0} ({1}xp)".format(mon['max_level'],
                                                mon['xp_curve']))
        em.add_field(name='HP',
                     value="[{0}][{1}]".format(mon['hp_min'], mon['hp_max']))
        em.add_field(name='ATK',
                     value="[{0}][{1}]".format(mon['atk_min'], mon['atk_max']))
        em.add_field(name='RCV',
                     value="[{0}][{1}]".format(mon['rcv_min'], mon['rcv_max']))
        em.add_field(name='Leader Skill', value=str(mon['leader_skill']))
        em.add_field(name='Active Skill', value=str(mon['active_skill']))
        em.add_field(name='MP Sell Price', value=mon['monster_points'])
        em.add_field(name='Awakenings',
                     value=self.getawaken(mon['awoken_skills']),
                     inline=False)

        self.bot.cogs['WordDB'].cmdcount('pad')
        return em
Example #5
0
 async def ask(self, ctx, *, s: str):
     """ Asks wolfram alpha"""
     s.replace(' ', '+')
     req = requests.get(
         "http://api.wolframalpha.com/v1/result?appid=RPYQ54-Q3W9QJKWR9&i="
         + s)
     author = ctx.message.author
     em = dmbd.newembed(author, req.text)
     await self.bot.say(embed=em)
     self.bot.cogs['WordDB'].cmdcount('ask')
Example #6
0
 async def meow(self, ctx):
     """ When User Types ~meow, return a cat link """
     req = requests.get('http://random.cat/meow')
     if req.status_code != 200:
         print("Could not get a meow")
     catlink = json.loads(req.text)
     rngcat = catlink["file"]
     author = ctx.message.author
     title = 'Random.Cat'
     desc = 'Here, have a cat.'
     url = rngcat
     em = dmbd.newembed(author, title, desc, url)
     em.set_image(url=rngcat)
     await self.bot.say(embed=em)
     self.bot.cogs['WordDB'].cmdcount('meow')
Example #7
0
    async def woof(self, ctx):
        """When user types ~woof, return a woof link """

        req = requests.get('http://random.dog/')
        if req.status_code != 200:
            print("Could not get a woof")
        doglink = BeautifulSoup(req.text, 'html.parser')
        rngdog = 'http://random.dog/' + doglink.img['src']
        author = ctx.message.author
        title = 'Random.Dog'
        desc = 'Here, have a dog.'
        url = rngdog
        em = dmbd.newembed(author, title, desc, url)
        em.set_image(url=rngdog)
        await self.bot.say(embed=em)
        self.bot.cogs['WordDB'].cmdcount('woof')
Example #8
0
    async def ball(self, ctx):
        """ Ask the 8Ball """
        answers = [
            'It is certain', 'It is decidedly so', 'Without a doubt',
            'Yes, definitely', 'You may rely on it', 'As I see it, yes',
            'Most likely', 'Outlook good', 'Yes', 'Signs point to yes',
            'Reply hazy try again', 'Ask again later',
            'Better not tell you now', 'Cannot predict now',
            'Concentrate and ask again', 'Don\'t count on it',
            'My reply is no', 'My sources say no', 'Outlook not so good',
            'Very doubtful'
        ]

        author = ctx.message.author
        em = dmbd.newembed(author, random.choice(answers))
        await self.bot.say(embed=em)
        self.bot.cogs['WordDB'].cmdcount('8ball')
Example #9
0
 def display(self, author):
     title = self.username
     desc = self.country.upper()
     url = 'https://osu.ppy.sh/u/' + self.username
     em = dmbd.newembed(author, title, desc, url)
     em.add_field(name='Performance', value=self.pp_raw + 'pp')
     em.add_field(name='Accuracy',
                  value="{0:.2f}%".format(float(self.accuracy)))
     lvl = int(float(self.level))
     percent = int((float(self.level) - lvl) * 100)
     em.add_field(name='Level', value="{0} ({1}%)".format(lvl, percent))
     em.add_field(name='Rank', value=self.pp)
     em.add_field(name='Country Rank', value=self.pp_country_rank)
     em.add_field(name='Playcount', value=self.playcount)
     em.add_field(name='Total Score', value=self.total)
     em.add_field(name='Ranked Score', value=self.ranked)
     return em
Example #10
0
    async def displayanswer(self, author, char):
        try:
            anime = char['anime'][0]
        except:
            anime = char['anime']
        subtitle = anime['title_japanese']
        url = "https://anilist.co/anime/" + str(anime['id'])
        em = dmbd.newembed(author, 'Here\'s the answer!', subtitle, url)
        em.set_image(url=anime['image_url_lge'])
        em.add_field(name=anime['title_romaji'], value=anime['title_english'])
        em.add_field(name="Type", value=anime['type'])
        em.add_field(name='Rating', value=anime['average_score'])
        xstr = lambda s: s or ""
        em.add_field(name=char['name_japanese'],
                     value=char['name_first'] + " " + xstr(char['name_last']))

        await self.bot.say(embed=em)
Example #11
0
    async def roll(self, ctx, *, dice: str = '1d6'):
        """Rolls a dice in NdN format."""
        try:
            rolls, limit = map(int, dice.split('d'))
        except ValueError:
            await self.bot.say('Format has to be in NdN!')
            return

        author = ctx.message.author
        title = 'Here are your dice results!'
        em = dmbd.newembed(author, title)
        for r in range(rolls):
            em.add_field(name="Dice #" + str(r + 1),
                         value=str(random.randint(1, limit)))
        # result = ', '.join(str(random.randint(1, limit)) for r in range(rolls))
        await self.bot.say(embed=em)
        self.bot.cogs['WordDB'].cmdcount('roll')
Example #12
0
    async def topwords(self, ctx):
        """Top 10 words used in the server."""
        sorted_db = sorted(self.wordDB.items(),
                           key=operator.itemgetter(1),
                           reverse=True)

        digits = max(map(len, sorted_db))
        author = ctx.message.author
        title = "Top 10 Words Used"
        desc = "This is counted across all servers Rin is on."
        em = dmbd.newembed(author, title, desc)
        for i, x in zip(range(10), sorted_db):
            v = re.sub('[()\']', '', str(x))
            em.add_field(name="#" + str(i + 1), value=v.replace(",", ":"))

        await self.bot.say(embed=em)
        self.cmdcount('topwords')
Example #13
0
    async def safebooru(self, ctx, *, search: str):
        """Searches Safebooru"""
        link = ("http://safebooru.org/index.php?page=dapi&s=post&q=index" +
                "&tags=" + search.replace(' ', '_'))
        weeblist = self.getlink(link)
        numOfResults = int(weeblist['posts']['@count'])

        # Find how many pages there are

        numOfPages = int(numOfResults / 100)
        remaining = numOfResults % 100

        author = ctx.message.author
        title = 'Safebooru'
        desc = 'Searched For ' + search
        em = dmbd.newembed(author, title, desc)

        if numOfResults == 0:
            em.description = "No Results Found For " + search
        elif numOfResults == 1:
            em.set_image(url='https:' +
                         str(weeblist['posts']['post']['@file_url']))
        else:
            if numOfPages == 0:
                chosenone = random.randint(0, min(99, numOfResults - 1))
                em.set_image(
                    url='https:' +
                    str(weeblist['posts']['post'][chosenone]['@file_url']))
            else:
                page = random.randint(0, numOfPages)
                # Avoiding oversearching, and cutting the page limit to 3.
                # Sometimes really unrelated stuff gets put in.
                weeblist = self.getlink(link + '&pid=' + str(min(3, page)))
                if page == numOfPages:
                    chosenone = random.randint(0, min(99, remaining))
                    em.set_image(
                        url='https:' +
                        str(weeblist['posts']['post'][chosenone]['@file_url']))
                else:
                    chosenone = random.randint(0, 99)
                    em.set_image(
                        url='https:' +
                        str(weeblist['posts']['post'][chosenone]['@file_url']))

            self.bot.cogs['WordDB'].cmdcount('safebooru')
        await self.bot.say(embed=em)
Example #14
0
    async def cmdused(self, ctx, word: str):
        """ Shows how many times a cmd has been used."""

        author = ctx.message.author
        num = 0
        title = ""
        if word in self.cmdDB.keys():
            num = self.cmdDB[word]
        if num == 1:
            title = "This command has been used only once."
        else:
            title = "This command has been used {} times.".format(num)

        desc = "This is counted across all servers Rin is on."
        em = dmbd.newembed(author, title, desc)

        await self.bot.say(embed=em)
        self.cmdcount('cmdused')
Example #15
0
    async def flip(self, ctx):
        """ Flips a coin."""
        author = ctx.message.author
        em = dmbd.newembed(author)
        coin = random.randint(1, 2)
        if coin == 1:
            em.set_image(
                url=
                "https://www.usmint.gov/wordpress/wp-content/uploads/2017/03/2017-lincoln-penny-uncirculated-reverse-300x300.jpg"
            )
            await self.bot.say(embed=em)
        elif coin == 2:
            em.set_image(
                url=
                "https://www.usmint.gov/wordpress/wp-content/uploads/2017/03/2017-lincoln-penny-proof-obverse-san-francisco-300x300.jpg"
            )
            await self.bot.say(embed=em)

        self.bot.cogs['WordDB'].cmdcount('flip')
Example #16
0
    def gfylink(self, keyword, count, author):
        link = "https://api.gfycat.com/v1test/gfycats/search?search_text=" + str(
            keyword) + "&count=" + str(count)
        r = requests.get(link)
        if r.status_code != 200:
            print('Gyfcat returned ' + r.status_code)
            return
        giflist = json.loads(r.text)
        if not giflist:
            print('giflist not loaded correctly')
            return

        num = random.randint(0, count - 1)
        gif = giflist["gfycats"][num]
        title = gif["gfyName"]
        desc = gif["title"]
        if gif["tags"] != None:
            desc += " #" + " #".join([x for x in gif["tags"]])

        url = "https://gfycat.com/" + title
        return dmbd.newembed(author, title, desc, url)
Example #17
0
    def getinfo(self, author, series):
        """ Get the Info Message of the MalLink Class. Returns with Embed"""
        parser = htmlparser.HTMLParser()

        em = dmbd.newembed(author, series['title_japanese'],
                           series['title_romaji'],
                           self.getlink(series['id'], series['series_type']))
        em.set_thumbnail(url="https://anilist.co/img/logo_al.png")
        em.set_image(url=series['image_url_med'])
        if series['series_type'] == 'anime':  # if anime
            self.bot.cogs['WordDB'].cmdcount('anime')
            em.add_field(name="Episodes", value=series['total_episodes'])
            try:
                em.add_field(name="Length",
                             value=series['duration'] + " minutes")
            except KeyError:
                pass
            try:
                em.add_field(name="Status", value=series['airing_status'])
            except KeyError:
                pass

        elif series['series_type'] == 'manga':  # if manga
            self.bot.cogs['WordDB'].cmdcount('manga')
            em.add_field(name="Chapters", value=series['total_chapters'])
            em.add_field(name="Volumes", value=series['total_volumes'])
            try:
                em.add_field(name="Status", value=series['publishing_status'])
            except KeyError:
                pass

        em.add_field(name="Score", value=series['average_score'])
        em.add_field(name="Type", value=series['type'])
        if series['description'] != None:
            cleantext = BeautifulSoup(series['description'],
                                      "html.parser").text[:500] + "..."
            em.add_field(name="Synopsis", value=cleantext)
        return em
Example #18
0
    async def display(self, guess, misses, author, picture, win=0):
        subtitle = "Where you test your weeb level!"
        em = dmbd.newembed(author, "Anime Hangman!", subtitle)
        em.set_image(url=picture)

        em.add_field(name="Word",
                     value="`" + self.currentboard.title() + "`",
                     inline=False)
        if misses != []:
            em.add_field(name="Guess", value=guess)
            em.add_field(name="Misses", value=' '.join(misses))
        if not (len(misses) == 6 or win == 1):
            em.add_field(name="How to Play",
                         value=("Use " + self.bot.command_prefix +
                                "guess [x] to guess the next letter\n"
                                "Type $guess quit to exit\n"),
                         inline=False)

        if len(misses) == 0:
            em.set_thumbnail(url="https://goo.gl/FMUQrp")
        elif len(misses) == 1:
            em.set_thumbnail(url="https://goo.gl/fKvyTp")
        elif len(misses) == 2:
            em.set_thumbnail(url="https://goo.gl/dTVKVX")
        elif len(misses) == 3:
            em.set_thumbnail(url="https://goo.gl/BqiCFi")
        elif len(misses) == 4:
            em.set_thumbnail(url="https://goo.gl/XgytvK")
        elif len(misses) == 5:
            em.set_thumbnail(url="https://goo.gl/AevCAI")
        elif len(misses) == 6:
            em.set_thumbnail(url="https://goo.gl/8ymxqs")
            em.add_field(name="You Lose!", value="lul", inline=False)
            self.active = 0

        if win == 1:
            em.add_field(name="You Win!", value="You weeb...", inline=False)
        return await self.bot.say(embed=em)
Example #19
0
 async def choose(self, ctx, *choices: str):
     """Chooses between multiple choices."""
     author = ctx.message.author
     em = dmbd.newembed(author, random.choice(choices))
     await self.bot.say(embed=em)
     self.bot.cogs['WordDB'].cmdcount('choose')