#development

1 messages · Page 248 of 1

radiant kraken
#

ew powershell

#

cmd >>>

quartz kindle
#

powershell is weird af

#

such a convoluted overengineered and overcomplicated scripting syntax

lyric mountain
#

if only windows adopted bash like everything else

quartz kindle
#

"nah, lets make a .NET shell instead"

lyric mountain
#

never google "how to send post request with body on powershell"

#

worst mistake of my life

radiant kraken
#

its like they're trying to make a terminal for php users

earnest phoenix
#

"stats" and "analytics" are different words

radiant kraken
#

analytics are still stats

earnest phoenix
#

no

past field
#

is there a way to figure out what server the errors are coming from?

lyric mountain
#

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

deft wolf
#

For some errors, the url contains the server ID iirc

pearl trail
raven nexus
#

How could i fix the unknown interaction?

deft wolf
#

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

lyric mountain
#

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

winged sphinx
#

Most of the time it is a Discord issue yeah

#

Even defer cannot help

pearl trail
#

maybe it's deleted by user?

#

that's the other case that is possible

surreal sage
#

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

quartz kindle
#

they require you to specify for how long you store that data

surreal sage
#

So if it would automatically delete after 30 days it's fine?

quartz kindle
#

and ive seen them demand people not to store it for over 30 days regardless

quartz kindle
surreal sage
#

huhm

sharp geyser
#

https://hastebin.skyra.pw/dasalitufe.csharp what you guys think of this C# code?

What im trying to do is

  1. Grab commit history from facepunch commits
  2. Post only the most recent commits based off the last commit we've sent to a discord channel
  3. Make sure no duplicates get sent
  4. Make sure it gets sent in order (This part is tricky because of the timer we set)
surreal sage
#

ignore comparison

#

why bracket in new line 💔

sharp geyser
#

what

#

Its c#

#

tf you expect

surreal sage
#

if (condition) { where

#

just change it

sharp geyser
#

no

sharp geyser
#

shut it

eternal osprey
#

maynnn what dis

#

i just updated my node yesterday., i restarted and then boom my mac fucks me again

eternal osprey
#

ahh gotta restart prolly

eternal osprey
#

prolly need to restart one sec

quartz kindle
#

ah then probably rrestart ye

frosty gale
#

"macs are the best for code"

#

yeah it is unix based but a linux based system is still on top

proven lantern
#

at least Windows©®™ puts linux into a virtual machine

sharp geyser
#

mac just dual boots windows

frosty gale
#

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

proven lantern
#

wsl is pretty cool

frosty gale
#

too bad the partition was cursed with zig

proven lantern
#

that's in windows

#

zig is great though

proven lantern
lyric mountain
pearl trail
#

but that's only possible with non m series mac

proven lantern
lament rock
#

macos has hardware restrictions

#

people make hackintoshes for that reason

pearl trail
#

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

quartz kindle
#

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

lament rock
#

There are the open source nv drivers

pearl trail
pearl trail
lament rock
#

Nah they're primarily found on Linux but Linux is Unix so

#

Otherwise Linux people wouldnt be able to use their gpus

quartz kindle
#

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

pearl trail
#

ooooo

quartz kindle
#

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

pearl trail
#

😔

lament rock
#

Apple does also block certain devices from being installed iirc

pearl trail
#

certain hardware?

quartz kindle
#

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

quartz kindle
#

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

pearl trail
#

yeah, get AMD CPU and GPU

lament rock
#

This is starting to get more difficult though since the m series chips are starting to defeat x86 based chips in most tasks

quartz kindle
#

yeah its a new architecture, so a lot of things changed

proven lantern
#

isn't it just arm

lament rock
#

It is ARM/RISC

proven lantern
#

is it RISC?

lament rock
#

But when compared to other ARM chips like snapdragons meant for laptops, the performance gap is quite large

proven lantern
#

doesn't it have a bunck of extra stuff

lament rock
#

ARM is based off RISC iirc

#

RISC is just a limited instr set

quartz kindle
#

if apple fully deprecates intel and makes m-only OSx versions, then it will be more difficult to make hachintoshes

lament rock
#

For sure

sharp geyser
#

sup gaymers

lament rock
#

but there are still ARM chips but it's common to find them soldered

quartz kindle
#

but for now i believe all macos versions are dual-arch

proven lantern
#

windows is making arm versions soon

lament rock
#

Theres also Windows for ARM

quartz kindle
#

ye

lament rock
#

Thats already a thing

proven lantern
#

intel keeps getting bad news

quartz kindle
#

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

proven lantern
#

aren't chromebooks arm laptops?

quartz kindle
#

nobody would want to buy an arm windows laptop if it cant run your usual windows apps that only work on x86

quartz kindle
proven lantern
#

yeah, games will be a big problem too

quartz kindle
#

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

proven lantern
#

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.

pearl trail
#

it's too new to use

earnest phoenix
#

windows already has an emulation layer for x86

#

and also box86/64 exists for linux

frosty gale
#

not sure if there even is a variant of chromeos that supports arm

earnest phoenix
#

arent most cheap chromebooks arm

frosty gale
#

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

pearl trail
#

compatibility: Troll

#

i mean it's great for browsing, doing office

#

but else,

raven nexus
#

is there a guide to create event command like
guildcreate
guildremove
memberadd
memberremove?

deft wolf
#

Depends on what you mean by "guide". I think the documentation for the wrapper you are using has all the information you need

raven nexus
#

i have try to make one but it dont notify at all

deft wolf
#

Remember that you must have the appropriate intents activated in your code to receive such events

#

For example

raven nexus
#

can i send the code here? because what i done it give double log

#

i just want to make it show one time

deft wolf
#

Sure, remember to remove any token/api key

raven nexus
#

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

deft wolf
#

Are the codes you sent two separate files?

raven nexus
#

yea

#

2 seperate

#
  1. Guildcreate.js
  2. GuildDelete.js
deft wolf
#

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)

