【发布时间】:2022-01-03 18:28:16
【问题描述】:
不和谐,模块discord.ext.commands 允许您创建命令。我尝试创建一个带有前缀="/" 的命令,尽管它不会出现在 discord 的 UI 中。
代码:
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="/")
@bot.command(name="kick", description="Kick a user to your wish.")
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member, *, reason=None):
await member.kick(reason=reason)
await ctx.send(f"The user @{member} has been kicked. Reason: {reason}.")
bot.run("mytoken")
【问题讨论】:
标签: python discord discord.py bots