如何制作带参数的不和谐命令?
How to make a discord command with arguments?
我是编码之类的新手,我想知道是否有任何教程或页面可以解决这个问题:
我想制作一个看起来像这样的不和谐命令 !acz map Lasius flavus
其中:!acz
是前缀,map
是命令,Lasius flavus
是两个参数。
Bot 响应 link 消息,带有两个参数,应该如下所示:https://antmap.coc.tools/images/Lasius.flavus.png
这意味着我们收到一张图片的不和谐回复。
我希望能够输入我的 discord !acz map Genus species
- 并且机器人以 https://antmap.coc.tools/images/Genus.species.png
响应,其中 Genus 的第一个字母是大写的,就像在示例中一样。
我正在添加一张我想到的图片,其中 ?
是前缀,map
是命令,Lasius flavus
是属种
(不,我已经要求了代码)
感谢您的帮助!
@bot.command(brief="Za map napiš Rod a druh a vyskočí ti mapa výskytu!")
async def map(ctx, *args):
await ctx.channel.send('https://antmap.coc.tools/images/{}.png '.format('.'.join(args)))
这就是方法,通读 https://www.programiz.com/python-programming/methods/string/replace 对我有帮助!即使我没有使用 replace()!我只需要更改不发送参数和参数的代码中的几部分:
@bot.command()
async def map(ctx, *args):
await ctx.channel.send('{} arguments: {}'.format(len(args), ', '.join(args)))
我是编码之类的新手,我想知道是否有任何教程或页面可以解决这个问题:
我想制作一个看起来像这样的不和谐命令 !acz map Lasius flavus
其中:!acz
是前缀,map
是命令,Lasius flavus
是两个参数。
Bot 响应 link 消息,带有两个参数,应该如下所示:https://antmap.coc.tools/images/Lasius.flavus.png
这意味着我们收到一张图片的不和谐回复。
我希望能够输入我的 discord !acz map Genus species
- 并且机器人以 https://antmap.coc.tools/images/Genus.species.png
响应,其中 Genus 的第一个字母是大写的,就像在示例中一样。
我正在添加一张我想到的图片,其中 ?
是前缀,map
是命令,Lasius flavus
是属种
(不,我已经要求了代码)
感谢您的帮助!
@bot.command(brief="Za map napiš Rod a druh a vyskočí ti mapa výskytu!")
async def map(ctx, *args):
await ctx.channel.send('https://antmap.coc.tools/images/{}.png '.format('.'.join(args)))
这就是方法,通读 https://www.programiz.com/python-programming/methods/string/replace 对我有帮助!即使我没有使用 replace()!我只需要更改不发送参数和参数的代码中的几部分:
@bot.command()
async def map(ctx, *args):
await ctx.channel.send('{} arguments: {}'.format(len(args), ', '.join(args)))