How to make a embed to the user requirments?(如何嵌入用户需求?)
问题描述
所以我正在编写一个不和谐的机器人并想知道我将如何做到这一点
So I'm coding a discord bot and wondering how I would do this
如果用户输入
~embed Title Description Colour
它将输出一个包含需求的嵌入.
It will output an embed with the requirements.
我该怎么做?
感谢@André
这是我的代码:https://ghostbin.com/paste/uetpj
推荐答案
一种方法是使用用户需要用来分隔字段的字符.像 |
或 ;;
.用户通常不会在消息中键入的内容.
然后您可以使用该字符拆分消息.
One way to do it would be with a character that the user needs to use to separate the fields. Like |
or ;;
. Something the users wont usually type in the messages.
Then you can split the message with that character.
var arguments = myString.split('|');
然后验证用户是否提供了所有需要的参数:
And then verify if the user gave all the arguments required:
if(arguments && arguments.length == 3){
// keep going
} else {
// warn the user that the syntax is wrong
}
最后你需要生成嵌入.
var embed = new Discord.RichEmbed();
embed.setTitle(arguments[0]);
embed.setDescription(arguments[1]);
embed.setColor(arguments[2]);
这篇关于如何嵌入用户需求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何嵌入用户需求?


- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01