misc.vote: fix topic with spaces

This commit is contained in:
Cynthia Foxwell 2023-04-20 10:26:42 -06:00
parent 063dd0c3f1
commit c699c04717
1 changed files with 15 additions and 4 deletions

View File

@ -254,11 +254,14 @@ const vote = new Command("vote");
vote.category = CATEGORY;
vote.helpText = "Start a yes/no vote";
vote.usage = "[topic]";
vote.callback = async function (msg, line, [topic], {maybe}) {
vote.callback = async function (msg, line, topic, {maybe}) {
if (!topic) return "No topic given.";
topic = topic.join(" ");
return {
content: `**${msg.author.username}#${msg.author.discriminator}** has started a vote:\n**__${topic}__**\n<:ms_tick:503341995348066313>: Yes\n<:ms_cross:503341994974773250>: No${
content: `**${msg.author.username}#${
msg.author.discriminator
}** has started a vote:\n**__${topic}__**\n<:ms_tick:503341995348066313>: Yes\n<:ms_cross:503341994974773250>: No${
maybe ? "\n<:ms_tilda:581268710925271095>: Maybe/Uncertain" : ""
}`,
addReactions: [
@ -572,10 +575,18 @@ search.callback = async function (msg, line, args, {results = 2}) {
let out = `__**Results for \`${safeString(query)}\`**__\n`;
for (const result of searchResults) {
if (result.special_response) {
out += "> " + safeString(parseHtmlEntities(result.special_response.response.split("\n").join("\n> ")));
out +=
"> " +
safeString(
parseHtmlEntities(
result.special_response.response.split("\n").join("\n> ")
)
);
out += `\n<${encodeURI(result.special_response.source)}>`;
} else {
out += `**${safeString(parseHtmlEntities(result.title))}** - <${encodeURI(result.url)}>`;
out += `**${safeString(parseHtmlEntities(result.title))}** - <${encodeURI(
result.url
)}>`;
out += `\n> ${safeString(parseHtmlEntities(result.description))}`;
}
out += "\n\n";