示例#1
0
    async def user(self, ctx, *args):

        # Ensure list is cleared for each use of command

        ranked_result_list.clear()
        account_result_list.clear()
        # Store acc name without spaces
        acc_name = "".join(args)

        async with ctx.typing():
            try:
                outputRank(acc_name)
                outputAccount(acc_name)

                # Store account name with spaces
                acc_name_sp = ranked_result_list[0]['name']

                # Create and message final result

                await createEmbed(acc_name, acc_name_sp, ranked_result_list[2],
                                  account_result_list[3],
                                  ranked_result_list[3], ctx)

                elobot_usg = getMongo()
                elobot_usg.update_one({"command": "user"},
                                      {"$inc": {
                                          "count": 1
                                      }},
                                      upsert=True)

            except Exception as e:
                await ctx.send("Cannot find account's information!")
                print(e)
示例#2
0
	async def recent(self, ctx, *args):

		try:
			async with ctx.typing():
				buildStrings(args)
				await createEmbed(ctx)

				elobot_usg = getMongo()
				elobot_usg.update_one({"command":"recent"}, {"$inc": {"count": 1}}, upsert=True)
		except:
			await ctx.send("Cannot find account's information!")
示例#3
0
    async def status(self, ctx):
        try:
            async with ctx.typing():
                buildStrings()
                await createEmbed(ctx)
                elobot_usg = getMongo()
                elobot_usg.update_one({"command": "status"},
                                      {"$inc": {
                                          "count": 1
                                      }},
                                      upsert=True)

        except Exception as e:
            await ctx.send("Error retrieving status information!")
            print(e)
示例#4
0
    async def live(self, ctx, *args):
        try:
            async with ctx.typing():
                buildStrings(args)
                await createEmbed(ctx)

                elobot_usg = getMongo()
                elobot_usg.update_one({"command": "live"},
                                      {"$inc": {
                                          "count": 1
                                      }},
                                      upsert=True)

        except:
            await ctx.send("No live game info for that account!")
示例#5
0
    async def build(self, ctx, *args):
        try:
            champ_name = "".join(args)
            champ_name = champ_name.lower()
            if champ_name == "wukong":
                champ_name = "monkeyking"
            await createString(self, ctx, champ_name)

            elobot_usg = getMongo()
            elobot_usg.update_one({"command": "build"}, {"$inc": {
                "count": 1
            }},
                                  upsert=True)
        except Exception as e:
            await ctx.send("No build information for that champion!")
            print(e)
示例#6
0
    async def help(self, ctx):

        league_cmnds = """
					  **$build [champion]** *Shows most frequent build info for a given champion*
					  **$live [username]** *Shows in-game info for a user*
					  **$mastery [username]** *Shows mastery scores for a user*
					  **$master [username] - [champion]** *Mastery info for a specific champion*
					  **$recent [username]** *Shows recent game stats for a user*
					  **$status** *Shows server status for each region*
					  **$user [username]** *Shows general account info for a user*
					  **$region** *Shows the currently selected region*
					  **$region [NA/EUW/KR...]** *Allows you to use commands for accounts in the selected region*\n"""

        music_cmnds = """
					  **$join** *Connects the bot to your current voice channel*
					  **$leave** *Disconnects the bot from your current voice channel*
					  **$play [URL or song name]** *Plays the URL or song name given. If a song is already playing, adds it to the queue*
					  **$queue** *Displays the current queue*
					  **$next** *Skips the current song and plays the next one in queue*
					  **$clear** *Stops the current song and clears the queue*"""

        embed = discord.Embed(colour=discord.Colour(0xff005c))

        embed.add_field(
            name="<:league_icon:713961777691623436> **League Commands**",
            value=league_cmnds,
            inline=False)

        embed.add_field(name="<:djsona:713966916708073519> **Music Commands**",
                        value=music_cmnds,
                        inline=False)

        embed.set_footer(text="Created by Sam and Alek",
                         icon_url="https://i.imgur.com/rqXHyI8.png")

        await ctx.send(embed=embed)

        elobot_usg = getMongo()
        elobot_usg.update_one({"command": "help"}, {"$inc": {
            "count": 1
        }},
                              upsert=True)
