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!