如何嵌入到用户要求中? [英] 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
它将输出嵌入
我该怎么做?
感谢@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]);
这篇关于如何嵌入到用户要求中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文