raven nexus
#

so how could i fix it?

deft wolf
#

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

raven nexus
deft wolf
#

Yep

#

Just remove the GuildDelete listener from the Guildcreate.js file and the GuildCreate listener from the GuildDelete.js file

raven nexus
#

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);
deft wolf
#

The file was saved and the bot was restarted?

raven nexus
#

ya

#

i could try to replace the token

#

usally how you do the guildCreate?

rustic nova
raven nexus
#

huh?

raven nexus
#

someone ask

rustic nova
#

No I mean there's 2 different bots apparently

raven nexus
#

yes

rustic nova
raven nexus
#

but both are same structure

#

??

#

i dont understand

rustic nova
#

Changing it on one won't change it on the other though

raven nexus
#

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

rustic nova
#

Your logs mention a different bot than what the bot on the screenshot is

rustic nova
rustic nova
raven nexus
#

ok?

#

then why you go look at the log ?

#

i really dont understand

raven nexus
#

there is no point to read the log

#

did i ask to help and see the log? i dont think so

lyric mountain
#

rude

raven nexus
rustic nova
#

Forget it then

raven nexus
#

i just need help to know why it react double

rustic nova
#

Just saying there appears to be 2 different bots while your logs show a different one

lyric mountain
raven nexus
#

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

lyric mountain
#

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?

rustic nova
#

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

lyric mountain
#

that's a possibility too

raven nexus
#

And I don't speak English I speak Thai

#

So yea sorry

lyric mountain
#

wait you said you have 2 different files, guildcreate and guildDelete right?

raven nexus
#

Yws

#

Yes

lyric mountain
#

I suppose you have a different file for initializing your bot

#

like an index

raven nexus
#

Yea

lyric mountain
#

then the issue is the last line in the code u sent here

raven nexus
#

1 is fortune and 1 is the dev version

lyric mountain
#

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

raven nexus
#

I want to know how usually the event structure?

#

They are not like command file right

lyric mountain
#

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

raven nexus
#

Oh

lyric mountain
#

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

quartz kindle
#

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

lyric mountain
#

oh, weird

quartz kindle
raven nexus
raven nexus
#

this 2 was in an event folder

quartz kindle
#

