SpicyJungle
SpicyJungle
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
Will be compiling all my bots from now on, never realized the performance difference was that different
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
Transpiled JS ran in just a few seconds and works perfectly, thanks so much for the help!!
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
Can I transpile the JS to a completely different directory, completely seperate from the typescript?
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
True, I didn't expect the transpiling to take this much computing. I'll give that a shot and if not i'll just upgrade
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
probably why the javascript bot works yeah
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
ok
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
well my tsConfig is only this so doubt it
{
"compilerOptions": {
"lib": ["ES2021"],
}
}
{
"compilerOptions": {
"lib": ["ES2021"],
}
}
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
Yup. Never done that before, do I just run tsc at the top level of the directory?
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
ts-node Bot.ts
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
Nope, just importing the listeners and exporting them as an array
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
Ready.ts
import { Listener } from "../utils/types/Listener"
import { Commands } from "../Commands"
import { Client, ActivityType, Guild } from "discord.js"

export const Ready: Listener = {
name: "ready",
once: true,
run: async (client: Client) => {
console.log(`Logged in as ${client.user?.tag}!`);
if (!client.user || !client.application) return console.log("Client user or application is undefined");
await client.application.commands.set(Commands);
}
}
import { Listener } from "../utils/types/Listener"
import { Commands } from "../Commands"
import { Client, ActivityType, Guild } from "discord.js"

export const Ready: Listener = {
name: "ready",
once: true,
run: async (client: Client) => {
console.log(`Logged in as ${client.user?.tag}!`);
if (!client.user || !client.application) return console.log("Client user or application is undefined");
await client.application.commands.set(Commands);
}
}
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
Correct. Only those two. InteractionCreate.ts
import { Listener } from "../utils/types/Listener"
import { Commands } from "../Commands"
import { Client, ActivityType, ChatInputCommandInteraction, GuildMember, BaseInteraction } from "discord.js"
import { Command } from "../utils/types/Command";

const checkPermissions = (command: Command, member: GuildMember) => {
for (const permission of command.permissions) {
if (!member.permissions.has(permission)) return false;
}
return true;
}

export const InteractionCreate: Listener = {
name: "interactionCreate",
once: false,
run: async (client: Client, interaction: BaseInteraction) => {
console.log(`Recieved interaction: ${interaction.type}`);

if (!(interaction.isCommand()) && !(interaction.isAutocomplete())) return;

const command: Command | undefined = Commands.find(command => command.name === interaction.commandName);
if (!command) return console.log(`Command ${interaction.commandName} not found`);
if (interaction.isAutocomplete()) {
if (!command.autocomplete) return;

try {
await command.autocomplete(client, interaction);
} catch (error) {
console.error(error);
}
return;
}
if (!checkPermissions(command, interaction.member as GuildMember)) return interaction.reply({ content: "You do not have permission to use this command!", ephemeral: true });
if (command.defer) await interaction.deferReply();
try {
await command.run(client, interaction);
} catch (error) {
console.error(error);
await interaction.followUp({ content: "There was an error while executing this command!", ephemeral: true });
}
}
}
import { Listener } from "../utils/types/Listener"
import { Commands } from "../Commands"
import { Client, ActivityType, ChatInputCommandInteraction, GuildMember, BaseInteraction } from "discord.js"
import { Command } from "../utils/types/Command";

const checkPermissions = (command: Command, member: GuildMember) => {
for (const permission of command.permissions) {
if (!member.permissions.has(permission)) return false;
}
return true;
}

export const InteractionCreate: Listener = {
name: "interactionCreate",
once: false,
run: async (client: Client, interaction: BaseInteraction) => {
console.log(`Recieved interaction: ${interaction.type}`);

if (!(interaction.isCommand()) && !(interaction.isAutocomplete())) return;

const command: Command | undefined = Commands.find(command => command.name === interaction.commandName);
if (!command) return console.log(`Command ${interaction.commandName} not found`);
if (interaction.isAutocomplete()) {
if (!command.autocomplete) return;

try {
await command.autocomplete(client, interaction);
} catch (error) {
console.error(error);
}
return;
}
if (!checkPermissions(command, interaction.member as GuildMember)) return interaction.reply({ content: "You do not have permission to use this command!", ephemeral: true });
if (command.defer) await interaction.deferReply();
try {
await command.run(client, interaction);
} catch (error) {
console.error(error);
await interaction.followUp({ content: "There was an error while executing this command!", ephemeral: true });
}
}
}
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
This is the entirety of the entry point:
import { Client, ClientOptions, GatewayIntentBits } from "discord.js";
import { config } from "dotenv";
config();
const clientOptions: ClientOptions = {
intents: [
GatewayIntentBits.Guilds,
],
};
const client = new Client(clientOptions);

import { Listeners } from "./Listeners";
for (const listener of Listeners) {
console.log(listener.name)
if (listener.once) {
client.once(listener.name, (...args) => listener.run(client, ...args));
} else {
client.on(listener.name, (...args) => listener.run(client, ...args));
}
}

//let guildCounter = 0;
//client
// .on("raw", (data)=>{
//if (data.t && data.t !== 'GUILD_CREATE') {
//console.log(data)
//} else {
//guildCounter = guildCounter +1
//console.log(guildCounter)
//}
//})
// .on("warn", console.log)
// .on("debug", console.log)
setTimeout(() => console.log(, 1000)
client.login(process.env.DISCORD_TOKEN);
import { Client, ClientOptions, GatewayIntentBits } from "discord.js";
import { config } from "dotenv";
config();
const clientOptions: ClientOptions = {
intents: [
GatewayIntentBits.Guilds,
],
};
const client = new Client(clientOptions);

import { Listeners } from "./Listeners";
for (const listener of Listeners) {
console.log(listener.name)
if (listener.once) {
client.once(listener.name, (...args) => listener.run(client, ...args));
} else {
client.on(listener.name, (...args) => listener.run(client, ...args));
}
}

//let guildCounter = 0;
//client
// .on("raw", (data)=>{
//if (data.t && data.t !== 'GUILD_CREATE') {
//console.log(data)
//} else {
//guildCounter = guildCounter +1
//console.log(guildCounter)
//}
//})
// .on("warn", console.log)
// .on("debug", console.log)
setTimeout(() => console.log(, 1000)
client.login(process.env.DISCORD_TOKEN);
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
This is all
"dependencies": {
"axios": "^1.4.0",
"cheerio": "^1.0.0-rc.12",
"discord.js": "^14.11.0",
"dotenv": "^16.3.1",
"fast-average-color-node": "^2.6.0",
"typescript": "^5.1.3"
}
"dependencies": {
"axios": "^1.4.0",
"cheerio": "^1.0.0-rc.12",
"discord.js": "^14.11.0",
"dotenv": "^16.3.1",
"fast-average-color-node": "^2.6.0",
"typescript": "^5.1.3"
}
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
hmm
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
wikibot3@1.0.0 /root/wikibot3
└─┬ discord.js@14.11.0
├─┬ @discordjs/ws@0.8.3
│ └── ws@8.13.0 deduped
└── ws@8.13.0
wikibot3@1.0.0 /root/wikibot3
└─┬ discord.js@14.11.0
├─┬ @discordjs/ws@0.8.3
│ └── ws@8.13.0 deduped
└── ws@8.13.0
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
very lame, just []
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
[ 'shardDisconnect', 'ready', 'interactionCreate' ]
41 replies
DIAdiscord.js - Imagine an app
Created by SpicyJungle on 7/2/2023 in #djs-questions
Not recieving heartbeats, killed after ~50 seconds, zombie connection, do recieve guildCreate event
beofre or after client.login?
41 replies