[英]How do I get a bot to send the message of the poll without the '\_poll' for an adv poll command with discord.js
I can't seem to get the bot to send the message of the poll without the '_poll'.如果没有“_poll”,我似乎无法让机器人发送投票消息。 What am I missing?
我错过了什么?
Code sample below:下面的代码示例:
module.exports = (client) => {
const command = require('./command');
command(client, 'poll', async (message) => {
const tag = `<@${message.author.id}>`;
message.content.replace('_poll', ' ');
const sentMessage = await message.channel.send(
`${tag} started a poll: **${message.content}**`
);
sentMessage.react('👍');
sentMessage.react('👎');
});
};
replace
does not change the value of the string it is replacing, it simply returns a new string. replace
不会改变它正在替换的字符串的值,它只是返回一个新字符串。
So in order to remove _poll
from your message content, create a new variable and set that variable to the replaced text.因此,为了从您的消息内容中删除
_poll
,请创建一个新变量并将该变量设置为替换文本。 Here is an example:下面是一个例子:
module.exports = (client) => {
const command = require('./command');
command(client, 'poll', async (message) => {
const tag = `<@${message.author.id}>`;
var content = message.content.replace('_poll', ' '); //Added a variable here
const sentMessage = await message.channel.send(
`${tag} started a poll: **${content}**`
);
sentMessage.react('👍');
sentMessage.react('👎');
});
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.