you put new Client() and client.login() in your index.js file

#

and remove them from all other files

raven nexus
#

already in

quartz kindle
#

now remove it from all other files

#

also remove module.exports = client

raven nexus
#
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?

quartz kindle
#

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

raven nexus
#

like guildmemberadd

quartz kindle
#

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

raven nexus
quartz kindle
#

oh, handlers are not events?

#

what are handlers then?

raven nexus
#

should i move it to index.js?

#

and remove the handler?

quartz kindle
#

sure, its the same thing tho

#

you dont need this if you already load them dynamically

#

also remove this, you dont need it

raven nexus
#
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?

quartz kindle
#

sure, that should work

raven nexus
#

im confuse about the pathing

quartz kindle
#

do you have a src folder?

raven nexus
#

the file are in src/events/XXX.js

#

ya

quartz kindle
#

where is index.js?

raven nexus
#

in the src

quartz kindle
#

then remove src from path

#

./ means "this folder", if index.js is inside src, then ./ is src already

raven nexus
#
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);
quartz kindle
#

how do you start the bot?

raven nexus
#

node .

quartz kindle
#

node index.js? or node ./src/index.js?

raven nexus
#

in my laptop i use node . or node index.js

#

but in my host i use /src/index.js

quartz kindle
raven nexus
#

"main": "./src/index.js",

quartz kindle
#

ok

raven nexus
#

this

quartz kindle
#

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

raven nexus
#

ok

quartz kindle
#

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

raven nexus
#

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?

quartz kindle
#

sure you can, but that error should not be happening, did you put ready.js inside events folder?

raven nexus
#

ya

quartz kindle
#

and you have ```js
require(./events/${event})(client);

raven nexus
#
// 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}`);
}
quartz kindle
#

this is in index.js right?

raven nexus
#

ya

quartz kindle
#

and its after client = new Client() ?

raven nexus
#

yes

quartz kindle
#

and in ready.js you have module.exports = (client) => { client.on("ready", ...) } ?

raven nexus
#
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 });
    });
};
quartz kindle
#

then it should work

raven nexus
#

i think it react everything about the client.on

quartz kindle
#

show full index.js

raven nexus
quartz kindle
#

hmm i dont see a reason for why its not working, but try using readdirSync instead of readdir

raven nexus
#

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

quartz kindle
#

ah

#

you cant use const client = require('..');

#

you need to use module.exports = client => { client.on() }

raven nexus
#

now it loaded

quartz kindle
#

and not duplicated anymore?

raven nexus
#

yes

#

nope

quartz kindle
#

good

raven nexus
#

actually what happed

#

i really confuse

quartz kindle
#

why was it duplocated?

raven nexus
#

yea

quartz kindle
#

because you had multiple clients

#

each new Client() is a separate bot

#

you had new Client() in index.js and also in events

raven nexus
#

how could i make the command work globally?

#

i think i make it for private use

quartz kindle
#

use Routes.applicationCommands instead of Routes.applicationGuildCommands

#

Routes.applicationCommands(clientId)

raven nexus
#

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);
    }
};```
pearl trail
#

uh what are you awaiting in the second Promise.all

raven nexus
#

hm?

pearl trail
#

why you use promise and async when none of the code isn't using await

pearl trail
#

just use for loop for that

raven nexus
pearl trail
#
for (let file of jsFiles) {
  // rest of your code
}
raven nexus
#

ohh

pearl trail
#

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

raven nexus
#
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);
                }
            }
        }```
pearl trail
#

it's up to you

raven nexus
#

like this?

pearl trail
#

yep smth like that

raven nexus
#

yea the another question i dont kinda dumb or not "how long it took discord to register a slashcommand per 1 server"

pearl trail
#

not that long, not even a second

raven nexus
lyric mountain
#

are you registering a server command or global command?

raven nexus
#

global command

lyric mountain
#

globals usually take a bit longer to appear on all servers

raven nexus
#

oh

quartz kindle
raven nexus
quartz kindle
#

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"

wheat mesa
#

I prefer to just do “CTRL R”

raven nexus
wheat mesa
#

