Ahmad A.
Ahmad A.
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
Ok
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
import fs from "fs";
import Client from "../Interfaces/Client.js";
import Command from "../Interfaces/Command.js";
import sendLog from "../functions/sendLog.js";
function CommandHandler(client: Client): void {
fs.readdirSync("./build/commands").forEach(async dir => {
const commands = fs.readdirSync(`./build/commands/${dir}`).filter(file => file.endsWith(".js"));

for (const file of commands) {
const command: Command = await import(`../commands/${dir}/${file}`).then(
imported => imported.default
);

client.commands.set(command.data.name, command);
const handlerMessage = `[HANDLER - COMMAND] Loaded a command: ${file} (#${client.commands.size})`;
sendLog(handlerMessage, 2);
}
});
}

export default CommandHandler;
import fs from "fs";
import Client from "../Interfaces/Client.js";
import Command from "../Interfaces/Command.js";
import sendLog from "../functions/sendLog.js";
function CommandHandler(client: Client): void {
fs.readdirSync("./build/commands").forEach(async dir => {
const commands = fs.readdirSync(`./build/commands/${dir}`).filter(file => file.endsWith(".js"));

for (const file of commands) {
const command: Command = await import(`../commands/${dir}/${file}`).then(
imported => imported.default
);

client.commands.set(command.data.name, command);
const handlerMessage = `[HANDLER - COMMAND] Loaded a command: ${file} (#${client.commands.size})`;
sendLog(handlerMessage, 2);
}
});
}

export default CommandHandler;
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
import { Client as BaseClient, Collection, GatewayIntentBits } from "discord.js";
import Command from "../Interfaces/Command.js";
import ClientConfig from "../Interfaces/ClientConfig.js";
import CommandHandler from "../handlers/commandHandler.js";
import EventHandler from "../handlers/eventHandler.js";
import Modal from "../Interfaces/Modal.js";
import ModalHandler from "../handlers/modalHandler.js";
import { PasteClient } from "pastebin-api";
import secrets from "../json/secrets.json" assert { type: "json" };
import sendLog from "../functions/sendLog.js";
class Client extends BaseClient<true> {
public readonly commands: Collection<string, Command>;
public readonly modals: Collection<string, Modal>;
public pastebin: PasteClient;
constructor() {
super({
intents: [GatewayIntentBits.Guilds],
allowedMentions: { parse: ["users"] },
});

this.commands = new Collection<string, Command>();
this.modals = new Collection<string, Modal>();
this.pastebin = new PasteClient(this.config.pastebin);
}
config = secrets as unknown as ClientConfig;
async init() {
await sendLog(`[SYSTEM] Handlers have been initiated.`);
await CommandHandler(this);
await EventHandler(this);
await ModalHandler(this);
return await this.login(this.config.token);
}
}
export default Client;
import { Client as BaseClient, Collection, GatewayIntentBits } from "discord.js";
import Command from "../Interfaces/Command.js";
import ClientConfig from "../Interfaces/ClientConfig.js";
import CommandHandler from "../handlers/commandHandler.js";
import EventHandler from "../handlers/eventHandler.js";
import Modal from "../Interfaces/Modal.js";
import ModalHandler from "../handlers/modalHandler.js";
import { PasteClient } from "pastebin-api";
import secrets from "../json/secrets.json" assert { type: "json" };
import sendLog from "../functions/sendLog.js";
class Client extends BaseClient<true> {
public readonly commands: Collection<string, Command>;
public readonly modals: Collection<string, Modal>;
public pastebin: PasteClient;
constructor() {
super({
intents: [GatewayIntentBits.Guilds],
allowedMentions: { parse: ["users"] },
});

this.commands = new Collection<string, Command>();
this.modals = new Collection<string, Modal>();
this.pastebin = new PasteClient(this.config.pastebin);
}
config = secrets as unknown as ClientConfig;
async init() {
await sendLog(`[SYSTEM] Handlers have been initiated.`);
await CommandHandler(this);
await EventHandler(this);
await ModalHandler(this);
return await this.login(this.config.token);
}
}
export default Client;
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
Argument of type 'this' is not assignable to parameter of type 'Client'.ts(2345)
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
in the handlers
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
With "this"
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
Still getting an error
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
I didnt get where u wanted me to put the client sorry
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
import { Client as BaseClient, Collection, GatewayIntentBits } from "discord.js";
import Command from "../Interfaces/Command.js";
import ClientConfig from "../Interfaces/ClientConfig.js";
import CommandHandler from "../handlers/commandHandler.js";
import EventHandler from "../handlers/eventHandler.js";
import Modal from "../Interfaces/Modal.js";
import ModalHandler from "../handlers/modalHandler.js";
import { PasteClient } from "pastebin-api";
import secrets from "../json/secrets.json" assert { type: "json" };
import sendLog from "../functions/sendLog.js";
class Client<T extends boolean> extends BaseClient<T> {
public readonly commands: Collection<string, Command>;
public readonly modals: Collection<string, Modal>;
public pastebin: PasteClient;
constructor() {
super({
intents: [GatewayIntentBits.Guilds],
allowedMentions: { parse: ["users"] },
});

this.commands = new Collection<string, Command>();
this.modals = new Collection<string, Modal>();
this.pastebin = new PasteClient(this.config.pastebin);
}
config = secrets as unknown as ClientConfig;
async init() {
await sendLog(`[SYSTEM] Handlers have been initiated.`);
const client = await new Client().init();
await CommandHandler(this);
await EventHandler(this);
await ModalHandler(this);
return await this.login(this.config.token);
}
}
export default Client;
import { Client as BaseClient, Collection, GatewayIntentBits } from "discord.js";
import Command from "../Interfaces/Command.js";
import ClientConfig from "../Interfaces/ClientConfig.js";
import CommandHandler from "../handlers/commandHandler.js";
import EventHandler from "../handlers/eventHandler.js";
import Modal from "../Interfaces/Modal.js";
import ModalHandler from "../handlers/modalHandler.js";
import { PasteClient } from "pastebin-api";
import secrets from "../json/secrets.json" assert { type: "json" };
import sendLog from "../functions/sendLog.js";
class Client<T extends boolean> extends BaseClient<T> {
public readonly commands: Collection<string, Command>;
public readonly modals: Collection<string, Modal>;
public pastebin: PasteClient;
constructor() {
super({
intents: [GatewayIntentBits.Guilds],
allowedMentions: { parse: ["users"] },
});

this.commands = new Collection<string, Command>();
this.modals = new Collection<string, Modal>();
this.pastebin = new PasteClient(this.config.pastebin);
}
config = secrets as unknown as ClientConfig;
async init() {
await sendLog(`[SYSTEM] Handlers have been initiated.`);
const client = await new Client().init();
await CommandHandler(this);
await EventHandler(this);
await ModalHandler(this);
return await this.login(this.config.token);
}
}
export default Client;
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
In handlers
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
This is the error
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
Argument of type 'this' is not assignable to parameter of type 'Client'.ts(2345)
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
The return type of an async function or method must be the global Promise<T> type. Did you mean to write 'Promise<boolean>'?ts(1064)
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
this is Client<true>?
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
Could you tell me a bit more clearly
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
Ill remove the client interface
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
Does this help?
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
import Client from "./structures/Client.js";
const client = new Client();
client.init();
export default client;
import Client from "./structures/Client.js";
const client = new Client();
client.init();
export default client;
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
import { Client as BaseClient, ClientUser, Collection } from "discord.js";
import Command from "./Command.js";
import ClientConfig from "./ClientConfig.js";
import Modal from "./Modal.js";
import { PasteClient } from "pastebin-api";

