Esempio n. 1
0
 async def wiki(self, ctx):
     string = ctx.message.content.split(" ")
     string.pop(0)
     if len(string) == 0:
         await self.bot.say(embed=exception_handler.help(
             "!wiki word\nThis command only works in English at the moment!"
         ))
     else:
         message = ""
         for i in range(0, len(string)):
             message += string[i] + " "
         try:
             wiki_page = wikipedia.page(title=message,
                                        auto_suggest=True,
                                        redirect=True)
             title = wiki_page.title
             url_title = replace_char(title)
             url = "https://en.wikipedia.org/wiki/" + url_title
             description = wiki_page.summary[:2000]
             embed = discord.Embed(title=title,
                                   description=description,
                                   url=url,
                                   colour=discord.Colour.blue())
             await self.bot.say(embed=embed)
         except wikipedia.DisambiguationError as e:
             string = ""
             for i in range(0, 20):
                 string += "* " + e.options[i] + '\n'
             await self.bot.say(embed=exception_handler.error(
                 "Disambiguation. Try to be more specific!\n" + string))
         except wikipedia.PageError:
             await self.bot.say(
                 embed=exception_handler.error("The page does not exist."))
Esempio n. 2
0
 async def skip(self, ctx):
     state = self.get_voice_state(ctx.message.server)
     if not state.is_playing():
         await self.bot.say(embed=exception_handler.error(
             'Not playing any music right now.'))
         return
     elif self.is_paused:
         await self.bot.say(embed=exception_handler.error(
             "You must resume the paused song to skip."))
         return
     state.skip()
     await self.bot.say(embed=exception_handler.approve("Skipped"))
Esempio n. 3
0
 async def map(self, string):
     try:
         args = string.message.content.split(" ")
         source = args[1]
         destination = args[2]
         if len(args) != 3:
             await self.bot.say(embed=exception_handler.help(
                 "!map source_id destination_id"))
         elif source == destination:
             return
         source_id = self.bot.get_channel(source)
         destination_id = self.bot.get_channel(destination)
         if source_id and destination_id:
             self.mapping[source] = destination
             map_embed = discord.Embed(
                 title="Mapping Channels",
                 description="Mapped {}#{}  :arrow_right:  {}#{}.".format(
                     source_id.name, source_id.server.name,
                     destination_id.name, destination_id.server.name),
                 colour=discord.Colour.green())
             await self.bot.say(embed=map_embed)
         else:
             await self.bot.say(
                 embed=exception_handler.error("Invalid ID's."))
     except IndexError:
         await self.bot.say(
             embed=exception_handler.help("!map source_id destination_id"))
Esempio n. 4
0
 async def resume(self, ctx):
     state = self.get_voice_state(ctx.message.server)
     if state.is_playing() and self.is_paused is True:
         player = state.player
         player.resume()
         self.is_paused = False
     else:
         await self.bot.say(embed=exception_handler.error(
             "You cannot resume when nothing is paused."))
Esempio n. 5
0
 async def pause(self, ctx):
     state = self.get_voice_state(ctx.message.server)
     if state.is_playing():
         player = state.player
         player.pause()
         self.is_paused = True
     else:
         await self.bot.say(embed=exception_handler.error(
             "You cannot pause when nothing is playing."))
Esempio n. 6
0
    async def summon(self, ctx):
        summoned_channel = ctx.message.author.voice_channel
        if summoned_channel is None:
            await self.bot.say(embed=exception_handler.error(
                "You are not in a voice channel."))
            return False

        state = self.get_voice_state(ctx.message.server)
        if state.voice is None:
            state.voice = await self.bot.join_voice_channel(summoned_channel)
        else:
            await state.voice.move_to(summoned_channel)
        return True
Esempio n. 7
0
 async def reset_name(self, ctx):
     try:
         if len(ctx.message.content.split()) == 1:
             await self.bot.say(
                 embed=exception_handler.help("!reset_name user_mention"))
         else:
             user = ctx.message.mentions[0]
             await self.bot.change_nickname(user, None)
             await self.bot.say(
                 "User name for {} has been reset.".format(user))
     except discord.Forbidden:
         await self.bot.say(
             embed=exception_handler.error("You don't have the permission.")
         )
Esempio n. 8
0
 async def set_nickname(self, ctx):
     try:
         desired = ctx.message.content.split(" ")
         nickname = ""
         for i in range(2, len(desired)):
             nickname = nickname + desired[i] + " "
         user = ctx.message.mentions[0]
         await self.bot.change_nickname(user, nickname)
         await self.bot.say(
             "User {}'s nickname has been change to {} . ".format(
                 user.name, nickname))
     except discord.Forbidden:
         await self.bot.say(
             embed=exception_handler.error("You don't have the permission"))
     except IndexError:
         await self.bot.say(embed=exception_handler.help(
             "!set_nickname user_mention nickname"))
Esempio n. 9
0
 async def remind(self, string):
     args = string.message.content.split(" ")
     message = ""
     for i in range(2, len(args)):
         message += args[i] + " "
     if len(args) < 3:
         await self.bot.say(
             embed=exception_handler.help("!remind minutes message"))
     else:
         if int(args[1]) > 0:
             await self.bot.say(
                 "I will remind you in {} minutes to do that :ballot_box_with_check:"
                 .format(args[1]))
             await asyncio.sleep(int(args[1]) * 60)
             embed = discord.Embed(
                 title=
                 "Beep Boop, this is a reminder you set earlier :timer:",
                 description=message,
                 colour=discord.Colour.green())
             await self.bot.send_message(string.message.author, embed=embed)
         else:
             await self.bot.say(
                 embed=exception_handler.error("Invalid Minutes"))
Esempio n. 10
0
 async def play(self, ctx, *, song: str):
     state = self.get_voice_state(ctx.message.server)
     opts = {
         'default_search': 'auto',
         'quiet': True,
     }
     if state.voice is None:
         success = await ctx.invoke(self.summon)
         await self.bot.say(embed=exception_handler.approve("Loading..."))
         if not success:
             return
     try:
         player = await state.voice.create_ytdl_player(
             song, ytdl_options=opts, after=state.toggle_next)
         player.volume = self.glob_volume
     except Exception as e:
         await self.bot.say(embed=exception_handler.error(
             "Something has happened and could not play music."))
         print(e)
     else:
         entry = VoiceEntry(ctx.message, player)
         await self.bot.say(embed=exception_handler.approve('Enqueued ' +
                                                            str(entry)))
         await state.songs.put(entry)