That’ll refresh your discord client without actually ending the process and restarting it

lyric mountain
#

@quartz kindle close enough?

quartz kindle
#

xD

#

looks cool

lyric mountain
#

:D making a tutorial at once for my game, ig I replicated well enough if u didnt notice

#

that aint discord

quartz kindle
#

lmao

#

fake yugioh, fake discord, what else is fake? are you made of cake?

lyric mountain
#

🍰 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

raven nexus
#

now this if i use node-fetch it crash something ES6 something

lyric mountain
#

node has fetch built-in now no?

raven nexus
#

because discord.js v14 not support?

quartz kindle
#

what is your node.js version?

raven nexus
#

v20.16

quartz kindle
#

then you dont need node-fetch

#

node.js has fetch integrated

raven nexus
#

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?

quartz kindle
#

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

raven nexus
#

this one still under src/database.js can i put like that?

quartz kindle
#

sure

raven nexus
#

how to get rid of this warning?

lyric mountain
#

remove useNewUrlParser: true

#

deprecation warning usually tell you the exact thing you used that should've not (and why not)

#

also useUnifiedTopology: true

raven nexus
#

where should i put?

lyric mountain
#

nowhere

raven nexus
#

ah

lyric mountain
#

"useNewUrlParser has no effect"

raven nexus
#

oh

lyric mountain
#

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

raven nexus
#

just ignore it then

lyric mountain
#

no, remove the lines

raven nexus
#

eh

#

did they tell location?

lyric mountain
#

...

raven nexus
#

you ask me to remove

#

but which line?

sage bobcat
#

One message removed from a suspended account.

lyric mountain
#

Ctrl + F -> "useNewUrlParser"

raven nexus
#

huh i confuse

lyric mountain
#

use the find tool to find where

sage bobcat
#

One message removed from a suspended account.

raven nexus
#

?

lyric mountain
#

next match

raven nexus
#

dont have

#

only got 1

lyric mountain
#

it'll be where you declared your database

raven nexus
#

in index.js

lyric mountain
#

since it's a mongo warning

raven nexus
#
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

lyric mountain
#

yes

quartz kindle
deft wolf
#

It's in the MONGOURL env variable

lyric mountain
#

oh wait, that's actually a messed up replace

quartz kindle
#

lmao

lyric mountain
#

was supposed to be GuildMessages

raven nexus
lyric mountain
#

save the file

raven nexus
#

it autosave

lyric mountain
#

u didnt remove it

#

setting to false isn't removing, straight up delete the whole line

raven nexus
#

ok done

#

phewww

lyric mountain
# raven nexus

and this is supposed to be GatewayIntentBits.GuildMessages

lyric mountain
#

it's correct then

frosty gale
#

clearly had access to a secret new intent and is playing it off now like a mistake

quartz kindle
#

secret new intent that unlocks all intents without verification or approval

#

:^)

raven nexus
#

cant find to fix it

#

use await also the same

wheat mesa
#

Because client.setLevel is not a thing