示例#7
0
    async def usage(self, ctx):

        try:
            elobot_usg = getMongo()
            elobot_usg.update_one({"command":"usage"}, {"$inc": {"count": 1}}, upsert=True)

            build_c = elobot_usg.find_one({"command": "build"})['count']
            help_c = elobot_usg.find_one({"command": "help"})['count']
            live_c = elobot_usg.find_one({"command": "live"})['count']
            mastery_c = elobot_usg.find_one({"command": "mastery"})['count']
            play_c = elobot_usg.find_one({"command": "play"})['count']
            recent_c = elobot_usg.find_one({"command": "recent"})['count']
            status_c = elobot_usg.find_one({"command": "status"})['count']
            usage_c = elobot_usg.find_one({"command": "usage"})['count']
            user_c = elobot_usg.find_one({"command": "user"})['count']
            total_c = build_c + help_c + live_c + mastery_c + play_c + recent_c + status_c + usage_c + user_c

            usage_str = f"""**Help:** {help_c}
                            **Build:** {build_c}
                            **Live:** {live_c}
                            **Mastery:** {mastery_c} 
                            **Recent:** {recent_c} 
                            **Status:** {status_c}
                            **Usage:** {usage_c}
                            **User:** {user_c} 
                            **Play:** {play_c}\n
                            **TOTAL:** {total_c}"""

            embed = discord.Embed(title="EloBot Usage Information", colour=discord.Colour(0xff005c))
            embed.add_field(name="**Command Totals**", value=usage_str, inline=False)

            embed.set_footer(text="Created by Sam and Alek", icon_url="https://i.imgur.com/rqXHyI8.png")

            await ctx.send(embed=embed)


        except Exception as e:
            await ctx.send("Error retrieving usage information!")
            print(e)
示例#8
0
    async def mastery(self, ctx, *args):
        try:
            if '-' not in args:
                async with ctx.typing():
                    buildStrings(args)
                    await createEmbed(ctx)

            else:
                args = "".join(args)
                await specific(ctx, args)

            elobot_usg = getMongo()
            elobot_usg.update_one({"command": "mastery"},
                                  {"$inc": {
                                      "count": 1
                                  }},
                                  upsert=True)

        except Exception as e:
            await ctx.send(
                "Cannot find account's information!\nIf you were trying to look up a user's\nmastery on a specific champion use: **$mastery [user] - [champion]**"
            )
            print(e)
示例#9
0
    async def join(self, ctx):

        elobot_usg = getMongo()
        elobot_usg.update_one({"command": "play"}, {"$inc": {
            "count": 1
        }},
                              upsert=True)

        ##################################################################
        '''
		if you would like to take a look at the database and the table please download: https://sqlitebrowser.org/dl/
		In the first section of the join command we first use SQLite to make us a table in our database that we have connected to above
		we use the statement 'create table if not exists' this creates the table if one by the name specified does not exist
		We create the table Music with columns that we populate right away with when you use the join command in a server
		it gets the Server ID, Sever name, voice channel id, voice channel name, user that used the join command, what postition in the queue we are (starts at one),
		generates queue folder name, and generates the song file name
		then the last thing we do is assign those variables to each column and then create a new row with that info
		then we use db.commit() to write these changes we are making ot the database (basically a save command)
		'''

        SQL.execute('create table if not exists Music('
                    '"Num" integer not null primary key autoincrement, '
                    '"Server_ID" integer, '
                    '"Server_Name" text, '
                    '"Voice_ID" integer, '
                    '"Voice_Name" text, '
                    '"User_Name" text, '
                    '"Next_Queue" integer, '
                    '"Queue_Name" text, '
                    '"Song_Name" text'
                    ')')
        server_name = str(ctx.guild)
        server_id = ctx.guild.id
        SQL.execute(
            f'delete from music where Server_ID ="{server_id}" and Server_Name = "{server_name}"'
        )
        db.commit()
        user_name = str(ctx.message.author)
        queue_name = f"Queue#{server_id}"
        song_name = f"Song#{server_id}"
        channel_id = ctx.message.author.voice.channel.id
        channel_name = str(ctx.message.author.voice.channel)
        queue_num = 1
        SQL.execute(
            'insert into Music(Server_ID, Server_Name, Voice_ID, Voice_Name, User_Name, Next_Queue, Queue_Name, Song_Name) values(?,?,?,?,?,?,?,?)',
            (server_id, server_name, channel_id, channel_name, user_name,
             queue_num, queue_name, song_name))
        db.commit()

        ##################################################################
        '''
		This is basic join command
		'''

        channel = ctx.message.author.voice.channel
        voice = get(self.client.voice_clients, guild=ctx.guild)

        if voice is not None:
            return await voice.move_to(channel)

        title_list.clear()
        await channel.connect()

        print(f"The bot has joined {channel}")

        await ctx.send(f"Joined {channel}")