misc.mcserver: fix motd for some (older) servers

This commit is contained in:
Cynthia Foxwell 2024-08-02 12:17:51 -06:00
parent d4f504bb3a
commit fcb1b770ea

View file

@ -239,7 +239,11 @@ mcserver.callback = async function (msg, line) {
await msg.removeReaction("\uD83C\uDFD3");
const motd = data.description.text.replace(/\u00a7([a-f0-9k-or])/gi, (formatting) => {
const desc =
typeof data.description == "string"
? data.description
: data.description?.text ?? "<server didn't properly send motd>";
const motd = desc.replace(/\u00a7([a-f0-9k-or])/gi, (formatting) => {
const ansi = formattingToAnsi[formatting];
return ansi ? `\x1b[${ansi}m` : "";
});