小编dra*_*erv的帖子

如何在 python discord bot 中获取用户输入?

我有一个 python discord bot,我需要它在命令后获取用户输入,我该怎么做?我是 python 的新手,正在制作不和谐的机器人。这是我的代码:

import discord, datetime, time
from discord.ext import commands
from datetime import date, datetime

prefix = "!!"
client = commands.Bot(command_prefix=prefix, case_insensitive=True)

times_used = 0

@client.event
async def on_ready():
  print(f"I am ready to go - {client.user.name}")
  await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=f"{client.command_prefix}python_help. This bot is made by drakeerv."))

@client.command(name="ping")
async def _ping(ctx):
  global times_used
  await ctx.send(f"Ping: {client.latency}")
  times_used = times_used + 1

@client.command(name="time")
async def _time(ctx):
  global times_used
  from datetime import date, datetime

  now = datetime.now()

  if (now.strftime("%H") <= …
Run Code Online (Sandbox Code Playgroud)

python discord.py python-3.8

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

discord.py ×1

python ×1

python-3.8 ×1