【问题标题】:How to make command that takes 2 argumetns如何制作带有 2 个参数的命令
【发布时间】:2021-09-16 22:18:18
【问题描述】:

所以,我正在制作一个不和谐的机器人,它需要很少的命令,其中之一是

/watch 

在该命令之后,用户将输入他们的地址(区块链)

/watch 0xAD488499b897a9667395526C39d0f3314A0f3FE9

我不知道如何在消息中制作 2 个变量来获取 if watch 获取地址 在机器人收到地址后,它将与用户一起将其保存到文本文件中,并且每 30 秒它会检查它是否正在挖掘(如果不是,则意味着您需要重新激活它会提醒使用该地址的手表的用户) 检查将使用idena API完成 https://api.idena.io/api/swagger/index.html 它将检查Online Miner status by the address

【问题讨论】:

  • 这是介绍中的第一件事..discordpy.readthedocs.io/en/latest/ext/commands/…
  • 非常感谢你
  • @ŁukaszKwieciński 它不工作
  • import discord from discord.ext import commands client = discord.Client() bot = commands.Bot(command_prefix='.') @client.event async def on_ready(): print('We have logged in as {0.user}'.format(client)) @bot.command() async def test(ctx, *, arg): await ctx.send(arg)
  • “它不工作” -- 为什么??

标签: python python-3.x python-requests discord discord.py


【解决方案1】:

这个程序可以根据你的问题帮助你

import os
from discord.ext import commands

bot = commands.Bot(command_prefix=".")

@bot.command(name="test")
async def _test(ctx, first, second):
    # first variable takes first argument
    # second variable takes second argument
    # Your programming logic goes here...

bot.run(os.environ["TOKEN"]) # your bot token here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-05
    • 1970-01-01
    • 1970-01-01
    • 2020-10-09
    • 1970-01-01
    • 2013-03-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多