【发布时间】:2020-06-07 00:12:45
【问题描述】:
好吧,我 12 岁,对任何“愚蠢”感到抱歉,好吧,我制作了一个不和谐的机器人,到目前为止它还不错,但是有一个问题,我们如何检查是否有人调用了命令?例如:
@client.commands()
async def sayname(ctx):
await ctx.send(f'Your name is {HowToGetName}')
是否可以添加两个参数,例如 sayname(ctx, member),因为我试过了,但没有用:(请帮忙。
编辑:如果这有助于我使用 Python 3.8.1
import discord
from discord.ext import commands
import random
import json
client = commands.Bot(command_prefix = ";")
@client.event
async def on_ready():
print("Bot is ready.")
@client.event
async def on_member_join(member):
print(f'{member} Joined the server!')
@client.command()
async def ping(ctx):
await ctx.send(f'Pong! Server Ping: {round(client.latency * 1000)}ms.')
@client.command()
async def coinflip(ctx):
number = random.randrange(1, 3);
if number == 1:
await ctx.send('Tails!')
else:
await ctx.send('Heads!')
@client.command()
async def test():
await ctx.send('This is a testing command.')
client.run("Token")
【问题讨论】:
-
出了什么问题,为什么每个人都反对这个帖子?我现在不能再问另一个问题了:(
标签: python python-3.x discord.py