0
votes

I have a selfbot project for Discord (I know it's against the ToS, but this is just an experiment I'm not going to use it)

I want the selfbot to send a message like "this is an example message" every hour in a specific channel with the ID (783651779207626752)

What and where should I add something in the code?

const Discord = require("discord.js")
const client = new Discord.Client()
const { prefix, token } = require("./config.json")
const fs = require("fs")
const { table, getBorderCharacters } = require("table")


const commands = new Discord.Collection();

let commandFiles

function loadCommands() {
    console.log("loading commands..")
    const startTime = new Date().getTime()

    commandFiles = fs.readdirSync("./commands/").filter(file => file.endsWith(".js"));
    const failedTable = []

    if (commands.size > 0) {
        for (command of commands.keyArray()) {
            delete require.cache[require.resolve(`./commands/${command}.js`)]
        }
        commands.clear()
    }

    for (file of commandFiles) {
        let command
        
        try {
            command = require(`./commands/${file}`);

            let enabled = true;
        
            if (!command.name || !command.description || !command.run) {
                enabled = false;
            }

            if (enabled) {
                commands.set(command.name, command);
            } else {
                failedTable.push([file, "❌"])
            }
        } catch (e) {
            failedTable.push([file, "❌"])
        }
    }
}

loadCommands()

exports.reloadCommands = loadCommands

client.once("ready", () => {
    console.log("logged in as " + client.user.username + "#" + client.user.discriminator)
})

function runCommand(cmd, message, args) {
    args.shift()
    try {
        commands.get(cmd).run(message, args)
    } catch(e) {
        console.log(e)
    }
}

setTimeout(() => {
    client.login(token)
}, 1500)
1
As you stated it is a Self Bot and is also against Discord's Terms of Service, I personally have used Selfbots back in like 2016 when they didn't enforce this issue, but I highly suggest that you don't selfbot and secondly; We as developers know that "I'm not going to use it" is very unlikely to be taken serious, the Terms of Service is there for a reason. Please stick to it and prevent yourself being account banned.Johnty

1 Answers

1
votes

You can make another file called globalFunctions.js

Add anything that you want to be running globally as an IFFE

This will insure that every IFFE has its own block of code

globalFunctions.js


export default globalFunctions(client, channel){
/*
 IFFE
*/

    (function(){
      setInterval(()=>{
         channel.send('some message')
      }, /*Time you want*/)
    })()

// and so on

}

OR "I recommend this if you want to scale"

you can add other files for each global function and add then to global function file

/*Import other functions*/

import periodicMessage from 'PATH'
export default globalFunctions(client, channel){
   
    periodicMessage(client, channel);


}

and just import this function to the main file and run it after the server runs

main.js

import globalFunctions from 'PATH'

client.once('ready', () => {

    // Your code

    globalFunctions(client, channel)
})