Kay
Kay
Explore posts from servers
DIAdiscord.js - Imagine a bot
Created by Kay on 6/29/2024 in #djs-questions
Cannot use 'in' operator to search for 'code' in undefined
When running my bot it sometimes returns this error and exists
error: Uncaught TypeError: Cannot use 'in' operator to search for 'code' in undefined
at WebSocketShard.onError (file:///deno-dir/npm/registry.npmjs.org/@discordjs/ws/1.1.1/dist/index.js:1065:16)
at WebSocket.connection.onerror (file:///deno-dir/npm/registry.npmjs.org/@discordjs/ws/1.1.1/dist/index.js:683:12)
at WebSocket.wrappedHandler (ext:deno_web/02_event.js:1401:12)
at innerInvokeEventListeners (ext:deno_web/02_event.js:754:7)
at invokeEventListeners (ext:deno_web/02_event.js:801:5)
at dispatch (ext:deno_web/02_event.js:658:9)
at WebSocket.dispatchEvent (ext:deno_web/02_event.js:1043:12)
at WebSocket.[[[eventLoop]]] (ext:deno_websocket/01_websocket.js:481:16)
at eventLoopTick (ext:core/01_core.js:168:7)
error: Uncaught TypeError: Cannot use 'in' operator to search for 'code' in undefined
at WebSocketShard.onError (file:///deno-dir/npm/registry.npmjs.org/@discordjs/ws/1.1.1/dist/index.js:1065:16)
at WebSocket.connection.onerror (file:///deno-dir/npm/registry.npmjs.org/@discordjs/ws/1.1.1/dist/index.js:683:12)
at WebSocket.wrappedHandler (ext:deno_web/02_event.js:1401:12)
at innerInvokeEventListeners (ext:deno_web/02_event.js:754:7)
at invokeEventListeners (ext:deno_web/02_event.js:801:5)
at dispatch (ext:deno_web/02_event.js:658:9)
at WebSocket.dispatchEvent (ext:deno_web/02_event.js:1043:12)
at WebSocket.[[[eventLoop]]] (ext:deno_websocket/01_websocket.js:481:16)
at eventLoopTick (ext:core/01_core.js:168:7)
I am running the bot in a deno docker container. Bot code:
import { Client, Events, GuildMember } from "discord";

const client = new Client({
// Numbers since the GatewayIntentBits import does not work in deno for some reason
intents: [
1,
2,
4,
512,
1024,
4096,
32768,
16777216,
33554432
]
});

client.on(Events.GuildMemberAdd, (member: GuildMember) => {
member.roles.add("1205218206155935754", "Join role");
});

client.login(Deno.env.get("TOKEN"));
import { Client, Events, GuildMember } from "discord";

const client = new Client({
// Numbers since the GatewayIntentBits import does not work in deno for some reason
intents: [
1,
2,
4,
512,
1024,
4096,
32768,
16777216,
33554432
]
});

client.on(Events.GuildMemberAdd, (member: GuildMember) => {
member.roles.add("1205218206155935754", "Join role");
});

client.login(Deno.env.get("TOKEN"));
4 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 5/22/2024 in #djs-questions
Invalid protocol value
getting this error
error: Uncaught (in promise) SyntaxError: Invalid protocol value.
at new WebSocket (ext:deno_websocket/01_websocket.js:203:13)
at WebSocketShard.internalConnect (file:///C:/Users/user/AppData/Local/deno/npm/registry.npmjs.org/@discordjs/ws/1.1.0/dist/index.js:675:24)
at eventLoopTick (ext:core/01_core.js:168:7)
error: Uncaught (in promise) SyntaxError: Invalid protocol value.
at new WebSocket (ext:deno_websocket/01_websocket.js:203:13)
at WebSocketShard.internalConnect (file:///C:/Users/user/AppData/Local/deno/npm/registry.npmjs.org/@discordjs/ws/1.1.0/dist/index.js:675:24)
at eventLoopTick (ext:core/01_core.js:168:7)
i tried resetting my token and removing the intents and that didnt fix it
2 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 12/21/2023 in #djs-questions
Cannot get params from url
@space ❄ (tagging u cous this is followup of my previous question which i closed and cant open anymore) so this is my code:
const params = new URL(req.url).searchParams
const [accessToken, tokenType] = [params.get('access_token'), params.get('token_type')];
console.log(accessToken, tokenType)
const params = new URL(req.url).searchParams
const [accessToken, tokenType] = [params.get('access_token'), params.get('token_type')];
console.log(accessToken, tokenType)
but this just logs null null this is the oauth2 url from discord https://discord.com/oauth2/authorize?client_id=1116352238667960392&response_type=token&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2Fauth&scope=identify
7 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 12/21/2023 in #djs-questions
Oauth2 category of discordjs.guide not up to date. need help with new stuff
No description
7 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 11/7/2023 in #djs-questions
GuildAuditLogEntryCreate does not provide a guild
in the documentation it says that the GuildAuditLogEntryCreate event a guild provides. but it seems to always be undefined the guildAuditLogsEntry does exist but i cant seem to get a guild value from that somehow https://old.discordjs.dev/#/docs/discord.js/main/class/Client?scrollTo=e-guildAuditLogEntryCreate
13 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 10/30/2023 in #djs-questions
get all mesages after a specific time
Im making a purge command but when i try to delete messages it says it can only delete messages that are younger than 14 days. so i made a date object and made it so the date was 14 days before the current date but it seems that the fetch function needs a snowflake, so how do i convert my date to a snowflake code:
const date = new Date();
date.setDate(date.getDate() - 14);
const fetched = await interaction.channel.messages.fetch({limit: amount});
interaction.channel.bulkDelete(fetched);
const date = new Date();
date.setDate(date.getDate() - 14);
const fetched = await interaction.channel.messages.fetch({limit: amount});
interaction.channel.bulkDelete(fetched);
4 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 9/25/2023 in #djs-questions
AutoModerationActionExecution does not trigger
When someone says a blacklisted word it gets deleted by autoMod but the event does not trigger. code:
import DiscordClient from "../utils/client.ts";
import Event from "../utils/structures/Event.ts"
import { AutoModerationAction, Events, Message } from "npm:discord.js";

export default class InteractionCreateEvent extends Event {

constructor() {
super(Events.AutoModerationActionExecution, false);
}

async execute(_client: DiscordClient, ...entries: any[]): Promise<void> {

console.log(entries) //not sure what the args are so just do this to find out

return;
}

}
import DiscordClient from "../utils/client.ts";
import Event from "../utils/structures/Event.ts"
import { AutoModerationAction, Events, Message } from "npm:discord.js";

export default class InteractionCreateEvent extends Event {

constructor() {
super(Events.AutoModerationActionExecution, false);
}

async execute(_client: DiscordClient, ...entries: any[]): Promise<void> {

console.log(entries) //not sure what the args are so just do this to find out

return;
}

}
7 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 9/16/2023 in #djs-questions
DiscordAPIError[50007]: Cannot send messages to this user
So i made a bot that reads messages and deletes them when there is a specific word in them. and after that i want to send the author a message in their dms. but i keep getting DiscordAPIError[50007]: Cannot send messages to this user. and sometimes it works, and sometimes it dosnt. and when it dosnt work i still get a notification and the bot shows up in my dms, i just dont see any messages. this could be a discord bug but it also gave my bot an error so i tought id ask here
4 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 9/14/2023 in #djs-questions
Says that interaction.isChatInputCommand is not a function
so this is my code
import DiscordClient from "../utils/client.ts";
import Event from "../utils/structures/Event.ts"
import { Events, Interaction } from "npm:discord.js";

export default class InteractionCreateEvent extends Event {

constructor() {
super(Events.InteractionCreate, false);
}

async execute(client: DiscordClient, interaction: Interaction): Promise<void> {

if (interaction.isChatInputCommand()) {

const command = client.commands.get(interaction.commandName);

if (!command) {
return;
}

try {
command.execute(client, interaction)
} catch (error) {
console.log(error)
}

}

}

}
import DiscordClient from "../utils/client.ts";
import Event from "../utils/structures/Event.ts"
import { Events, Interaction } from "npm:discord.js";

export default class InteractionCreateEvent extends Event {

constructor() {
super(Events.InteractionCreate, false);
}

async execute(client: DiscordClient, interaction: Interaction): Promise<void> {

if (interaction.isChatInputCommand()) {

const command = client.commands.get(interaction.commandName);

if (!command) {
return;
}

try {
command.execute(client, interaction)
} catch (error) {
console.log(error)
}

}

}

}
and when i run a command it gives this error
error: Uncaught (in promise) TypeError: interaction.isChatInputCommand is not a function
if (interaction.isChatInputCommand()) {
error: Uncaught (in promise) TypeError: interaction.isChatInputCommand is not a function
if (interaction.isChatInputCommand()) {
this is how my events are registerd. if it helps
async events(): Promise<void> {
for (const entry of walkSync(this.client.root + "\\src\\events", {includeDirs: false, exts: [".ts"]})) {
const file = await import("file://" + entry.path);
const event: Event = new file.default();
if (event.once == true) this.client.once(event.event, (...args: any[]) => {event.execute(this.client, args)});
else this.client.on(event.event, (...args: any[]) => {event.execute(this.client, args)});
}
}
async events(): Promise<void> {
for (const entry of walkSync(this.client.root + "\\src\\events", {includeDirs: false, exts: [".ts"]})) {
const file = await import("file://" + entry.path);
const event: Event = new file.default();
if (event.once == true) this.client.once(event.event, (...args: any[]) => {event.execute(this.client, args)});
else this.client.on(event.event, (...args: any[]) => {event.execute(this.client, args)});
}
}
the event class is just a simple abstract class with some values like the type of event called event and if its run once like for the ready event called once
13 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 2/18/2023 in #djs-questions
Set forum defaultReactionEmoji
how would i set the defaultReactionEmoji for a forum channel? i want to use this emoji 🛒 but i cant get it to work.
3 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 1/30/2023 in #djs-questions
Does discordjs support mjs?
Does discordjs support module js?
4 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 11/17/2022 in #djs-questions
Difrent data with sharding?
if i would get the total guild count with sharding, would i get a total of the guilds using that shard or the total guilds
10 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 11/17/2022 in #djs-questions
Automod events
Are there any automod events and what are they? i want to create a system where if you get automodded you get a warning
4 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 11/3/2022 in #djs-questions
get message from Context menu
How do i get the message from a Message Context menu? if i log the interaction i dont see anything related to the message (or im just not looking good enough) i only see the target id
10 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 11/3/2022 in #djs-questions
How to register Context Menus
How would i register a context menu?
6 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 10/24/2022 in #djs-questions
Specific profile for specific guild?
Is it possible to set a custom profile picture for a specific guild like i can with discord nitro?
8 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 8/7/2022 in #djs-questions
how do i detect if an interacion is a button?
Im creating seperate handlers for buttons, modals, etc. but how do i detect if an interaction is a button in discordjsV14
7 replies
DIAdiscord.js - Imagine a bot
Created by Kay on 7/31/2022 in #djs-questions
Wierd error whilst sending a modal
when i try to send a modal it gives an error Code: https://pastebin.com/0XWEjbBV Error: https://pastebin.com/0eiC7Ew3
6 replies