Jakub Šidlík
Jakub Šidlík

Reputation: 25

Defining the argument number in discord.py, sending a picture

The problem is on the 10th line, (don't mind the 9th) I want the discord bot to send back a message with arguments like this .../arg1/arg1.arg2.png after they send in the command !maps arg1 arg2

@bot.command(brief="test")
async def maps(ctx, *args):
    if not args:
        await ctx.channel.send("Nenapsal jsi Rod/ Rod a druh! \nVysvětlivka:")
        await ctx.channel.send(
            "https://cdn.discordapp.com/attachments/661985293834125342/808308254081417227/acz_map_command.png"
        )

    else:
        await ctx.channel.send('Mapa výskytu: *{}*'.format(
            ' '.join(args).capitalize()))
        #await ctx.channel.send('https://antmap.coc.tools/images/{0}/{0}.{0}.png'.format(''.join(args).rpartition("")))
        await ctx.channel.send(f'https://ants-api.qwq.xyz/static/antmaps/{0}/{0}.{1}.png')
        await ctx.channel.send('AntWiki: *{}*'.format(
            ' '.join(args).capitalize()))
        await ctx.channel.send(
            'https://antwiki.org/wiki/{}'.format(
                '_'.join(args).capitalize()))

await ctx.channel.send(f'https://ants-api.qwq.xyz/static/antmaps/{0}/{0}.{1}.png') Won't send to the channel https://ants-api.qwq.xyz/static/antmaps/Common/Common.ant.png after receiving the command !maps Common ant It only does send in https://ants-api.qwq.xyz/static/antmaps/0/0.1.png

Upvotes: 0

Views: 67

Answers (1)

ESloman
ESloman

Reputation: 2102

I see your issue now. You're not using f-strings correctly. Replace your send with the below and it should work as expected.

await ctx.channel.send(f'https://ants-api.qwq.xyz/static/antmaps/{args[0]}/{args[0]}.{args[1]}.png')

Inside the { } you just put 0 or 1. Python understands that as literally 0 or 1 - hence the link you're getting. You need to change it so it's actually getting the value you want from args.

Upvotes: 1

Related Questions