Niwa
Niwa
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
thank you
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
like node index.js --deploy-commands?
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
so, for deploying command i just make a deploy.js for exemple that i start when i want to deploy?
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
that'll be enough i guess
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
however its more faster
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
Its still doing the same
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
that would prevent the loading time?
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
i see
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
oh
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
Alright, so what shall I do, it's better to check if the name/description doesnt change or to make a command to just deploy them?
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
If i edit them, i dont need to deploy them again?
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
i was kinda confused too
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
this.token returns nothing
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
if i log that, it returns my token
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
No description
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
if u need more info u can ping me
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
yeah theres still commentary tho, i was testing slash commands (im not used to)
30 replies
DIAdiscord.js - Imagine an app
Created by Niwa on 5/24/2024 in #djs-questions
Problems with starting up the bot
"use strict";

import { Client, Collection } from "discord.js";
import { readdirSync } from 'node:fs';
import settings from "../../app.settings.js";
import Logger from "./Logger.js";
import { REST, Routes } from "discord.js";


class Madi extends Client {
constructor(client, token ){
super(client);
this.commands = new Collection()
this.events = new Collection()
this.settings = settings;
this.token = token;
this.logger = Logger;
this.id = "1240374752183586826"
this.guild = "1001197214766477462"
this.regex = new RegExp("<@!?1240374752183586826>");
}

async init(){
await this.login(this.options.token);

await this.loadCommands()
await this.loadEvents()

return this;
}

async loadCommands(){
console.log(this.id)
const commands = [];
const rest = new REST().setToken(this.options.token);
const cmdList = readdirSync("./src/commands/").filter((file) => file.endsWith(".js"))
for(const cmd of cmdList){
const cmdName = cmd.split(".js")[0]
const CommandInstance = (await import(`./../commands/${cmd}`)).default
const Command = new CommandInstance(this, cmdName)
if ('data' in Command && 'run' in Command) {
commands.push(Command.data.toJSON());
} else {
console.log(`[WARNING] The command ${cmdName} is missing a required "data" or "execute" property.`);
}
this.commands.set(cmdName, Command)

}

try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);

// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationGuildCommands(this.id, this.guild),
{ body: commands },
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}

}

async loadEvents(){
const eventList = readdirSync("./src/events/").filter((file) => file.endsWith(".js"))
for(const event of eventList){
const eventName = event.split(".js")[0]
const EventInstance = (await import(`./../events/${event}`)).default
const Event = new EventInstance(this)
this.events.set(eventName, Event)
if (Event.once){
this.once(eventName, (...args) => Event.run(...args))
} else {
this.on(eventName, (...args) => Event.run(...args))
}
}
}
}

export { Madi }
"use strict";

import { Client, Collection } from "discord.js";
import { readdirSync } from 'node:fs';
import settings from "../../app.settings.js";
import Logger from "./Logger.js";
import { REST, Routes } from "discord.js";


class Madi extends Client {
constructor(client, token ){
super(client);
this.commands = new Collection()
this.events = new Collection()
this.settings = settings;
this.token = token;
this.logger = Logger;
this.id = "1240374752183586826"
this.guild = "1001197214766477462"
this.regex = new RegExp("<@!?1240374752183586826>");
}

async init(){
await this.login(this.options.token);

await this.loadCommands()
await this.loadEvents()

return this;
}

async loadCommands(){
console.log(this.id)
const commands = [];
const rest = new REST().setToken(this.options.token);
const cmdList = readdirSync("./src/commands/").filter((file) => file.endsWith(".js"))
for(const cmd of cmdList){
const cmdName = cmd.split(".js")[0]
const CommandInstance = (await import(`./../commands/${cmd}`)).default
const Command = new CommandInstance(this, cmdName)
if ('data' in Command && 'run' in Command) {
commands.push(Command.data.toJSON());
} else {
console.log(`[WARNING] The command ${cmdName} is missing a required "data" or "execute" property.`);
}
this.commands.set(cmdName, Command)

}

try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);

// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationGuildCommands(this.id, this.guild),
{ body: commands },
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}

}

async loadEvents(){
const eventList = readdirSync("./src/events/").filter((file) => file.endsWith(".js"))
for(const event of eventList){
const eventName = event.split(".js")[0]
const EventInstance = (await import(`./../events/${event}`)).default
const Event = new EventInstance(this)
this.events.set(eventName, Event)
if (Event.once){
this.once(eventName, (...args) => Event.run(...args))
} else {
this.on(eventName, (...args) => Event.run(...args))
}
}
}
}

export { Madi }
30 replies