1

i wanted to create a discord bot that automatically sorts the numbers that a webhook sends and put them in a specific channel. I will be honest, i dont know how to start tho...

what should i do? i have searched some bots online and axtually tried to write mine but it just doesnt work

this is my code:

const Discord = require('discord.js');
const client = new Discord.Client();
const token = '<token>';

client.on('ready', () => {
    console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', msg => {
    if (msg.content.startsWith('sort')) {
        const numbers = msg.content.split(' ').slice(1);
        const sortedNumbers = numbers.sort((a, b) => a - b);
        const channels = msg.mentions.channels.array();
        channels.forEach(channel => {
            const output = sortedNumbers.join('\n');
            channel.send(`Sorted numbers:\n${output}`);
        });
    }
});

client.login(token);

i tried it and it doesnt work, if it was automated then it would be awesome... thank you!

  • Does this answer your question? [message.content doesn't have any value in Discord.js](https://stackoverflow.com/questions/73036854/message-content-doesnt-have-any-value-in-discord-js) – Zsolt Meszaros Feb 21 '23 at 17:33

0 Answers0