discord - !say discord.py 重写命令
问题描述
这是我的代码
@bot.command()
async def say(ctx, message=None):
await ctx.message.delete()
await ctx.send(message)
但是,如果我这样做!!说我是一只狗,机器人会说只有我是
你能帮我吗?
解决方案
那是因为空格是参数分隔符。如果您想*
在函数中使用带空格的参数。像这样:
@bot.command()
async def say(ctx,*,message=None):
await ctx.message.delete()
await ctx.send(message)
推荐阅读
- python-3.x - 每单位令牌python函数拆分一个数字
- opencl - pyopencl,找不到匹配的设备
- linux - 使用脚本检查 git 分支是否在另一个之前
- javascript - 如何使用 jquery 获取 div 的值?
- java - 如何使用 apache commons csv 使用具有多个字符的分隔符
- excel - 如果以前不存在,如何创建带有超链接的选项卡?
- php - 清理输入数据是否可以防止 sql 注入?
- javascript - Plotly.js - 多条轨迹的悬停标签与 xaxis 悬停标签重叠
- python - 如何从合并的pdf文件中提取文本?
- sql - SQL - 截断(Oracle)日期 - 什么是未来的安全选项?