#development
1 messages · Page 248 of 1
powershell is weird af
such a convoluted overengineered and overcomplicated scripting syntax
if only windows adopted bash like everything else
"nah, lets make a .NET shell instead"
never google "how to send post request with body on powershell"
worst mistake of my life
who doesn't love a terminal withPascalKebab-Case keywords and a horrible syntax

its like they're trying to make a terminal for php users
"stats" and "analytics" are different words
analytics are still stats
no
is there a way to figure out what server the errors are coming from?
not quite unless u add loggers for that
tho it's usually useless to know which server it is, knowing where in the code is more useful
ur supposed to handle errors and tell the user it errored and why
For some errors, the url contains the server ID iirc
analytics is stats but it's recorded in time

How could i fix the unknown interaction?
It depends, in most cases such an error is the result of the bot needing more than 3 seconds to respond
So you either need to opTIMize the code or try to defer the interaction which gives you 15 minutes to respond
as a rule of thumb if you're doing anything but sending a simple text reply you should defer
lag spikes happen, discord aint perfectly stable
sanity check
is it against discord tos to download all media sent in a specific server, and to not delete said media locally if the originating message was deleted
it is against the tos if there is no time limit
they require you to specify for how long you store that data
So if it would automatically delete after 30 days it's fine?
and ive seen them demand people not to store it for over 30 days regardless
should be fine ye
huhm
https://hastebin.skyra.pw/dasalitufe.csharp what you guys think of this C# code?
What im trying to do is
- Grab commit history from facepunch commits
- Post only the most recent commits based off the last commit we've sent to a discord channel
- Make sure no duplicates get sent
- Make sure it gets sent in order (This part is tricky because of the timer we set)
no
shut it
maynnn what dis
i just updated my node yesterday., i restarted and then boom my mac fucks me again
how did you install it?
ahh gotta restart prolly
nvm installer, also added it to my path
prolly need to restart one sec
ah then probably rrestart ye
most productive mac development experience
"macs are the best for code"
yeah it is unix based but a linux based system is still on top
at least Windows©®™ puts linux into a virtual machine
i thought that was a neat option
never have i thought mac would let you dual boot into windows on your mac let alone have an entire utility for it
wsl is pretty cool
too bad the partition was cursed with zig
windows allows you to install on any hardware. im sure apple would ban dual booting if they could
K&R vs Allman, the eternal fight
fyi, apple made an app called "Bootcamp" for dual booting with windows 
but that's only possible with non m series mac
that's so nice of apple to do. why doesn't windows make an app that allows dual booting macos...
yep
few latest macos versions can't even support Intel hd graphics because they don't use Intel graphics anymore, instead almost every AMD graphics can use hackintosh
and Intel graphics that's based on xe graphics don't support every versions
the latest Nvidia graphics it can support is 1050 afaik
they dont bother making drivers for devices they dont support
also doesnt help that intel/nvidia internals are not open source, so devs cant easily make custom drivers for them
There are the open source nv drivers
yeah that's fair enough
most prob for older GPUs? idk about driver development
Nah they're primarily found on Linux but Linux is Unix so
Otherwise Linux people wouldnt be able to use their gpus
there are some generic drivers that work for many devices, but are not able to access/use all of the devices features and capabilities
some specific devices have better drivers, others dont
ooooo
it takes a lot of reverse engineering a specific device to make it work correctly in an unsupported system
so you have lists of specific devices that work well, work partially or dont work at all in things like hackintosh
depending on how much time someone invested on a specific device on a specific system
in case of nvidia specifically, apple makes official nvidia drivers for them, but only for the specific gpus they use in their machines, unlike windows drivers that work for all gpus.
if the gpu you have is not in the list of supported drivers, it may not work, or many need additional tweaks
😔
Apple does also block certain devices from being installed iirc
certain hardware?
on their own machines yes, if its not a verified device, they will try to block it
but on non-apple machines they cant block anything, it will either work or not work depending on driver compatibility
serialization 
fun fact
if you do your research and assemble a fully compatible machine, you can have a hackintosh that is both cheaper and much faster than a regular apple machine
:^)
same with laptops, there are people who maintain a lists of the best laptops to make a hackintosh with, depending on its components
if you get a fully compatible non-apple laptop, you can turn it into a better version of a mac, for cheaper
yeah, get AMD CPU and GPU
This is starting to get more difficult though since the m series chips are starting to defeat x86 based chips in most tasks
yeah its a new architecture, so a lot of things changed
isn't it just arm
It is ARM/RISC
is it RISC?
But when compared to other ARM chips like snapdragons meant for laptops, the performance gap is quite large
doesn't it have a bunck of extra stuff
if apple fully deprecates intel and makes m-only OSx versions, then it will be more difficult to make hachintoshes
For sure
sup gaymers
but there are still ARM chips but it's common to find them soldered
but for now i believe all macos versions are dual-arch
windows is making arm versions soon
Theres also Windows for ARM
ye
Thats already a thing
intel keeps getting bad news
arm is coming to non-apple laptops more and more
but such a large architecgture shift will take a long time
a lot of compatibility layers will be required to even attempt making such a transition
aren't chromebooks arm laptops?
nobody would want to buy an arm windows laptop if it cant run your usual windows apps that only work on x86
ye, and they cant run windows apps
yeah, games will be a big problem too
m$ will need to design some very powerful compatibility layer, like apple did with rosetta
until they do that, they cant really enter the arm market
if they try to sell arm windows without it, people will not understand why xyz app that works on other windowses doesnt work on this windows
a lot will be up to Unreal Engine
lot of optimizations in games are written in ASM or do tricky x86 stuff.
they should switch from c++ to zig so it's easier to write cross platform code.
so do snapdragon right?
it's too new to use
windows already has an emulation layer for x86
and also box86/64 exists for linux
for the most part chromebooks are still x86
not sure if there even is a variant of chromeos that supports arm
arent most cheap chromebooks arm
literally cant find a chromebook laptop that runs arm
online there also isnt anywhere that says chromeos supports arm
but it would make sense for google to make an arm variant, theres lots of potential for battery saving and efficiency and cost saving
the amount of apps the chromebook can run is limited anyways and most things are maintained by google, chromeos runs on Linux and linux already has an arm variant
is there a guide to create event command like
guildcreate
guildremove
memberadd
memberremove?
Depends on what you mean by "guide". I think the documentation for the wrapper you are using has all the information you need
i have try to make one but it dont notify at all
Remember that you must have the appropriate intents activated in your code to receive such events
For example
can i send the code here? because what i done it give double log
i just want to make it show one time
Sure, remember to remove any token/api key
ok
require('dotenv').config(); // Load environment variables from .env file
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
// Replace with your actual channel ID
const LOG_CHANNEL_ID = 'channelid';
// Event handler for when the bot joins a new guild
client.on('guildCreate', async (guild) => {
try {
// Fetch the log channel
const channel = await client.channels.fetch(LOG_CHANNEL_ID);
if (channel) {
// Send a message to the log channel
await channel.send(`I have joined the server \`${guild.name}\``);
} else {
console.error(`Channel with ID ${LOG_CHANNEL_ID} not found.`);
}
} catch (error) {
console.error('Error handling guildCreate event:', error);
}
});
// Event handler for when the bot is removed from a guild
client.on('guildDelete', async (guild) => {
try {
// Fetch the log channel
const channel = await client.channels.fetch(LOG_CHANNEL_ID);
if (channel) {
// Send a message to the log channel
await channel.send(`I have been removed from the server \`${guild.name}\``);
} else {
console.error(`Channel with ID ${LOG_CHANNEL_ID} not found.`);
}
} catch (error) {
console.error('Error handling guildDelete event:', error);
}
});
// Log in to Discord with your app's token from environment variable
client.login(process.env.BOT_TOKEN);
require('dotenv').config(); // Load environment variables from .env file
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
// Replace with your actual channel ID
const LOG_CHANNEL_ID = 'channelid';
// Event handler for when the bot joins a new guild
client.on('guildCreate', async (guild) => {
try {
// Fetch the log channel
const channel = await client.channels.fetch(LOG_CHANNEL_ID);
if (channel) {
// Send a message to the log channel
await channel.send(`I have joined the server \`${guild.name}\``);
} else {
console.error(`Channel with ID ${LOG_CHANNEL_ID} not found.`);
}
} catch (error) {
console.error('Error handling guildCreate event:', error);
}
});
// Event handler for when the bot is removed from a guild
client.on('guildDelete', async (guild) => {
try {
// Fetch the log channel
const channel = await client.channels.fetch(LOG_CHANNEL_ID);
if (channel) {
// Send a message to the log channel
await channel.send(`I have been removed from the server \`${guild.name}\``);
} else {
console.error(`Channel with ID ${LOG_CHANNEL_ID} not found.`);
}
} catch (error) {
console.error('Error handling guildDelete event:', error);
}
});
// Log in to Discord with your app's token from environment variable
client.login(process.env.BOT_TOKEN);
this 2
i send out like this
even when i do try to kick the bot also show 2 time
both bot are driffent token
Are the codes you sent two separate files?
Events work in such a way that each of these files/listeners will receive its own event, so the code will be executed twice (because there are two listeners that listen to the same event)
so how could i fix it?
In Guildcreate.js you want to have only one listener which is GuildCreate and similarly in GuildDelete.js you want to have only one listener which is GuildDelete
here?
Yep
Just remove the GuildDelete listener from the Guildcreate.js file and the GuildCreate listener from the GuildDelete.js file
still double
require('dotenv').config(); // Load environment variables from .env file
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
});
// Replace with your actual channel ID
const LOG_CHANNEL_ID = 'XXXX';
// Event handler for when the bot joins a new guild
client.on('guildCreate', async (guild) => {
try {
// Fetch the log channel
const channel = await client.channels.fetch(LOG_CHANNEL_ID);
if (channel) {
// Send a message to the log channel
await channel.send(`I have joined the server \`${guild.name}\``);
} else {
console.error(`Channel with ID ${LOG_CHANNEL_ID} not found.`);
}
} catch (error) {
console.error('Error handling guildCreate event:', error);
}
});
// Log in to Discord with your app's token from environment variable
client.login(process.env.BOT_TOKEN);
The file was saved and the bot was restarted?
Bots name is fortunes
Logs say fortunes development
huh?
oh because
someone ask
No I mean there's 2 different bots apparently
yes
Or is the screenshot here a renamed bot
Changing it on one won't change it on the other though
wdym
i use the same structure with the fortune
i just use the dev for testing new code
then only upload on to the host
but i want to make the guild log
so i know which server add my bot in that all
Your logs mention a different bot than what the bot on the screenshot is
This here
Is not what is mentioned here in the logs
?
there is no point to read the log
did i ask to help and see the log? i dont think so
rude
she go and look and my log
Forget it then
i just need help to know why it react double
Just saying there appears to be 2 different bots while your logs show a different one
it's cuz usually when someone posts an image here containing a log it's related to the bot in question, you could've just said the log is unrelated
i told above
i already say
1 of the member ask that i run double bot or not then i capture
forget it then i just want a help
you need to be more polite, but well, are you 100% sure it isn't running 2 instances?
if you remove the guildCreate event does it stop sending the message?
My thinking is:
You're assuming you're working on the production bot while you've fixed the issue on your development bot, trying to start the development bot and trying it out on your production bot, expecting it to be fixed
that's a possibility too
So first my English is like this
And I don't speak English I speak Thai
So yea sorry
Yes
wait you said you have 2 different files, guildcreate and guildDelete right?
Yea
then the issue is the last line in the code u sent here
1 is fortune and 1 is the dev version
you're logging-in your bot in the guildcreate file
this line should only be called once per project
so if u already call it on index, you shouldn't call anywhere else
I want to know how usually the event structure?
They are not like command file right
well, it depends on how you want to structure it
usually you simply pass the client instance from index to other files through function parameters
or make it a global variable
idk if d.js reuses the same client when importing, if it does then that works too
Oh
all in all it's up to you how you structure your files
but client.login() should only ever be called once, as everytime you call it you start a new instance
which is why you're getting twice as many logs, because there're twice as many instances
you can call login multiple times, djs wont let it happen on the same instance, what creates new instances is new Client()
but yeah, just semantics
oh, weird
so i just remove new client?
do you have an index.js file or a main file?
Yes
this 2 was in an event folder
you put new Client() and client.login() in your index.js file
and remove them from all other files
require('dotenv').config(); // Load environment variables from .env file
const { Client, GatewayIntentBits } = require('discord.js');
const client = {
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
};
// Replace with your actual channel ID
const LOG_CHANNEL_ID = 'xxx';
// Instantiate the client
const client = Client(clientConfig);
// Event handler for when the bot is removed from a guild
client.on('guildDelete', async (guild) => {
try {
// Fetch the log channel
const channel = await client.channels.fetch(LOG_CHANNEL_ID);
if (channel) {
// Send a message to the log channel
await channel.send(`I have been removed from the server \`${guild.name}\``);
} else {
console.error(`Channel with ID ${LOG_CHANNEL_ID} not found.`);
}
} catch (error) {
console.error('Error handling guildDelete event:', error);
}
});
// Event handler for when the bot joins a new guild
client.on('guildCreate', async (guild) => {
try {
// Fetch the log channel
const channel = await client.channels.fetch(LOG_CHANNEL_ID);
if (channel) {
// Send a message to the log channel
await channel.send(`I have joined the server \`${guild.name}\``);
} else {
console.error(`Channel with ID ${LOG_CHANNEL_ID} not found.`);
}
} catch (error) {
console.error('Error handling guildCreate event:', error);
}
});
// Log in to Discord with your app's token from environment variable
client.login(process.env.BOT_TOKEN);
like this?
no
like this
// guildCreate.js
module.exports = (client) => {
client.on("guildCreate", async guild => {
...
})
}
// guildDelete.js
module.exports = (client) => {
client.on("guildDelete", async guild => {
...
})
}
and remove client.login and require(discord), and Client and dotenv and everything
does the type you give work with other event also?
like guildmemberadd
yes
in your index.js you have fs.readdirSync("./src/handlers").forEach(handler => require(...)(client))
that will load all files you have in the handlers folder, and send the client to them
sure, its the same thing tho
you dont need this if you already load them dynamically
also remove this, you dont need it
require('dotenv').config();
const fs = require('fs');
const { Client, GatewayIntentBits, Collection, PermissionsBitField } = require('discord.js');
const { Routes } = require('discord-api-types/v9');
const { REST } = require('@discordjs/rest');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
});
// Initialize collections
client.commands = new Collection();
client.buttons = new Collection();
client.embeds = require('./data/config/embeds');
client.e = require('./data/config/emotes');
client.c = require('./data/config/colors');
// Load events
fs.readdirSync('./src/events').filter((file) => file.endsWith('.js')).forEach((event) => {
require(`./src/events/${event}`)(client);
});
console.log(`Client - Events loaded`);
// Register commands
const registerCommands = async () => {
const commands = [];
const guildId = process.env.GUILD_ID; // Add your server (guild) ID here
const rest = new REST({ version: '9' }).setToken(process.env.BOT_TOKEN);
try {
// Read commands directory
const commandDirs = await fs.promises.readdir('./src/commands');
// Process each directory concurrently
await Promise.all(commandDirs.map(async (dir) => {
const cmdFiles = await fs.promises.readdir(`./src/commands/${dir}`);
const jsFiles = cmdFiles.filter(file => file.endsWith('.js'));
// Process each command file concurrently
await Promise.all(jsFiles.map(async (file) => {
const cmd = require(`./src/commands/${dir}/${file}`);
commands.push({
name: cmd.name,
description: cmd.description,
type: cmd.type,
options: cmd.options ? cmd.options : null,
default_permission: cmd.default_permission ? cmd.default_permission : null,
default_member_permissions: cmd.default_member_permissions ? PermissionsBitField.resolve(cmd.default_member_permissions).toString() : null
});
if (cmd.name) {
client.commands.set(cmd.name, cmd);
} else {
console.log(`Client - Failed to load ${file.split('.js')[0]}`);
}
}));
}));
// Register commands for a specific guild
await rest.put(
Routes.applicationGuildCommands(process.env.BOT_ID, guildId),
{ body: commands }
);
console.log('Client - Registered commands for the guild');
} catch (e) {
console.error('Client - Failed to register application (/) commands', e);
}
};
// Execute command registration
registerCommands();
// Log in to Discord with your app's token from environment variable
client.login(process.env.BOT_TOKEN);
like this?
sure, that should work
do you have a src folder?
where is index.js?
in the src
then remove src from path
./ means "this folder", if index.js is inside src, then ./ is src already
require('dotenv').config();
const fs = require('fs');
const { Client, GatewayIntentBits, Collection, PermissionsBitField } = require('discord.js');
const { Routes } = require('discord-api-types/v9');
const { REST } = require('@discordjs/rest');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
]
});
// Initialize collections
client.commands = new Collection();
client.buttons = new Collection();
// Load events
fs.readdirSync('./events').filter((file) => file.endsWith('.js')).forEach((event) => {
require(`./events/${event}`)(client);
});
console.log(`Client - Events loaded`);
// Register commands
const registerCommands = async () => {
const commands = [];
const guildId = process.env.GUILD_ID; // Add your server (guild) ID here
const rest = new REST({ version: '9' }).setToken(process.env.BOT_TOKEN);
try {
// Read commands directory
const commandDirs = await fs.promises.readdir('./commands');
// Process each directory concurrently
await Promise.all(commandDirs.map(async (dir) => {
const cmdFiles = await fs.promises.readdir(`./commands/${dir}`);
const jsFiles = cmdFiles.filter(file => file.endsWith('.js'));
// Process each command file concurrently
await Promise.all(jsFiles.map(async (file) => {
const cmd = require(`./commands/${dir}/${file}`);
commands.push({
name: cmd.name,
description: cmd.description,
type: cmd.type,
options: cmd.options ? cmd.options : null,
default_permission: cmd.default_permission ? cmd.default_permission : null,
default_member_permissions: cmd.default_member_permissions ? PermissionsBitField.resolve(cmd.default_member_permissions).toString() : null
});
if (cmd.name) {
client.commands.set(cmd.name, cmd);
} else {
console.log(`Client - Failed to load ${file.split('.js')[0]}`);
}
}));
}));
// Register commands for a specific guild
await rest.put(
Routes.applicationGuildCommands(process.env.BOT_ID, guildId),
{ body: commands }
);
console.log('Client - Registered commands for the guild');
} catch (e) {
console.error('Client - Failed to register application (/) commands', e);
}
};
// Execute command registration
registerCommands();
// Log in to Discord with your app's token from environment variable
client.login(process.env.BOT_TOKEN);
how do you start the bot?
node .
node index.js? or node ./src/index.js?
in package.json you have "main": "./src/index.js"?
"main": "./src/index.js",
ok
this
the problem is require and fs use paths differently
require is based on where the file is
fs is based on where node is started from
so for fs you need the path based on where you run node from, if you run it from outside the src folder, then you need to have the src in the path
ok
you can use special variables like __dirname and process.cwd() if you want a fixed path system
process.cwd() is the path where node runs from
__dirname is the path of the current file
now it react another
Failed to load event ready.js: TypeError: client.on is not a function
can i put the ready in the index?
or not recommand?
sure you can, but that error should not be happening, did you put ready.js inside events folder?
ya
and you have ```js
require(./events/${event})(client);
// Load events
const eventsPath = path.resolve(__dirname, 'events');
if (fs.existsSync(eventsPath)) {
fs.readdir(eventsPath, (err, files) => {
if (err) {
console.error('Error reading events directory:', err);
return;
}
files.filter(file => file.endsWith('.js')).forEach(file => {
try {
require(path.join(eventsPath, file))(client);
} catch (error) {
console.error(`Failed to load event ${file}:`, error);
}
});
console.log('Client - Events loaded');
});
} else {
console.error(`Events directory not found at path: ${eventsPath}`);
}
this is in index.js right?
ya
and its after client = new Client() ?
yes
and in ready.js you have module.exports = (client) => { client.on("ready", ...) } ?
const { ActivityType } = require('discord.js');
const fs = require('fs');
const path = require('path');
module.exports = (client) => {
// Log the restart timestamp
const restartFilePath = path.join(__dirname, '..', 'lastRestart.txt');
function logRestartTimestamp() {
const now = new Date().toISOString();
fs.writeFileSync(restartFilePath, `Last Restart: ${now}\n`);
}
client.on('ready', async () => {
console.log(`Client - Logged in as ${client.user.tag}`);
// Log restart timestamp
logRestartTimestamp();
// Set custom status and set to Do Not Disturb
await client.user.setStatus('dnd');
await client.user.setActivity('This bot is for developing purpose', { type: ActivityType.Custom });
});
};
then it should work
show full index.js
hmm i dont see a reason for why its not working, but try using readdirSync instead of readdir
maybe because of
const { Collection, PermissionBitField } = require('discord.js');
const ms = require('ms');
const client = require('..');
const cooldowns = new Collection();
client.on('interactionCreate', async interaction => {
const command = client.commands.get(interaction.commandName);
if (interaction.type == 4 && command.autocomplete) {
const choices = [];
await command.autocomplete(interaction, choices);
}
if (!interaction.type == 2) return;
if (!command) return client.commands.delete(interaction.commandName);
try {
if (command.cooldown) {
if (cooldowns.has(`${command.name}-${interaction.user.id}`)) {
let duration = ms(cooldowns.get(`${command.name}-${interaction.user.id}`) - Date.now(), { long: true });
return interaction.reply(client.embeds.cooldown(duration));
}
if (command.userPerms || command.botPerms) {
if (!interaction.memberPermissions.has(PermissionBitField.resolve(command.userPerms || []))) return interaction.reply(client.embeds.fail(`You don't have \`${command.userPerms}\` permissions.`));
if (!interaction.guild.members.cache.get(client.user.id).permissions.has(PermissionBitField.resolve(command.botPerms || []))) return interaction.reply(client.embeds.fail(`I don't have \`${command.botPerms}\` permissions.`));
}
await command.run(client, interaction);
cooldowns.set(`${command.name}-${interaction.user.id}`, Date.now() + command.cooldown);
setTimeout(() => {
cooldowns.delete(`${command.name}-${interaction.user.id}`);
}, command.cooldown);
} else {
if (command.userPerms || command.botPerms) {
if (!interaction.memberPermissions.has(PermissionBitField.resolve(command.userPerms || []))) return interaction.reply(client.embeds.fail(`You don't have \`${command.userPerms}\` permissions.`));
if (!interaction.guild.members.cache.get(client.user.id).permissions.has(PermissionBitField.resolve(command.botPerms || []))) return interaction.reply(client.embeds.fail(`I don't have \`${command.botPerms}\` permissions.`));
}
await command.run(client, interaction);
}
} catch (e) {
console.log(e);
return interaction.reply(client.embeds.error);
}
});```
this one are not the same maybe
ah
you cant use const client = require('..');
you need to use module.exports = client => { client.on() }
and not duplicated anymore?
good
why was it duplocated?
yea
because you had multiple clients
each new Client() is a separate bot
you had new Client() in index.js and also in events
in your command registration
use Routes.applicationCommands instead of Routes.applicationGuildCommands
Routes.applicationCommands(clientId)
you mean here?
// Register commands
const registerCommands = async () => {
const commands = [];
const guildId = process.env.GUILD_ID; // Ensure this is set correctly in your .env
const rest = new REST({ version: '9' }).setToken(process.env.BOT_TOKEN);
try {
const commandsPath = path.resolve(__dirname, 'commands');
// Check if commands directory exists
if (!fs.existsSync(commandsPath)) {
console.error(`Commands directory not found at path: ${commandsPath}`);
return;
}
// Read commands directory
const commandDirs = await fs.promises.readdir(commandsPath);
// Process each directory concurrently
await Promise.all(commandDirs.map(async (dir) => {
const dirPath = path.join(commandsPath, dir);
const cmdFiles = await fs.promises.readdir(dirPath);
const jsFiles = cmdFiles.filter(file => file.endsWith('.js'));
// Process each command file concurrently
await Promise.all(jsFiles.map(async (file) => {
try {
const cmd = require(path.join(dirPath, file));
commands.push({
name: cmd.name,
description: cmd.description,
type: cmd.type,
options: cmd.options || null,
default_permission: cmd.default_permission || null,
default_member_permissions: cmd.default_member_permissions
? PermissionsBitField.resolve(cmd.default_member_permissions).toString()
: null
});
if (cmd.name) {
client.commands.set(cmd.name, cmd);
} else {
console.log(`Client - Failed to load ${file.split('.js')[0]}`);
}
} catch (error) {
console.error(`Failed to process command file ${file}:`, error);
}
}));
}));
// Register commands for a specific guild
await rest.put(
Routes.applicationCommands(clientId)(process.env.BOT_ID, guildId),
{ body: commands }
);
console.log('Client - Registered commands for the guild');
} catch (e) {
console.error('Client - Failed to register application (/) commands', e);
}
};```
uh what are you awaiting in the second Promise.all
hm?
why you use promise and async when none of the code isn't using await
so remove?
just use for loop for that
for the promise and async?
for (let file of jsFiles) {
// rest of your code
}
ohh
just my opinion, I think you don't really need to use promises await fs.promises.readdir(commandsPath); unless you're loading tons of files. since it'll be running only once and/or won't run every time, you can stick with the synchronous one
for (const file of jsFiles) {
try {
const cmd = require(path.join(dirPath, file));
commands.push({
name: cmd.name,
description: cmd.description,
type: cmd.type,
options: cmd.options || null,
default_permission: cmd.default_permission || null,
default_member_permissions: cmd.default_member_permissions
? PermissionsBitField.resolve(cmd.default_member_permissions).toString()
: null
});
if (cmd.name) {
client.commands.set(cmd.name, cmd);
} else {
console.log(`Client - Failed to load ${file.split('.js')[0]}`);
}
} catch (error) {
console.error(`Failed to process command file ${file}:`, error);
}
}
}```
it's up to you
like this?
yep smth like that
yea the another question i dont kinda dumb or not "how long it took discord to register a slashcommand per 1 server"
not that long, not even a second
like when i add the new command and i reload it and i do try with my friend server it not syncs yet
are you registering a server command or global command?
global command
globals usually take a bit longer to appear on all servers
oh
restarting discord app may help refresh faster
some people say kick the bot and reinvite ?
no
just close your app and open again
to refresh local discord caches
but according to the docs, global command propagation is "up to 1 hour"
I prefer to just do “CTRL R”
ohh
That’ll refresh your discord client without actually ending the process and restarting it
@quartz kindle close enough?
is that yugioh?
xD
looks cool
:D making a tutorial at once for my game, ig I replicated well enough if u didnt notice
that aint discord
🍰 perhaps
resorted to figma cuz I cant explain well enough with words how to play, better show them
and I knew it was interactive from the "robots have dominated the world" discord blog post
it's surprisingly easy to replicate anything, no wonder it's used for app prototyping
now this if i use node-fetch it crash something ES6 something
node has fetch built-in now no?
because discord.js v14 not support?
what is your node.js version?
v20.16
i want to add the mongodb into my bot the index should i add
const mongoose = require('mongoose');
// Replace with your MongoDB connection string
const mongoURI = 'xxxxxxxxxxxxxxx';
const connectDB = async () => {
try {
await mongoose.connect(mongoURI, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
console.log('MongoDB connected');
} catch (err) {
console.error(err.message);
process.exit(1);
}
};
module.exports = connectDB;```
into index?
or i should create another file call mongoose.js?
if you want to use module.exports and require, create another file
if you want to put it in index, you dont use module.exports, you can add it to client instead or something
this one still under src/database.js can i put like that?
sure
remove useNewUrlParser: true
deprecation warning usually tell you the exact thing you used that should've not (and why not)
also useUnifiedTopology: true
where should i put?
nowhere
ah
oh
it means u putting it or not wont matter, but it'll lead to errors in the future if you update to the next major version
just ignore it then
no, remove the lines
...
One message removed from a suspended account.
Ctrl + F -> "useNewUrlParser"
huh i confuse
use the find tool to find where
One message removed from a suspended account.
next match
it'll be where you declared your database
in index.js
since it's a mongo warning
require('dotenv').config(); // Load environment variables from .env file
const mongoose = require('mongoose');
const mongoURI = process.env.MONGOURL;
const connectDB = async () => {
try {
await mongoose.connect(mongoURI, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
console.log('MongoDB connected');
} catch (err) {
console.error(err.message);
process.exit(1);
}
};
module.exports = connectDB;
ok here then
yes
???????
It's in the MONGOURL env variable
actually, if u didn't point it out I'd not ask: what intent is that?
oh wait, that's actually a messed up replace
lmao
was supposed to be GuildMessages
bruh
save the file
it autosave
u didnt remove it
setting to false isn't removing, straight up delete the whole line
and this is supposed to be GatewayIntentBits.GuildMessages
eh
edited?
it's correct then
clearly had access to a secret new intent and is playing it off now like a mistake
Because client.setLevel is not a thing
const { ApplicationCommandType, PermissionsBitField, EmbedBuilder } = require('discord.js');
const Functions = require('../../database/models/functions');
module.exports = {
name: 'setlevel',
description: 'Set or update the level of a user',
type: ApplicationCommandType.ChatInput,
cooldown: 10000,
options: [
{
name: 'user',
type: 6,
description: 'The user whose level you want to set',
required: true
},
{
name: 'level',
type: 10,
description: 'The new level to set for the user',
required: true
}
],
run: async (client, interaction) => {
const user = interaction.options.getUser('user');
const level = interaction.options.getNumber('level');
if (!interaction.member.permissions.has(PermissionsBitField.Flags.ManageMessages)) {
return interaction.reply({
content: 'You do not have permission to use this command.',
ephemeral: true
});
}
try {
const data = await Functions.findOne({ Guild: interaction.guild.id });
if (data && data.Levels) {
const updatedUser = await client.setLevel(user.id, interaction.guild.id, level);
const successEmbed = new EmbedBuilder()
.setTitle('Success')
.setDescription('Level has been modified successfully')
.addFields(
{ name: ':new:┆New Level', value: `${updatedUser.level}`, inline: true },
{ name: ':bust_in_silhouette:┆User', value: `${user} (${user.tag})`, inline: true }
)
.setColor('#28a745');
await interaction.reply({ embeds: [successEmbed] });
} else {
const errorEmbed = new EmbedBuilder()
.setTitle('Error')
.setDescription('Levels are disabled in this guild!')
.setColor('#dc3545');
await interaction.reply({ embeds: [errorEmbed], ephemeral: true });
}
} catch (error) {
console.error(error);
const errorEmbed = new EmbedBuilder()
.setTitle('Error')
.setDescription('An error occurred while processing your request.')
.setColor('#dc3545');
await interaction.reply({ embeds: [errorEmbed], ephemeral: true });
}
}
};
if (data && data.Levels) {
const updatedUser = await client.setLevel(user.id, interaction.guild.id, level);```
^^^
batman show ofc
its not even batman
its some ytber merch shop
That logo is supposed to say "Startle"
but its so unreadable its annoying
glitch shutting down???
jk just some community manager is leaving her job that handles the newsletters
glitch is cooked though not sure why fastly bought them
ez
just a mild amount of blindness
average rubber duck debugging
rubber duck programming enthusiasts realising the duck wont write the code for them
oh fastly bought it?
damn
nvm I thought this https://www.npmjs.com/package/fastly 's maintainer bought glitch
how do you even come up with that 💀
fastly is basically cloudflares competitor
much better too apparently
oh
I never heard about that company 💀
OOOHHH my brain thought of fastify, kinda similar with fastly 😭
In terms of a CDN sure
fastly has no dns option afaik
yuh
they do though thats one of their main selling points
its just not free and only available to enterprise clients
theyre more of a consultancy service where you meet with their people to discuss your requirements and they will try to accommodate them rather than having predefined services
i hate these though because theres some things they cant accommodate and you can only find out by having a meeting with their sales team that will try to get you on their plans anyways
um hello? i have a little question, what permission should the "warn" command of my bot require?
to answer your question, typically warn commands will require "Manage Messages"
okay, thank you!
At least thats how i've always set it up, and how i've seen others
only if you actually delete a message
If you can't even delete messages, no point in warning
Right to clarify
Require the user to have this perm
your bot actually needs no perms, unless it does something to the server / user
@runic lake ^^^
Yeah, I know, only the user needs the permission

my warn command requires moderate_members, ban and kick lul, only cuz of the automod feature
Did you code the bots website?
What even is Moderate Members
mute
Ban/kick/mute
I guess
not only me, it was a team
A github template
i guess
idrc at all
just asking
Why would that be a template
because i used it
It can easily be done
It is one
Fair enough
For now, maybe there will be more options in the future 🤔
idk what else could be used as a penalty
make a member blind? like, cant read messages
is that possible to do the log if got any user use the command but let it notify to my server
log command usage?
yea like guildmemberadd'
but it log user use command
it "is" possible, but better not to
oh
you'll be wasting much of your allowed ratelimit bucket
as every command will send 2 messages
it very hard for me to monitor the error then
errors are possible, even recommended yes
use try-catch, sending an error message on the catch
join/leaves/errros are in my server
or when the bot errror make it send the log to channel maybe?
try {
// execute command here
} catch (e) {
// send error message ("e" is your error descriptor)
}
BOP - bulldozer-oriented programming
totally not cursed code 🔥
looks normal
xD
i see some things that can be improved, performance-wise
Whts difference betweeb fs.promises and normal promises
nothing

fs.promises is just the normal fs functions, like readFile, etc
but they return a promise instead of using callbacks
Ahhhh
elaborate
Arigato tim-dono
the entire code is sequential, but i see some things in there that dont need to be
some of those promises can be executed concurrently
well that code runs after a 3min java build
I dont think some concurrent stuff would make it a lot faster
main issue is the binary diff i need to create
xD
the hell ur making that makes java build for 3 minutes?
wtf
Why is there 2 rings
I know one is a border placed when focused
but its getting rid of the wrong one
ah wait its outline
such a dumb thing, why is there
ring, border, and outline
it's french 🇫🇷
ring uses css box-shadow
outline uses css outline
border uses css border
I should maybe do 18 small crontabs all on different processes instead of 1 big one that uses promise.all for 15 types
add them to linux crontab
or just run a file with a setInterval
well yeah anything would be better than the current solution
currently if one type needs to be partially rehashed/rebuilt it clogs up all other types too
so no updates for those while its rehashing
u could make a java project instead of js
at least u get to use system-level threads
wait i jusgt saw this #discord-news message
holy this is huge
#discord-news message this is also a big improvement
if u know c/c++ or any alikes then u wont have much issue with java
there's also groovy
well
only languages im confident in are ts,go,php
do it in php
go can use threads too no?
best lang
probably
but the effort to rewrite this giant of workarounds and sketchy parsing is probably not worth it
if you really need threading, you can always use worker threads or child process
the advantage of java/groovy would be that u can just import those jars and call them directly
but most of the work you're doing is async i/o, so i dont think threading would improve much
and put each task in a separate thread
thank god
for this
amen
yep, now you dont need to fetch almost every detail of the message
did you really need to fetch before? from what i remember you jsut needed to wait a bit
you would receive 2 messageUpdate events for the same message
one empty, and the other with the contents after file upload finished
ah wait, I'm confusing with reaction event
not sure why discord is using aes256 for encryption and performance
for performance with encryption youd usually use aes128
thats what most browsers do with TLS on mobile devices
XChaCha20-Poly1305 is faster for environments without aes hardware acceleration on the cpu so that makes sense including it
Can anyone tell me why we're still trying to get votes on Top.GGs site? Didn't they stop rewarding us for votes?
it affects your placement on the listing
Oh great, and does that matter if I'm not in the top 10?
also it's a convenient system to give rewards to users
So giving my players something for nothing?
I use it mostly cuz I didn't make my own site yet
Do it, I'd use it instead xD
why not? it's free
nonono, website for my own bot, not a public site
Because it took me time to implement so I'd be able to advertise the bot better
Now with no vote credits, I'm unable to do that
users vote, you give them something, your bot goes a little bit up in the listing, they get some currency or reward
happy users mean more users
Ehh, I guess you're right. But I'm gonna try to find another way to do this, so I actually get something out of it
I can't fund my bot on hopes and dreams
well, the only other way would be making your own site to be able to get money off ads
Not exclusively
That website that shows you an ad, then redirrects you, what's that called?
I know, but there are few alternatives.
Honestly, I thought they got enough money from the 30 ads that pop up when you go there xD
nah, they milk every last opportunity they can get
also you'd be hindered by adblockers, whereas in your site you could require ads not to be hidden
eh, well that's likely an update on shields site that broke it
the current site is just a placeholder tbh, I'll rewrite it all eventually
I'd love to have the time to rewrite entire sites, I honestly just spend my time trying to make coding more than just a hobby. I bought a 28 core, 64 gb server for the fun of it, and I want to test it 😄
doesn't take too much work, it's mostly just figuring out how your site appearance will be
for that I'll likely use figma this time
message delete
unkick :^)
send invite link to users dms ‼️
would be funny if discord had a way to unkick someone
like if the person was kicked less than 24h ago, you can forcibly make them join again
xD
do I buy
I mean you can do that with a bot
sure why not
i wouldnt personally spend that mmuch on the cpu, but thats just me
main issue is im on intel 14th gen
oh rip
and have been affected by crashes pretty hard already
Oh damn
like 5 crashes a week average
bruh
true
remember that indian wife washing her husband's laptop with water and soap
and putting it to dry together with clothes
idk if i should get more ram too
I bought a computer cheap that kept crashing, I figured out it was the motherboard, so I just replaced the entire thing. Still only cost me 30% of what the computer would have actually cost
how much you got?
32gb
well if you have the money why not going for 64
hows the setup for that? 4x 12gb?
2x24gb
I kinda need to replace my sticks either way
since they use intel xmp instead of amd expo
and its a lottery whether itll properly overclock on ryzen
4x 16gb would probably be faster tho, assuming quad channel support
well yes but the 9900x only has dual channel
ah ye
hard no, expensive
I did actually write something so gpt can use a browser with buttons / inputs
O
u mean get responses with scraping
I see
ye
making a sort of unofficial api that uses your personal account and automates it
You would have to be logged in to use chatgpt
ye
Can you do this with a headless browser? While also bypassing their own restrictions like ox7d8 pointed out
make a browser extension that interacts with it and sends the responses via http
and keep it always open
xD
probably cheaper to just use the api
on god
its weird you go that far into precision for money
well its how far openai goes
per 1000 tokens
1 token = average 4-5chars i think
it's cuz AI doesn't read the text as a text, but as a bunch of trigram-like tokens
which is also why AI cant draw text (properly)
Is there anyway to tap into the placeholder of a input element
trying to test out a design where I apply a type writer effect to the placeholder not sure if that will look good
idk what any of that means
Have you ever seen Office Space?
varchar
put something like 32 or so for length, varchar only uses necessary space so constraining too much wouldn't be worth it
using char with extra padding will have faster lookups
but it doesn't really matter much
bigint is probably the best since it's a discord id
discord id is quite close to bigint limit no?
bigint -> 9223372036854775807
you -> 92436985859293184
actually, it already went into another digit for new accounts
It will be bigger than bigint in 2084
👀 my great grandmother is 101
I'd rather die than live through em 
she still lives at home, idk how.
Granny goated thats how
for sure
She still poppin wheelies at night I bet
btw how is woo these days
haven't seen you in a bit
I'm alright, lots going on as usual these days.
Got a new router today, its pretty amazing.
I dont know what half the settings are
But it runs containers, might setup a pihole or adguard on it(for funsies)
Thats a lot of stuff you likely will never need
then make a wifi connection that has adguard built in
Its there just to have it in case you do
so 2 SSIDs, one that has adblock, one that doesnt.
Why would you ever want one without adblock
Other people using the wifi network will think sites just break and not inform me
I mean, the number isn't a sequence
so it'll be just for me, while the fam gets ads 😄
The length increases due to the timestamp part of the snowflake afaik.
yep
all the other parts are statically sized
2084 + or - a year is probably pretty accurate.
discord ids are not signed are they?
unsigned would be 18446744073709551615
probably not, but idk
I imagine not
never seen anyone with a negative id
👀 imagine using your ISPs router
;p
Its so much cheaper to use your own router, at least for my ISP
must be nice ^-^
DELETE FROM table_name;
Right?
Its the same thing as deleting a row, without the where condition
Its $84 a year, not including tax to rent a router from my ISP.
They still give a router and a modem, and both must be rented, so it ends up being $150~ if you rent.
dafuq
thats bullshit
Yeah, I've helped quite a few people save a lot by not renting.
TRUNCATE TABLE table_name
If it has an autoincrement id use RESTART IDENTITY with truncate
DROP TABLE + CREATE TABLE :^)
I can't change isp's router in my country :(
it needs id and password from them

why do you have two tables storing roughly the same information
theres strikingly similar data being stored on both that you can likely combine into one
same here
with big telephony ISPs we could still get our own ADSL modem and they would give us the PPPOE credentials
but with today's fiber ISPs they no longer allow you to do jack shit
they dont even allow you to change your own wifi's name/password
It hurts me deeply that there's no standard for id and created_at
Also note, if you have to put quotes on something, you're seriously advised to name that thing differently, I've saw many weird bugs that took a long time to debug just to find out it was because the lib assumed something to be a reserved keyword when it wasn't
wtf that's more stupid 💀
thats how it is
if you wanna change it, you have to contact their support and ask them
and they will do it remotely
💀
their excuse is that the router belongs to them and has many secret keys and stuff inside that you are not allowed to see
lmao
what a bs
the fiber connector also has one of those glued on labels that cannot be removed without ripping them
which voids your warranty if you do it
so you cant even unplug the fiber cable to move the router somewhere else in your home
i wouldnt be surprised if they also log/monitor what their clients do on the internet
💀 💀 💀 💀 💀
but oh well, its cheap and it works pretty decently
kind of mucked around and accidentally uninstalled python3.10 (which caused ufw and a lot of other stuff to uninstall)
Now I can't install ufw again as this error happens

yea
but completely uninstall ufw and reset iptables
Can't even ping google.com
Its not installed
then check your iptables
I was trying to uninstall 3.9
forgot to specify which python version I wanted to uninstall
and it ended up uninstalling both

so shold be fine if you reset those
How the fuck do I reset those
because I was lookin online
and it wants me to use rm -rf on shit
and im not trusting that

reinstall server lmfao
idk there should be a way to fix that
it has a lot of important shit
kekw
important = I dont want to setup again
fair enough
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
``` try this lol
Do I have to reload anything
also found this .sh script:
#!/bin/sh
#
# rc.flush-iptables - Resets iptables to default values.
#
# Copyright (C) 2001 Oskar Andreasson <bluefluxATkoffeinDOTnet>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program or from the site that you downloaded it
# from; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA
#
# Configurations
#
IPTABLES="/sbin/iptables"
#
# reset the default policies in the filter table.
#
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -P OUTPUT ACCEPT
#
# reset the default policies in the nat table.
#
$IPTABLES -t nat -P PREROUTING ACCEPT
$IPTABLES -t nat -P POSTROUTING ACCEPT
$IPTABLES -t nat -P OUTPUT ACCEPT
#
# reset the default policies in the mangle table.
#
$IPTABLES -t mangle -P PREROUTING ACCEPT
$IPTABLES -t mangle -P POSTROUTING ACCEPT
$IPTABLES -t mangle -P INPUT ACCEPT
$IPTABLES -t mangle -P OUTPUT ACCEPT
$IPTABLES -t mangle -P FORWARD ACCEPT
#
# flush all the rules in the filter and nat tables.
#
$IPTABLES -F
$IPTABLES -t nat -F
$IPTABLES -t mangle -F
#
# erase all chains that's not default in filter and nat table.
#
$IPTABLES -X
$IPTABLES -t nat -X
$IPTABLES -t mangle -X
fuck it at this point
pretty sure you dont
ye vnc sucks lmao
better off just doing that all myself
also
# You should have received a copy of the GNU General Public License
# along with this program or from the site that you downloaded it
# from; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA
lmao
I did all this
still can't even ping google.com
or install any packages
Temporary failure in name resolution

A-A ron done fucked up
How credible do you think this is
are you using ubuntu?
check this as well
its a bit old tho
but yeah, messing with the dns resolver should be the next step
also try this
sudo systemd-resolve --set-dns=8.8.8.8 --interface=<interface name>
E.g. sudo systemd-resolve --set-dns=8.8.8.8 --interface=eth0.
afaik the resolver.conf file is not supposed to be edited directly because its managed by systemd
you can also check if by any change the resolver is not running at all
sudo systemctl enable systemd-resolved.service
sudo systemctl start systemd-resolved.service
run ifconfig
just leaked my vps ip :^)
what does your ifconfig show?
lmao nice names
blame contabo
does any of them have your vps ip?
inet your.ip.address.k
the one that has the correct ip is the one
none of these?
try sudo dpkg-reconfigure network-manager
Network manager not installed
Lol
God what the fuck did I do
All I wanted to do was uninstall python 3.9
Didn’t even know python 3.10 was installed until after

show the contents of /etc/network/interfaces
wtf
What framework should I use for making an iOS/android app? Svelte native?
sudo nano /etc/network/interfaces doesn work?
youre forked

are you sure you didnt run rm -rf /?
put this on it ```sh
This file describes the network interfaces available on your system
and how to activate them. For more information, see interfaces(5).
The loopback network interface
auto lo
iface lo inet loopback
The primary network interface
auto eth0
iface eth0 inet dhcp
then run ```sh
sudo ifdown eth0
sudo ifup eth0
🤣
ifdown not a valid command
God damn im screwed
At this point bout to just fuck all my shit and just reinstall the os
erxdee
like idfk why uninstalling python does this shit
No way stuff is that reliant on python its sad
also, apparenry onubuntu 18+ its /etc/netplan/ not /etc/network/interfaces
check if netplan exists
xD
yknow
luckily all that was on there was some bot I can reset up and my mail server I hardly use
Sooooo
Not too important
but the mailserver is annoying asf to setup
so, the lesson is


