#How to send ansi text with webhooks?

17 messages · Page 1 of 1 (latest)

regal raven

Hey,

I've been playing around with ansi but i can't for the life of me get it to work when sending webhooks, why is this?

code:

import { REST, Routes } from "discord.js";
import { codeBlock } from "discord.js";

const rest = new REST({ version: "10" }).setToken();

const payload = {
  components: [
    {
      type: 17,
      accent_color: null,
      spoiler: false,
      components: [
        {
          type: 9,
          accessory: {
            type: 2,
            style: 2,
            label: "Small Eel",
            emoji: null,
            disabled: false,
            custom_id: "37e83076f00f4179b48f21be6d217d6d"
          },
          components: [
            {
              type: 10,
              content: codeBlock(
                "ansi",
                "\u001b[2;31m\u001b[0m\u001b[0;2mtext text\u001b[0m\u001b[0;2mSupport Desk\u001b[0m"
              )
            }
          ]
        }
      ]
    }
  ],
  flags: 32768
};

(async () => {
  try {
    const result = await rest.post(
      Routes.webhook(webhookId, webhookToken),
      { body: payload, auth: false }
    );
    console.log(result);
  } catch (error) {
    console.error(error);
  }
})();

the webhook executes just find, but the ansi text doesn't show. I used another tool called discohook but that doesn't do components v2, but i won't be sending everything using discohook when it comes to my bot

charred magnetBOT
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
vivid kelp

is it just with ansi?

and are you checking on desktop?

regal raven

Yh, just sends this

works if i do another language

I remember having to escape some characters or something but im not 100%

vivid kelp

check if that exact codeblock works with message content

if it does then it sounds like a cv2 bug

regal raven

I don't believe it works in normal embeds, but that's a good shout actually let me check

just to confirm you mean like literally content or within cv2 like text builder outside container

vivid kelp

message content, no cv2

const payload = { content: codeBlock(...) }

regal raven

No doesn't work

actually, i maybe being stupid

hold up

yh nvm, i was being stupid