所以我正在编写一个不和谐的机器人并想知道我将如何做到这一点
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]);
这篇关于如何嵌入用户需求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!