lonely dev
lonely dev
DIAdiscord.js - Imagine an app
Created by lonely dev on 8/19/2024 in #djs-questions
messageCreate not picking up dm messages
My bot's messageReact event doesn't pick up any messages that are in dms, even tho i have enabled the needed intents for them, it works fine for guild messages tho bot.ts
import { Client, Collection } from "discord.js";
import { Command } from "./interfaces/command.js";
import { Handler } from "./interfaces/handlers.js";
import { QuickDB } from "quick.db";

export interface Ticket {
userId: string;
channelId: string;
}

export interface Bot {
client: Client;
commands: Collection<string, Command>;
handlers: Collection<string, Handler>;
tickets: QuickDB<Ticket>;
}

export const bot: Bot = {
client: new Client({
intents: [
"Guilds",
"GuildMembers",
"DirectMessages",
"GuildBans",
"GuildMessages",
"MessageContent",
],
}),
commands: new Collection(),
handlers: new Collection(),
tickets: new QuickDB().table<Ticket>("tickets"),
};
import { Client, Collection } from "discord.js";
import { Command } from "./interfaces/command.js";
import { Handler } from "./interfaces/handlers.js";
import { QuickDB } from "quick.db";

export interface Ticket {
userId: string;
channelId: string;
}

export interface Bot {
client: Client;
commands: Collection<string, Command>;
handlers: Collection<string, Handler>;
tickets: QuickDB<Ticket>;
}

export const bot: Bot = {
client: new Client({
intents: [
"Guilds",
"GuildMembers",
"DirectMessages",
"GuildBans",
"GuildMessages",
"MessageContent",
],
}),
commands: new Collection(),
handlers: new Collection(),
tickets: new QuickDB().table<Ticket>("tickets"),
};
index.ts
import { bot } from "./bot.js";
import { config } from "./config.js";
import { importDirectory } from "./utils/loader.js";

await importDirectory("./dist/commands");

await importDirectory("./dist/events");

await importDirectory("./dist/handlers");

const rest = new REST({ version: "10" }).setToken(config.token);

try {
console.log("Started refreshing application (/) commands.");

await rest.put(Routes.applicationCommands(atob(config.token.split(".")[0])), {
body: bot.commands.map((e) => e.data),
});

console.log("Successfully reloaded application (/) commands.");
} catch (error) {
console.error(error);
}

await bot.client.login(config.token);
import { bot } from "./bot.js";
import { config } from "./config.js";
import { importDirectory } from "./utils/loader.js";

await importDirectory("./dist/commands");

await importDirectory("./dist/events");

await importDirectory("./dist/handlers");

const rest = new REST({ version: "10" }).setToken(config.token);

try {
console.log("Started refreshing application (/) commands.");

await rest.put(Routes.applicationCommands(atob(config.token.split(".")[0])), {
body: bot.commands.map((e) => e.data),
});

console.log("Successfully reloaded application (/) commands.");
} catch (error) {
console.error(error);
}

await bot.client.login(config.token);
9 replies