interface Client extends BaseClient {
readonly commands: Collection<string, Command>;
readonly modals: Collection<string, Modal>;
config: ClientConfig;
pastebin: PasteClient;

user: ClientUser
init: () => Promise<void>;
}

export default Client;
import { Client as BaseClient, ClientUser, Collection } from "discord.js";
import Command from "./Command.js";
import ClientConfig from "./ClientConfig.js";
import Modal from "./Modal.js";
import { PasteClient } from "pastebin-api";

interface Client extends BaseClient {
readonly commands: Collection<string, Command>;
readonly modals: Collection<string, Modal>;
config: ClientConfig;
pastebin: PasteClient;

user: ClientUser
init: () => Promise<void>;
}

export default Client;
40 replies
DIAdiscord.js - Imagine an app
Created by Ahmad A. on 12/3/2023 in #djs-questions
super.user error after updating packages
import { Client as BaseClient, ClientUser, Collection, GatewayIntentBits } from "discord.js";
import IClient from "../Interfaces/Client.js";
import Command from "../Interfaces/Command.js";
import ClientConfig from "../Interfaces/ClientConfig.js";
import CommandHandler from "../handlers/commandHandler.js";
import EventHandler from "../handlers/eventHandler.js";
import Modal from "../Interfaces/Modal.js";
import ModalHandler from "../handlers/modalHandler.js";
import { PasteClient } from "pastebin-api";
import secrets from "../json/secrets.json" assert { type: "json" };
import sendLog from "../functions/sendLog.js";
class Client extends BaseClient implements IClient {
public readonly commands: Collection<string, Command>;
public readonly modals: Collection<string, Modal>;
public user: ClientUser;
public pastebin: PasteClient;
constructor() {
super({
intents: [GatewayIntentBits.Guilds],
allowedMentions: { parse: ["users"] },
});

this.commands = new Collection<string, Command>();
this.modals = new Collection<string, Modal>();
this.user = super.user as ClientUser;
this.pastebin = new PasteClient(this.config.pastebin);
}
config = secrets as unknown as ClientConfig;
async init() {
await sendLog(`[SYSTEM] Handlers have been initiated.`);
await CommandHandler(this);
await EventHandler(this);
await ModalHandler(this);
await this.login(this.config.token);
}
}
export default Client;
import { Client as BaseClient, ClientUser, Collection, GatewayIntentBits } from "discord.js";
import IClient from "../Interfaces/Client.js";
import Command from "../Interfaces/Command.js";
import ClientConfig from "../Interfaces/ClientConfig.js";
import CommandHandler from "../handlers/commandHandler.js";
import EventHandler from "../handlers/eventHandler.js";
import Modal from "../Interfaces/Modal.js";
import ModalHandler from "../handlers/modalHandler.js";
import { PasteClient } from "pastebin-api";
import secrets from "../json/secrets.json" assert { type: "json" };
import sendLog from "../functions/sendLog.js";
class Client extends BaseClient implements IClient {
public readonly commands: Collection<string, Command>;
public readonly modals: Collection<string, Modal>;
public user: ClientUser;
public pastebin: PasteClient;
constructor() {
super({
intents: [GatewayIntentBits.Guilds],
allowedMentions: { parse: ["users"] },
});

this.commands = new Collection<string, Command>();
this.modals = new Collection<string, Modal>();
this.user = super.user as ClientUser;
this.pastebin = new PasteClient(this.config.pastebin);
}
config = secrets as unknown as ClientConfig;
async init() {
await sendLog(`[SYSTEM] Handlers have been initiated.`);
await CommandHandler(this);
await EventHandler(this);
await ModalHandler(this);
await this.login(this.config.token);
}
}
export default Client;
40 replies