raven nexus
#
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);```
wheat mesa
raven nexus
#

ah

#

wait i think i see sth

sharp geyser
#

Gotta love NaN

lyric mountain
#

batman show ofc

sharp geyser
#

its not even batman

#

its some ytber merch shop

#

That logo is supposed to say "Startle"

#

but its so unreadable its annoying

frosty gale
#

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

summer acorn
#

hi, getting this error, not quite sure why

#

oh wait

#

nevermind I see why now

frosty gale
#

ez

summer acorn
#

just a mild amount of blindness

lyric mountain
#

average rubber duck debugging

frosty gale
#

rubber duck programming enthusiasts realising the duck wont write the code for them

pearl trail
#

damn

#

nvm I thought this https://www.npmjs.com/package/fastly 's maintainer bought glitch

frosty gale
#

how do you even come up with that 💀

#

fastly is basically cloudflares competitor

#

much better too apparently

pearl trail
#

oh

#

I never heard about that company 💀

#

OOOHHH my brain thought of fastify, kinda similar with fastly 😭

sharp geyser
#

fastly has no dns option afaik

lyric mountain
#

also no site protection features

#

it's mostly for content delivery

sharp geyser
#

yuh

frosty gale
#

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

lyric mountain
frosty gale
#

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

runic lake
#

um hello? i have a little question, what permission should the "warn" command of my bot require?

sharp geyser
#

to answer your question, typically warn commands will require "Manage Messages"

runic lake
#

okay, thank you!

sharp geyser
#

At least thats how i've always set it up, and how i've seen others

lyric mountain
#

only if you actually delete a message

sharp geyser
#

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 ^^^

runic lake
sharp geyser
lyric mountain
#

my warn command requires moderate_members, ban and kick lul, only cuz of the automod feature

pine willow
sharp geyser
#

What even is Moderate Members

lyric mountain
#

mute

sharp geyser
#

its not an actual permission in a role

#

Bruh

pine willow
lyric mountain
sharp geyser
#

I guess

runic lake
lyric mountain
#

stupid discord naming

#

it's literally only to mute people

pine willow
#

i guess

#

idrc at all

#

just asking

sharp geyser
#

Why would that be a template

pine willow
#

because i used it

sharp geyser
#

It can easily be done

runic lake
sharp geyser
#

Fair enough

deft wolf
sharp geyser
#

Doubtful

#

It’s been that way for years

lyric mountain
#

idk what else could be used as a penalty

#

make a member blind? like, cant read messages

raven nexus
#

is that possible to do the log if got any user use the command but let it notify to my server

lyric mountain
#

log command usage?

raven nexus
#

but it log user use command

lyric mountain
#

it "is" possible, but better not to

raven nexus
#

oh

lyric mountain
#

you'll be wasting much of your allowed ratelimit bucket

#

as every command will send 2 messages

raven nexus
#

it very hard for me to monitor the error then

pine willow
#

My bot logs uses in the console

#

that works good

lyric mountain
#

use try-catch, sending an error message on the catch

pine willow
#

join/leaves/errros are in my server

raven nexus
lyric mountain
#
try {
  // execute command here
} catch (e) {
  // send error message ("e" is your error descriptor)
}
frosty gale
#

i ignore all my errors

#

they only slow me down

lyric mountain
#

BOP - bulldozer-oriented programming

neon leaf
#

totally not cursed code 🔥

sharp geyser
#

looks normal

quartz kindle
#

i see some things that can be improved, performance-wise

eternal osprey
#

Whts difference betweeb fs.promises and normal promises

eternal osprey
quartz kindle
#

fs.promises is just the normal fs functions, like readFile, etc

#

but they return a promise instead of using callbacks

eternal osprey
#

Ahhhh

eternal osprey
#

Arigato tim-dono

quartz kindle
#

some of those promises can be executed concurrently

neon leaf
#

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

quartz kindle
#

xD

lyric mountain
#

the hell ur making that makes java build for 3 minutes?

neon leaf
#

compiling a minecraft server software

#

but the binary diff alone takes like 20s

sharp geyser
#

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

lyric mountain
#

it's french 🇫🇷

quartz kindle
neon leaf
#

I should maybe do 18 small crontabs all on different processes instead of 1 big one that uses promise.all for 15 types

quartz kindle
#

add them to linux crontab

neon leaf
#

true I guess

#

its in a docker container so not too unrealistic

quartz kindle
#

or just run a file with a setInterval

neon leaf
#

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

lyric mountain
#

u could make a java project instead of js

#

at least u get to use system-level threads

neon leaf
#

well I barely know java

#

(and this codebase is a mess)

quartz kindle
#

holy this is huge

lyric mountain
#

there's also groovy

neon leaf
#

only languages im confident in are ts,go,php

quartz kindle
#

do it in php

lyric mountain
#

go can use threads too no?

quartz kindle
#

best lang

neon leaf
#

but the effort to rewrite this giant of workarounds and sketchy parsing is probably not worth it

quartz kindle
#

if you really need threading, you can always use worker threads or child process

lyric mountain
#

the advantage of java/groovy would be that u can just import those jars and call them directly

quartz kindle
#

but most of the work you're doing is async i/o, so i dont think threading would improve much

lyric mountain
#

and put each task in a separate thread

real rose
#

thank god

quartz kindle
#

amen

lyric mountain
#

yep, now you dont need to fetch almost every detail of the message

quartz kindle
#

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

lyric mountain
#

ah wait, I'm confusing with reaction event

frosty gale
#

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

crude egret
#

Can anyone tell me why we're still trying to get votes on Top.GGs site? Didn't they stop rewarding us for votes?

lyric mountain
#

it affects your placement on the listing

crude egret
#

Oh great, and does that matter if I'm not in the top 10?

lyric mountain
#

also it's a convenient system to give rewards to users

crude egret
lyric mountain
#

I use it mostly cuz I didn't make my own site yet

crude egret
lyric mountain
lyric mountain
crude egret
#

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

lyric mountain
#

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

crude egret
#

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

lyric mountain
#

well, the only other way would be making your own site to be able to get money off ads

crude egret
#

That website that shows you an ad, then redirrects you, what's that called?

lyric mountain
#

there are many, and I'd not recommend it

#

those sites are known to collect data

crude egret
crude egret
lyric mountain
#

nah, they milk every last opportunity they can get

crude egret
#

I bet they do

#

Btw, your website has what I believe is a lil issue

lyric mountain
#

also you'd be hindered by adblockers, whereas in your site you could require ads not to be hidden

lyric mountain
#

the current site is just a placeholder tbh, I'll rewrite it all eventually

crude egret
#

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 😄

lyric mountain
#

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

quartz kindle
#

unkick :^)

neon leaf
quartz kindle
#

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

neon leaf
#

do I buy

neon leaf
quartz kindle
#

i wouldnt personally spend that mmuch on the cpu, but thats just me

neon leaf
#

main issue is im on intel 14th gen

quartz kindle
#

oh rip

neon leaf
#

and have been affected by crashes pretty hard already

crude egret
#

Oh damn

neon leaf
#

like 5 crashes a week average

quartz kindle
#

damn, sounds like most of the pcs i've had in my life

#

xDDD

neon leaf
#

bruh

quartz kindle
#

i have never owned a single pc/laptop that didnt have some sort of issue

#

:^)

neon leaf
#

i need to deepclean my pc

#

so much cat hair

quartz kindle
#

xD

#

put it in the washing machine

neon leaf
#

true

quartz kindle
#

remember that indian wife washing her husband's laptop with water and soap

#

and putting it to dry together with clothes

lyric mountain
#

tbh, u can, just dont let energy get to it

#

and no soap ofc

quartz kindle
#

sure

#

if you remove the battery and empty the capacitors its pretty safe

neon leaf
#

idk if i should get more ram too

crude egret
#

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

quartz kindle
neon leaf
#

32gb

quartz kindle
#

well if you have the money why not going for 64

neon leaf
#

I was thinking of doing 48 lol

#

not that uncommon on ddr5

quartz kindle
#

hows the setup for that? 4x 12gb?

neon leaf
#

2x24gb

quartz kindle
#

ah

#

should be alright

neon leaf
#

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

quartz kindle
#

4x 16gb would probably be faster tho, assuming quad channel support

neon leaf
#

well yes but the 9900x only has dual channel

quartz kindle
#

ah ye

past field
#

ok question

#

is it a hard process to add a gpt to my bot for entertainment purposes?

lyric mountain
#

hard no, expensive

past field
#

oh so not worth it

#

i pay for chatgpt. i wonder if that includes an api

lyric mountain
#

it doesnt

#

the api is entirely separate, you pay per use

past field
#

oh

#

nvm then

quartz kindle
#

does a headless browser work on chatgpt?

#

could try scrapeing it

neon leaf
#

I did actually write something so gpt can use a browser with buttons / inputs

#

O

#

u mean get responses with scraping

#

I see

quartz kindle
#

ye

#

making a sort of unofficial api that uses your personal account and automates it

sharp geyser
#

You would have to be logged in to use chatgpt

neon leaf
#

well ratelimits exist

#

and cloudflare captcha

quartz kindle
#

ye

sharp geyser
#

Can you do this with a headless browser? While also bypassing their own restrictions like ox7d8 pointed out

quartz kindle
#

make a browser extension that interacts with it and sends the responses via http

#

and keep it always open

#

xD

sharp geyser
#

rip the users who use it

#

it will break in minutes

neon leaf
#

probably cheaper to just use the api

sharp geyser
#

on god

neon leaf
sharp geyser
#

its weird you go that far into precision for money

neon leaf
#

well its how far openai goes

sharp geyser
#

ah right

#

forgot open ai is weird like that

quartz kindle
neon leaf
#

per 1000 tokens

quartz kindle
#

or per X number of requests?

#

ah

neon leaf
#

1 token = average 4-5chars i think

quartz kindle
#

oh

#

weird, but i guess it makes sense

neon leaf
#

well an gpt consumes tokens to translate

lyric mountain
#

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)

sharp geyser
#

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

real rose
neon leaf
#

discord ids?

#

either bigint or varchar(22)

past field
#

idk what any of that means

proven lantern
lyric mountain
#

varchar

#

put something like 32 or so for length, varchar only uses necessary space so constraining too much wouldn't be worth it

proven lantern
#

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

lyric mountain
#

discord id is quite close to bigint limit no?

bigint -> 9223372036854775807
you ->    92436985859293184
#

actually, it already went into another digit for new accounts

solemn latch
sharp geyser
#

Hell yea

#

Ima survive that long!!!!

solemn latch
#

👀 I wont

#

^-^

sharp geyser
#

Hopefully I wont either

#

Fuck being old man

#

Illnesses run in my family

solemn latch
#

👀 my great grandmother is 101

sharp geyser
#

I'd rather die than live through em val_WaaGone

solemn latch
#

she still lives at home, idk how.

sharp geyser
#

Granny goated thats how

solemn latch
#

for sure

sharp geyser
#

She still poppin wheelies at night I bet

#

btw how is woo these days

#

haven't seen you in a bit

solemn latch
#

I'm alright, lots going on as usual these days.

#

Got a new router today, its pretty amazing.

#

But it runs containers, might setup a pihole or adguard on it(for funsies)

sharp geyser
#

Thats a lot of stuff you likely will never need

solemn latch
#

then make a wifi connection that has adguard built in

sharp geyser
#

Its there just to have it in case you do

solemn latch
#

so 2 SSIDs, one that has adblock, one that doesnt.

sharp geyser
#

Why would you ever want one without adblock

solemn latch
#

Other people using the wifi network will think sites just break and not inform me

lyric mountain
solemn latch
#

so it'll be just for me, while the fam gets ads 😄

solemn latch
lyric mountain
#

yep

solemn latch
#

all the other parts are statically sized

#

2084 + or - a year is probably pretty accurate.

pearl trail
#

is it hard to use adguard?

#

or simply by just changing dns?

quartz kindle
#

unsigned would be 18446744073709551615

lyric mountain
#

probably not, but idk

sharp geyser
#

never seen anyone with a negative id

solemn latch
#

👀 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

solemn latch
# solemn latch must be nice ^-^

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.

solemn latch
#

Yeah, I've helped quite a few people save a lot by not renting.

lyric mountain
#

TRUNCATE TABLE table_name

#

If it has an autoincrement id use RESTART IDENTITY with truncate

quartz kindle
#

DROP TABLE + CREATE TABLE :^)

pearl trail
#

it needs id and password from them

sharp geyser
#

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

quartz kindle
#

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

lyric mountain
#

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

pearl trail
quartz kindle
#

if you wanna change it, you have to contact their support and ask them

#

and they will do it remotely

pearl trail
#

💀

quartz kindle
#

their excuse is that the router belongs to them and has many secret keys and stuff inside that you are not allowed to see

pearl trail
#

my ISP, only open 1 LAN port 💀 (3)

#

the rest (1, 2, 4) won't work

quartz kindle
#

lmao

quartz kindle
#

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

quartz kindle
#

but oh well, its cheap and it works pretty decently

sharp geyser
#

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

quartz kindle
#

lol dafuq

#

i dont see how that could possibly happen lol

sharp geyser
#

yea

quartz kindle
#

but completely uninstall ufw and reset iptables

sharp geyser
sharp geyser
quartz kindle
#

then check your iptables

sharp geyser
#

I was trying to uninstall 3.9

#

forgot to specify which python version I wanted to uninstall

#

and it ended up uninstalling both

quartz kindle
#

lel

#

anyway ufw is just a wrapper for iptables and other low level linux routing

sharp geyser
#

I done fucked up

quartz kindle
#

so shold be fine if you reset those

sharp geyser
#

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

pearl trail
#

reinstall server lmfao

sharp geyser
#

nah

#

rather not

pearl trail
#

idk there should be a way to fix that

sharp geyser
#

it has a lot of important shit

pearl trail
#

kekw

sharp geyser
#

important = I dont want to setup again

pearl trail
#

fair enough

quartz kindle
#
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
pearl trail
sharp geyser
#

Do I have to reload anything

quartz kindle
#

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
sharp geyser
#

fuck it at this point

quartz kindle
sharp geyser
#

jesus using VNC I can't copy or paste

#

so fucking annoying

quartz kindle
#

ye vnc sucks lmao

sharp geyser
#

better off just doing that all myself

quartz kindle
#

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

sharp geyser
#

yea

#

im fucked

sharp geyser
#

or install any packages

#

Temporary failure in name resolution

#

A-A ron done fucked up

#

How credible do you think this is

quartz kindle
sharp geyser
#

yes

#

ubuntu 22.04

quartz kindle
#

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

sharp geyser
#

god idfk what to put for the interface name

#

I assume eth0

quartz kindle
#

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
quartz kindle
sharp geyser
#

what am I supposed to look for in ifconfig

#

ion see that

#

eth0 not there

quartz kindle
#

just leaked my vps ip :^)

quartz kindle
sharp geyser
quartz kindle
#

lmao nice names

sharp geyser
#

blame contabo

quartz kindle
#

does any of them have your vps ip?

#

inet your.ip.address.k

#

the one that has the correct ip is the one

sharp geyser
#

oh lovely

#

inet not found

#

💀

quartz kindle
#

none of these?

sharp geyser
#

none of them have the ip in it no

#

the last 3 are ipv6

quartz kindle
#

try sudo dpkg-reconfigure network-manager

sharp geyser
#

Network manager not installed

quartz kindle
#

Lol

sharp geyser
#

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

quartz kindle
#

show the contents of /etc/network/interfaces

sharp geyser
#

does not exist

#

/network doesnt even exist

quartz kindle
#

wtf

sharp geyser
#

No way uninstalling python 3.10 does this

#

Something else had to have happened

proven lantern
#

What framework should I use for making an iOS/android app? Svelte native?

quartz kindle
#

sudo nano /etc/network/interfaces doesn work?

sharp geyser
#

nope

#

doesnt exist

quartz kindle
#

youre forked

sharp geyser
quartz kindle
#

are you sure you didnt run rm -rf /?

sharp geyser
#

im sure because all my shits still there

#

and im not that dumb

quartz kindle
#

lmao

#

try creating a /etc/network/interfaces file

sharp geyser
#

ok

#

done

quartz kindle
#

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

sharp geyser
#

🤣

#

ifdown not a valid command

#

God damn im screwed

#

At this point bout to just fuck all my shit and just reinstall the os

quartz kindle
#

erxdee

sharp geyser
#

like idfk why uninstalling python does this shit

#

No way stuff is that reliant on python its sad

quartz kindle
#

also, apparenry onubuntu 18+ its /etc/netplan/ not /etc/network/interfaces

sharp geyser
#

thanks

quartz kindle
#

check if netplan exists

sharp geyser
#

netplan doesnt exist

#

file does

#

cmd doesnt

quartz kindle
#

at this point im curious

#

what would happen if you simply reboot?

sharp geyser
#

good question

#

lets find out shall we

quartz kindle
#

xD

sharp geyser
#

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

quartz kindle
#

so, the lesson is