Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward message function not working #1483

Closed
3 tasks done
mainecoonnetwork opened this issue Feb 1, 2025 · 1 comment
Closed
3 tasks done

Forward message function not working #1483

mainecoonnetwork opened this issue Feb 1, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@mainecoonnetwork
Copy link

Which package has the bugs?

The core library

Issue description

I’m trying to forward a message from source channel ID and send it to a target channel ID
The variables are all declared, but the forward function is just not working, I’m not sure why. It’s supposed to only need the target channel ID as a parameter. If anyone has an example code they can send, please do because I’m very confused.

This is the error:
Error forwarding message: cannot send an empty message

but when i logged the source message’s content, it did have content, and was also a regular text message.

This is the forward function on the documentation page: https://discordjs-self-v13.netlify.app/#/docs/docs/main/class/Message?scrollTo=forward. I hope that I submitted this right

Code sample

const Discord = require('discord.js-selfbot-v13');
const Authorization = process.env.Authorization;

const SOURCE_CHANNEL_ID = '00000';
const MESSAGE_ID = '00000';
const TARGET_CHANNEL_ID = '00000';
// IDs I used are blanked by 0s in this discussion 

const client = new Discord.Client({ checkUpdate: false });

client.once('ready', async () => {
  try {
    // Fetch the source channel
    const sourceChannel = await client.channels.fetch(SOURCE_CHANNEL_ID);
    if (!sourceChannel) {
      console.error('Source channel not found.');
      return;
    }

    // Fetch the specific message
    const message = await sourceChannel.messages.fetch(MESSAGE_ID);
    if (!message) {
      console.error('Message not found.');
      return;
    }

    // Fetch the target channel
    const targetChannel = await client.channels.fetch(TARGET_CHANNEL_ID);
    if (!targetChannel) {
      console.error('Target channel not found.');
      return;
    }

    // Forward the message to the target channel
    const forwardedMessage = await message.forward(targetChannel);
    console.log(`Message successfully forwarded`);
  } catch (error) {
    console.error('Error forwarding message:', error.message);
  }
});

client.login(Authorization);

Package version

[email protected]

Node.js version

Node v22.13.0

Operating system

Windows 11

Priority this issue should have

Medium (should be fixed soon)

Checklist

  • I have searched the open issues for duplicates.
  • I have shared the entire traceback.
  • I am using a user token (and it isn't visible in the code).

Additional Information

No response

@mainecoonnetwork mainecoonnetwork added the bug Something isn't working label Feb 1, 2025
aiko-chan-ai added a commit that referenced this issue Feb 3, 2025
@aiko-chan-ai
Copy link
Owner

b83323d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants