0

I am new to python and using the discord api. I am making a bot where I collect league of legends data and I already created the function where I can collect the data like Summoners Information and Ranked details. I am just having hard time figuring it out and I have been looking every where that could help me.

async def on_message(message):
    if message.author == client.user:
        return
    
    if message.content.startswith('!stats'):
        await message.channel.send(requestSummonerData("Munns"))
        await message.channel.send("-----------------------------------")
        await message.channel.send(requestRankData("Munns"))

This is my current code at the moment, so far I am just hard coding the name and the information printing part is working perfectly but I would like to do something like !stats xyz and it would print information for that person. Honestly, any advice would help me because cause in the end I am just trying to learn python and discords api. Thank you so much!

Tone
  • 21
  • 2

1 Answers1

0
client = commands.Bot(command_prefix="!")

@client.command() 
async def stats(ctx, user):
    await ctx.send("put your msges here")

here's a slightly better way to do it and should get the job done now you just need to do !stats and it will send the message you send

Bagle
  • 2,326
  • 3
  • 12
  • 36
coder
  • 143
  • 1
  • 11
  • Hello! thank you for taking the time to respond! So for line 4 I would just type in the person I want to check so it'll be !stats xyz and it would show the information for that person? – Tone Apr 24 '22 at 00:33
  • i edited my answer for that to work I don't know how to check users you'll have to figure that out yourself but it will save what the user says after "!stats" as the variable "user" which you can use to find the stats – coder Apr 24 '22 at 00:36
  • @Tone If you want to mention a user, I've edited coder's answer so you can access the [`discord.Member`](https://discordpy.readthedocs.io/en/stable/api.html?highlight=discord%20member#discord.Member) object when using your command. – Bagle Apr 24 '22 at 02:30
  • @Bagle that will do discord member not league of legends – coder Apr 24 '22 at 02:40
  • 1
    My apologies, I must've understood the question wrong. I'll remove it. – Bagle Apr 24 '22 at 03:15