#development

1 messages ยท Page 249 of 1

quartz kindle
#

never uninstall python

sharp geyser
#

Dont fuck with python, cause that shit hurts

quartz kindle
#

ubuntu 20 requires python to run all these:

gnome-control-center
gnome-session
gnome-terminal
network-manager-gnome
ubuntu-desktop
ubuntu-desktop-minimal
ubuntu-drivers-common
ubuntu-minimal
ubuntu-release-upgrader-core
ubuntu-release-upgrader-gtk
ubuntu-session
ubuntu-standard
ubuntu-system-service
#

lmao

#

uninstalling python literally kills linux

sharp geyser
#

Note to self

#

dont fuck with python 3.10

#

Works again

#

ty <3

#

learned something new though

#

Now I know how to troubleshoot minor network problems at least

quartz kindle
sharp geyser
#

nah I tried that thing in stack overflow

quartz kindle
#

which one

sharp geyser
#

Was able to connect my vps back to the internet

quartz kindle
#

which answer

sharp geyser
#

first one

#

running ip link set and dhclient worked

quartz kindle
#

ah cool

#

good to know

#

for future reference

sharp geyser
#

netplan still not a command tho

#

so yikes

#

Gotta figure that one out

#

pretty sure a lot of packages that come with ubuntu got uninstalled when python did

#

due to purging packages after uninstalling python3.10 & python3.9

quartz kindle
#

ye

#

you need to install all of them back

sharp geyser
#

welp gg

#

probably more annoying than reinstalling ubuntu

quartz kindle
#
sudo apt-get update && sudo apt-get upgrade
sudo apt --fix-broken install
sudo apt-get purge network-manager
sudo apt-get install network-manager --fix-broken
sudo apt-get install ufw --fix-broken
sudo apt-get install python3:any --fix-broken
sudo apt-get install ubuntu-desktop
#

probably dont need the last one since its not a desktop

sharp geyser
#
W: https://download.docker.com/linux/ubuntu/dists/focal/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
E: The repository 'https://ppa.launchpadcontent.net/certbot/certbot/ubuntu jammy Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
#

wtf does this mean

quartz kindle
#

you need to reset the certbot repository

#

just do the certbot installation process again

#

ig2gsleepgoodluckkthxbye

sharp geyser
#

ty

pearl trail
sharp geyser
#

Right so, classic question. Who should I go through for quality US servers?

#

october 26th my contabo vps contract runs out, and I dont want to go with contabo anymore

#

hetzner us servers also sadly aren't the best in terms of price and not to mention idek what exactly cpu I am getting

pearl trail
#

either gcp, aws, or azure

#

that's my suggestion

#

choose the big companies

sharp geyser
#

yea

#

price is a concern

#

aws is fucking expensive as hell

#

azure and gcp are also

#

for what you get its not worth it imo

pearl trail
#

those are "quality servers" I know. maybe wait for others suggestions

#

digital ocean also expensive af

sharp geyser
#

I mean fair enough, they are quality but expensive

pearl trail
#

yeah lmfao

digital swan
#

Vultr is a bit cheaper than digital ocean for the performance

pearl trail
#

iirc it's contabo that has bad support and slow machine?

raven nexus
#

is it possible to make a command if the user already vote and make they allow to use specific command?

earnest phoenix
#

yes

red jolt
#

Any idea why the activites not working anymore for my bot?

#

How can I register a primary entry point command?

#

It worked yesterday but now I can't even launch it.

eternal osprey
pearl trail
#

lmao

raven nexus
#

or how could make it detect?

pearl trail
#

you can use api, but it's limited to the first 1000 votes iirc, and there's no way it'll be live

#

use webhook instead

#

and save the sent data from topgg to your desired db, and handle it by yourself

raven nexus
#
const { ApplicationCommandType, AttachmentBuilder } = require('discord.js');
const Canvacord = require('canvacord');
const Level = require('../../models/level');

module.exports = {
    name: 'levels',
    description: "Check your current level and experience points",
    type: ApplicationCommandType.ChatInput,
    cooldown: 10000,
    run: async (client, interaction) => {
        const guildId = interaction.guild.id;
        const memberId = interaction.user.id;

        try {
            // Fetch user level data from the database
            let userLevelData = await Level.findOne({ guild_id: guildId, member_id: memberId });

            if (!userLevelData) {
                // If no data found, initialize new data
                userLevelData = new Level({ guild_id: guildId, member_id: memberId });
                await userLevelData.save();
            }

            const { level, experience } = userLevelData;

            // Simulate gaining experience for interaction
            userLevelData.experience += 10;
            if (userLevelData.experience >= userLevelData.level * 100) {
                userLevelData.experience = 0;
                userLevelData.level += 1;
            }

            // Update the database with the new level data
            await userLevelData.save();

            // Create a level card using Canvacord
            const rank = new Canvacord.Rank()
                .setAvatar(interaction.user.displayAvatarURL({ format: 'png', size: 512 }))
                .setCurrentXP(userLevelData.experience)
                .setRequiredXP(userLevelData.level * 100)
                .setLevel(userLevelData.level)
                .setRank(1, 'RANK', false) // Assuming rank 1 for demonstration; replace with actual rank if available
                .setStatus(interaction.user.presence ? interaction.user.presence.status : 'offline')
                .setProgressBar('#FFFFFF', 'COLOR')
                .setUsername(interaction.user.username)
                .setDiscriminator(interaction.user.discriminator);

            rank.build()
                .then(async data => {
                    const attachment = new AttachmentBuilder(data, { name: 'rankcard.png' });
                    await interaction.reply({ files: [attachment] });
                });
        } catch (error) {
            console.error(error);
            await interaction.reply('There was an error fetching your level data. Please try again later.');
        }
    }
};

what did i do wrong after fixing it show as Canvacord.Rank

#

what shoudl i add then?

#

i cannot used embed right?

deft wolf
#

You may be using some outdated guide/code

raven nexus
#

it need some custom font as i read in the doc

deft wolf
#

I have no idea, I've never used this library

raven nexus
deft wolf
#

No library that would manipulate the image in any way. I just don't create functions like that

raven nexus
#

there is no other?

deft wolf
#

They definitely exist, but Canvacord seems to be quite popular

lyric mountain
#

TIL there are libs to generate profile cards

raven nexus
#

ohh

#

did i do something wrong?

const express = require('express');
const bodyParser = require('body-parser');

const createServer = (client) => {
    const app = express();
    const port = 3000; // Change this to your preferred port

    // Top.gg webhook token
    const TOP_GG_WEBHOOK_TOKEN = 'xxxx';

    // Middleware
    app.use(bodyParser.json());

    // Verify the webhook token
    const verifyToken = (req, res, next) => {
        const token = req.headers['authorization'];
        if (token !== `Bearer ${TOP_GG_WEBHOOK_TOKEN}`) {
            return res.status(403).send('Forbidden');
        }
        next();
    };

    // Handle top.gg vote events
    app.post('/topgg-webhook', verifyToken, (req, res) => {
        const event = req.body;

        if (event.type === 'voted') {
            const userId = event.user;
            console.log(`User ${userId} voted for the bot.`);
            // Notify the bot about the vote if needed
            // Example: client.emit('topggVote', userId);
        }
        
        res.sendStatus(200);
    });

    app.listen(port, () => {
        console.log(`Server is running on port ${port}`);
    });
};

module.exports = createServer;

it dont reply anything it dont give any error or any notification sadyee

lyric mountain
#

why do you think it errored?

#

ah, right, no console log

raven nexus
#

i have try to vote myself

#

no popup coming as log

lyric mountain
#

did you put the correct url on topgg?

raven nexus
#

ah token?

lyric mountain
#

url

raven nexus
lyric mountain
#

you need to put a url there yes

raven nexus
#

what url i should put ?

lyric mountain
#

and something you want to use as a password

lyric mountain
#

as in, the server where ur bot is running

raven nexus
#

ummm
you mean the discord,gg?

#

the server link right

lyric mountain
#

server as in machine, not discord server

raven nexus
#

like this one?

lyric mountain
#

I think so

#

if that's what points to your vps

neon leaf
raven nexus
#

they got 2

#

server ip

#

and hostname

#

both also ip

neon leaf
#

copy the ip

raven nexus
#

ok done

#

and what do i need to put for authorization?

lyric mountain
#

anything, it's you who define the authorization token

#

but whatever u put there you should also put on your code

civic scroll
#

remember to store it somewhere safe

#

don't put it directly in your source code

lyric mountain
#

hi sayu

civic scroll
#

use environment vars or files

civic scroll
lyric mountain
#

also remove the Bearer from here, topgg will send exactly what you put in that field

raven nexus
#

so i should add the webhook url : XXX.XXX.XXX

and the authorization : XXXX (key)

inside my code also? or just use the token that i put above

#

already fine

civic scroll
raven nexus
civic scroll
#

use environments

#

either via environment variables, or use an environment file (with dotenv library)

raven nexus
#

ohh

#

so put the token in the dotenv then

civic scroll
#

you already using that to store your bot's token?

raven nexus
#

ya

civic scroll
#

that's great, you can also put the authorization key there as well

#

along with the address

raven nexus
#

ok

raven nexus
#

after i add the ip

#

it give this

neon leaf
#

did you put the full url

raven nexus
#

you told me to ip only?

neon leaf
raven nexus
#

ok

#
const express = require('express');
const bodyParser = require('body-parser');
require('dotenv').config(); // Load environment variables from .env file

const createServer = (client) => {
    const app = express();
    const port = process.env.PORT || 3000; // Use port from .env or default to 3000

    // Top.gg webhook token and additional config from .env
    const TOP_GG_WEBHOOK_TOKEN = process.env.TOP_GG_WEBHOOK_TOKEN;
    const WEBHOOK_PASSWORD = process.env.WEBHOOK_PASSWORD;
    const ALLOWED_IP = process.env.ALLOWED_IP; // Single allowed IP address

    // Middleware
    app.use(bodyParser.json());

    // Verify IP address
    const verifyIP = (req, res, next) => {
        const clientIP = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
        if (clientIP !== ALLOWED_IP) {
            return res.status(403).send('Forbidden: IP not allowed');
        }
        next();
    };
    
    // Verify the webhook token and password
    const verifyTokenAndPassword = (req, res, next) => {
        const token = req.headers['authorization'];
        const password = req.headers['x-webhook-password']; // Custom header for password

        if (token !== TOP_GG_WEBHOOK_TOKEN || password !== WEBHOOK_PASSWORD) {
            return res.status(403).send('Forbidden');
        }
        next();
    };

    // Handle top.gg vote events
    app.post('/topgg-webhook', verifyIP, verifyTokenAndPassword, (req, res) => {
        const event = req.body;

        if (event.type === 'voted') {
            const userId = event.user;
            console.log(`User ${userId} voted for the bot.`);
            // Notify the bot about the vote if needed
            // Example: client.emit('topggVote', userId);
        }
        
        res.sendStatus(200);
    });

    app.listen(port, () => {
        console.log(`Server is running on port ${port}`);
    });
};

module.exports = createServer;
#

like this?

lyric mountain
#

why do you have both TOP_GG_WEBHOOK_TOKEN and WEBHOOK_PASSWORD?

raven nexus
#

eh

#

the webhook password

#

is

#

Authorization

lyric mountain
#

no, that's the former

#

x-webhook-password I suppose is filled by your webserver, but that doesnt add any safety layer

#

as any request will need to pass by it anyway, so it'll always be true

raven nexus
#

ok

#

so i just have top_gg token and allowed_ip should be fine right

#

i have send the test thing also notthing has show

pearl trail
#

more expensive than mine (with higher spec also), but still cheap than those big companies

#

datalix

#

$5 for 12gb ram and @4 2.8ghz vcore

#

i've been happy for the performance, and also it's closer than US to me (it's in germany)

neon leaf
#

๐Ÿ”ฅ

pearl trail
#

๐Ÿ”ฅ

deft wolf
#

Too bad they don't have US servers notlikenoot

neon leaf
#

well usa servers are next

neon leaf
#

just a lot easier to offer german servers cuz the owner lives in germany yknow

deft wolf
#

๐Ÿฆ…

neon leaf
#

like 2 hours to datacenter for him

pearl trail
#

i have vpses from all over the world* KEK
-# *only 4

neon leaf
#

when vps in my house

pearl trail
#

wish i can convince my parents to buy me server rack

#

the electricity tho

neon leaf
#

just do it urself smh

pearl trail
#

smh

neon leaf
#

i told mine ill pay 30โ‚ฌ/month for elec

#

and they agreed

pearl trail
#

does your server costs like $500?

#

more or less?

neon leaf
#

pretty much exactly $550

pearl trail
#

hmm fair price

neon leaf
#

I used used parts except for drives

pearl trail
#

ah yeah used parts ism't that bad for servers

neon leaf
#

especially for cpu/case

#

cpus rarely just break

pearl trail
neon leaf
#

wtf

lament rock
#

I have an orange pi with 8 cores and 16GB of ram I use along with gigashit internet

#

SQL can easily handle this! There is a transaction statement but transactions are primarily for MILLIONS of rows or if you want to discard a transaction before it's committed to the data set

pearl trail
#

youre lucky to have gigashit internet for self hosted server

#

if i own my own server, it'll run with d/u 50/10mbps lmao KEK

lyric mountain
#

if you can call native queries then also yes, postgres allows batch inserts

#
INSERT INTO table_name (field, field, field) VALUES
(1, 2, 3),
(1, 2, 3),
(1, 2, 3),
(1, 2, 3),
(1, 2, 3),
(1, 2, 3),
(1, 2, 3),
(1, 2, 3),
(1, 2, 3);
sharp geyser
#

wtf is that := syntax

#

Oh wait thats go

livid socket
#

guys anyone have any tip to not make my bot a unmodififeed shape bot?

deft wolf
#

I don't think there is any option for you to put your bot made with Shapes on top.gg

livid socket
#

bruh ):

bitter granite
#

Sadly you cant
||Ngl I am happy that shapes cant be modefied||

raven nexus
#

i dont understand that the port is use even i change it?

#
const express = require('express');
const { Webhook } = require('@top-gg/sdk');
const TopGG = require(`../models/TopGG`);

module.exports = (client) => {
  const app = express();
  const webhook = new Webhook(process.env.TOPGG_WEBHOOK_AUTH);

  app.post(
    '/dblwebhook',
    webhook.listener(async (vote) => {
      try {
        const userId = vote.user;
        let TOPGG = await TopGG.findOne({ userID: userId });

        if (!TOPGG) {
          TOPGG = new TopGG({
            userID: userId,
            remindersEnabled: true,
            lastVoteTimestamp: 0,
            totalVotes: 0,
            purchasedRoles: [],
          });
        }

        const VoteUser = await client.users.fetch(vote.user);
        const guild = client.guilds.cache.get(process.env.SUPPORT_SERVER);
        const USER = guild.members.cache.get(vote.user);
        const channel = client.channels.cache.get(process.env.TOPGG_VOTE_LOG_CHANNEL);

        const thankYouMessage = `๐ŸŽ‰ Thank you, ${VoteUser.tag}, for your vote! ๐Ÿ™Œ Your support means a lot to us!`;

        console.log(`${VoteUser.tag} Just Voted On Top.gg`);

        TOPGG.lastVoteTimestamp = Date.now();
        TOPGG.totalVotes += 1;

        await TOPGG.save();

        if (channel) {
          await VoteUser.send(`**> Thank you ${VoteUser.tag} for voting me on top.gg**`);
          await channel.send(thankYouMessage);
        } else {
          console.log("Invalid Vote Log Channel");
        }

      } catch (error) {
        console.error(error);
      }
    })
  );

  client.once('ready', () => {
    const PORT = process.env.TOPGG_WEBHOOK_PORT || 3101;
    app.listen(PORT, () => {
      console.log(`Express server is listening on port ${PORT}`);
    });
  });
  
};
neon leaf
#

i mean thats kinda what they are for

#

many changes at once

#

that depend on each other (not necessarily)

lament rock
sage bobcat
quartz kindle
sharp geyser
#

I mean, quality as in theres a name behind it

#

terrible fuckin specs tho

#

Wouldn't pay for them even if it was the last servers left available

quartz kindle
#

they are throttled af

sharp geyser
#

and expensive

#

150$ a month for 16gb with 2vcpu cores

quartz kindle
#

in GCP, your ssd performance scales with how much you pay]

sharp geyser
quartz kindle
#

you need to pay like 50-100+ per month to get the same ssd performance you get anywhere else for $5

sharp geyser
#

Side note

#

I just bullied a kid off a rust server

#

I feel somewhat bad

quartz kindle
#

bully

sharp geyser
#

tbf

#

he picked me up, then killed me again

#

Thats like ultra disrespect in the game

#

So I came back to his raid and fucked em up then raided his base

quartz kindle
#

oh wait

#

rust server, as in, the game?

#

i thought rust server like a discord server for the language lol

lyric mountain
#

aaron killed the programmer dreams of the kid KEKW

sharp geyser
#

๐Ÿ˜ญ

#

yea the game

neon leaf
#

best programming lang ๐Ÿ”ฅ

surreal sage
#

people who selfhost a git service for their personal projects ๐Ÿ˜•

#

i dont want to visit your shitea website mann

winged linden
#

What do you guys usually give out for voters? Tryna incentivize voters

#

Maybe a higher command usage limit for the premium commands

lyric mountain
#

currency

surreal sage
#

does anyone know how to get google to remove safebrowsing's "Dangerous" when the site is literally private? ๐Ÿ˜ญ

#

yes

#

๐Ÿ˜•

surreal sage
lyric mountain
surreal sage
#

for some reason this isn't happening in incognito

lyric mountain
#

I mean, like, with some big name to attest you are legit

#

chrome does not like self-signed certs

surreal sage
lyric mountain
#

for me it's always been an issue on chrome

surreal sage
#

okay nevermind

#

maybe

#

chrome was just absolutely

#

tweaking

lyric mountain
#

I just use CF origin cert

surreal sage
#

now it disappeared......

#

it never was on search console though*

lyric mountain
#

cert cache maybe?

surreal sage
#

cert hasnt changed

#

at least i think

lyric mountain
#

no, I mean, a stale copy was in cache

surreal sage
lyric mountain
#

welp

#

try cloudflare, at least it's guaranteed you wont have issues with anyone

surreal sage
#

well it disappeared now though

#

i closed the window, opened another

#

and tada...

#

very weird

#

also im using traefik for context

frosty gale
lyric mountain
#

I mean, only issue is if ur using an always-open websocket

#

cuz CF periodically drops connections when they hotswap for updates

neon leaf
#

I mean you should have reconnection logic either way

lyric mountain
#

yep

#

also honestly if cf goes down half the internet goes with it

frosty gale
#

it really did amaze me how pushy they are and essentially force you to upgrade to an enterprise plan without saying you have to

neon leaf
#

dont make casino websites

#

on cloudflare

frosty gale
#

its not about the casino, its about the principle

neon leaf
#

it, is definitely mainly about the casino

frosty gale
#

it makes no sense to discriminate against their clients assuming theyre complying with all laws

lyric mountain
#

they probably cranked their plan usage to the maximum for extended periods of time

frosty gale
#

its likely but its mostly about the way they went about it, instead of just reaching out and saying "youre maxing our internal caps please upgrade" they went about it in a very weird way

#

i would expect at least that level of transparency if im a paying client

lyric mountain
#

you could do it yourself, it aint too complicated

#

this is what I do

#

Oh wait, sent the wrong code

#

That's to parse time into millis

#

I'll send the correct one later

lyric mountain
#

Here, image is a bit small cuz I'm on pc

#

It's java but the same formula applies to any lang

digital swan
#

i've got a 'game' where the bot gives a random word from a list and members have to type it as quick as they can

its timed with performance.now, and usually the timing works fine and is consistent
but occasionally/randomly, all of the results show a way quicker time, (maybe around a second quicker?)

is this just discord being wacky with events and stuff or could it be something with my code?

function: https://github.com/mxz7/nypsi/blob/main/src/utils/functions/chatreactions/game.ts#L38

lyric mountain
#

Keep dividing by the millis_in_X till the level you want

lyric mountain
#

Cuz u have 4 different layers of delay

#
  • bot sending message to discord
  • discord shows message to users
  • users send message to discord
  • discord sends event to your bot
digital swan
#

yeah its not intended to be competitive, just hoping to show consistent timings

lyric mountain
#

The accuracy of the time of each one will be waaaay off

lyric mountain
#

Bot to discord u can mitigate kinda, just start counting from the time the message finishes sending

#

For the other 3 it's hard to get any form of precision

digital swan
#

yeah it only starts timing after it sends

#

rip

civic scroll
lyric mountain
#

You can use activities for that game if you must, at least it'll be as close to real-time as possible without IRC-inherent delays

digital swan
#

nah thats too much for it, its existed for over 3 years now i was just tryna perfect that 1 issue

#

surprisingly it works alright as in faster typers are usually the winners

#

but people in australia etc are always at a massive disadvantage

elfin tulip
#

Guys is it me or .setTimestamp() for Embeds is delayed? For example if I send an Embed with timestamp at 1 second after the minute, it still displays the timestamp from the previous minute. So if I execute it at 01:01:01, it shows 01:00 instead of the current minute.

pine willow
#

thats normal i think

#

discord issue i guess

elfin tulip
unique maple
#

how do i stop an email address from being used more than once when using auth.gg email verification bot in my server?

lyric mountain
#

if (emailExists()) return;

#

oh wait, u mean there's a bot for this

#

you'd better ask on their support server, we cant really help with that

frosty gale
#

darn kangaroo people

unique maple
#

when people verify, i can download a CSV file and upload it to a google sheet

#

and im trying to figure out how i can stop people from using the same email more than once

#

because i dont want to ban someone and then they can just join back on a new discord account and use the same email

quartz kindle
#

but i would imagine it to be quite unlikely

pine willow
#

which bot doesnt have a DB

quartz kindle
#

since it would require the bot owner to store third party email addresses, which is a very big privacy breach

unique maple
unique maple
livid socket
#

guys does shape bots ! comamdn count as costum commadns?

unique maple
quartz kindle
#

topgg does not like shapes

pine willow
#

Giving the Ai the prompt to respond to that keywords etc etc is not a custom command

livid socket
#

but it still couldmake goood bot tho right?

quartz kindle
#

yes but it will likely be rejected by topgg

#

you could still use other bot lists tho if they accept it

livid socket
#

how

quartz kindle
#

topgg is a bot list website, there are many others out there

livid socket
#

oh

unique maple
unique maple
quartz kindle
#

someone else owns the bot

pine willow
#

i cant check if the bot is his or not lol

quartz kindle
#

lol

pine willow
quartz kindle
#

it seems the owner already stores third party emails

#

hopefuly its well encrypted

unique maple
unique maple
quartz kindle
#

if its not encrypted, he could very well access and use those emails, send spam, etc

#

and if not him, if his server is hacked, all those emails will be leaked to hackers

#

but i assume the owner of a decent security bot knows all this and took measures accordingly

frosty gale
#

with discord bots its extremely unlikely

#

most bot developers just happened to get a popular bot going and may have decent developer skills but security practically none

#

ive seen massive bots with tons of servers have exposed databases on their dashboards and a lot of very concerning stuff

#

no firewalls either

#

plus ssh with passwords enabled

livid socket
#

@shell tundra i start knowing why top.gg kinda hate shapes now.....

#

it VERY hard to start a new command and acctually make it work ;-;

quartz kindle
quartz kindle
#

shapes does not provide enough features to make bots unique, basically bots made with shapes are very generic, all similar to each other, they all look like clones

frosty gale
pine willow
livid socket
#

who want to try my bot

#

dm me to try :>

bitter granite
proven lantern
#

i got my first subscription! it took me 4 days to notice it

spiral obsidian
pearl trail
proven lantern
#

maybe i'll send myself an sns notification if a new guild is added

#

how does this table look?

  DbPremiumServer:
    DependsOn: DbCounter
    Type: AWS::DynamoDB::Table
    Properties:
      KeySchema:
        - AttributeName: "id"
          KeyType: "HASH"
      AttributeDefinitions:
        - AttributeName: "id"
          AttributeType: "S"
        - AttributeName: "subscription_status"
          AttributeType: "S"
        - AttributeName: "random_seed"
          AttributeType: "N"
      GlobalSecondaryIndexes:
        - IndexName: "subscription-random-index"
          KeySchema:
            - AttributeName: "subscription_status"
              KeyType: "HASH"
            - AttributeName: "random_seed"
              KeyType: "RANGE"
          Projection:
            ProjectionType: "ALL"
      TimeToLiveSpecification:
        AttributeName: "expiration_time"
        Enabled: true
      BillingMode: "PAY_PER_REQUEST"
sage bobcat
#

One message removed from a suspended account.

proven lantern
#

i want to show 10 random premium guilds on my website. my plan is to store all the active subscriptions in here and query using the GSI starting from the random_seed=Math.random()

sage bobcat
pearl trail
#

least obvious scam

proven lantern
#

lol

sage bobcat
#

One message removed from a suspended account.

sage bobcat
unique maple
#

i want to grab their emails, build an email list, and do email marketing

#

i will have their emails and can sell things to them

proven lantern
unique maple
#

Ive never heard of that

proven lantern
#

it's a service that sends out emails and doesn't get blocked as spam because it follows the rules about unsubscribing

#

Each separate email in violation of the CAN-SPAM Act is subject to penalties of up to $51,744

frosty gale
#

you can opt out of emails in most cases but you can do that with blocking anyways

pearl crest
#

yo guys did any one know why new registered discord slash command not showing on my discord server

#

permissions=8&integration_type=0&scope=bot+applications.commands

vivid fulcrum
#

there's too much code to analyze, do you think you could shorten it down a few lines maybe?

#

i'm kidding, you should provide more context if you want help

surreal sage
#

what are open source tools to track status of applications

#

via tcp and/or docker

frosty gale
#

docker lets you see the health check logs and when the health check fails

surreal sage
#

nono

#

like betterstack status

#

just something for more internal use

frosty gale
#

oh that thing

surreal sage
#

i want to see the status of like my 18 docker containers' app

frosty gale
#

i heard of one but its more for front facing websites so its quite vague in its detail

chrome grail
#

Cachet

frosty gale
#

yeah cachet

#

for customers and people id recommend it but i dont think its maintained anymore and if you want an internal one youd want more detail anyways

#

nevermind they still sort of maintain it

#

@surreal sage grafana?

#

its basically designed to integrate with almost anything including docker and tcp

surreal sage
frosty gale
#

it also supports integration with Prometheus but thats likely too complex for your use case

surreal sage
#

i love coolify

frosty gale
#

skill issue

surreal sage
#

prometheus right

frosty gale
#

can you do a custom integration?

surreal sage
#

idk!!

#

cadvisor

frosty gale
#

id honestly just write my own health checker from scratch and then setup some ui to view everything from a database

#

relying on supported software for tracking limits your options

surreal sage
#

it doesnt have to be advanced

frosty gale
#

but if youre using it purely for docker im sure theres dedicated solutions for that

quartz kindle
#

lmao

pearl trail
sharp geyser
#

also disable link

cunning stump
#

ู‡ู‡ู‡ู‡

quartz kindle
pine willow
#

this saves so much time KEKW

pine willow
surreal sage
#

What database do you guys recommend for a server list

#

Game server instance list

#

Not exactly persistent but data should stay during restarts/crashes of the API

sharp geyser
#

so persistent

#

๐Ÿ’€

#

Any database will do really

rare merlin
#

anybody know a good mongoose plugin to automatically encrypt certain fields and allows me to query encrypted fields (with the decrypted value)? I was looking at mongoose-encryption but it seems the only way to query encrypted fields is by doing this:

const allModels = await Modal.find(); // returns all documents with their decrypted values
const specificModel = allModels.find(({ field }) => field === "decrypted value");```
neon leaf
#

there is no other way

#

maybe you should not search by encrypted fields instead

surreal sage
#

pre-save

#

events

#

where you can modify documents

#

does zod

#

support

#

defaults

#

yes it does

#

im just very blind

quartz kindle
surreal sage
#

3.5

#

is good enough

prime cliff
#

vibecat First preview version of my project is now interactable https://devspace.fluxpoint.dev
It's gonna be an advanced version of Portainer, Sentry and other developer tools with server/website/project management features.

prime cliff
#

Thanks got most of the basic features done including full 2FA support โค๏ธ passkeys

quartz kindle
#

5s to load js files

#

890kb js file lol

prime cliff
#

Yea there is no compression on that file still in development, there's also a few other tweaks i can do to make it faster that i can look into

quartz kindle
#

once it loads its fast, but first load is 6+ seconds of black screen

rare merlin
#

how does top.gg protect itself from sending a webhook to a server that will collect it's IP and attempt to DDoS?

prime cliff
#

FacePalm why are you even asking that kind of question in the first place

rare merlin
prime cliff
#

The 2 things you can do is setup a proper linux firewall to block outside connections on all ports and allow stuff like your own ip and cloudflare ips to port 443 which will prevent ddos.
You could use another server to act as a proxy that all webhook requests use and your main server ip is not exposed.

rare merlin
prime cliff
#

Yea you can do that cloudflare domain

real rose
#

linux firewall, my lover.

prime cliff
#

Use that and create a timed cron job to run every hour, that will add cloudflares ips to your firewall on port 443 (ssl https port)

rare merlin
#

wouldn't this block those requests

prime cliff
#

The public api is running through cloudflare though?

rare merlin
#

i suppose

prime cliff
#

Everything running through cloudflare will be allowed with that script just that noone else can connect directly to your vps

#

Cloudflare has ddos mitigation/protection so that works best

#

My project i'm doing will also have some nice firewall stuff vibecat

rare merlin
prime cliff
#

Just the 1st one since second is already default allow

#

Make sure to add your ip first too otherwise you wont be able to remote ssh xD

rare merlin
#

ahh i misread, i thought they were both deny

rare merlin
frosty gale
prime cliff
#

Is that running through cloudflare too?

rare merlin
#

wrong ping

prime cliff
#

*wrong reply ๐Ÿ˜›

surreal sage
#

Does anyone have a

#

uhh

#

npm package

#

written in typescript

#

that has a new Client() for api

#

with post methods

#

etc

#

i need a template to work off

#

nvmmm

#

!!

frosty gale
#

something interesting i found in brave

quartz kindle
#

Chrome is prone to a remote code-execution vulnerability. Specifically, this issue arises when the V8 JavaScript engine handles malformed JavaScript code. Malicious JavaScript code may gain unauthorized access to memory, allowing the attacker to obtain sensitive information and execute arbitrary code in the Chrome sandbox. Failed attacks may cause denial-of-service conditions caused by a renderer (tab) crash.

The attacker can exploit this issue by enticing an unsuspecting victim to view a malicious webpage.

#

interesting

frosty gale
#

i think its mostly an attack that is possible

#

the v8 optimizer compiles some of your code to assembly/binary so the same paths/snippets can run faster

#

if an attacker can somehow influence the assembly/binary that is generated or control execution flow you could thereotically escape the VM and get remote code execution

#

if there is no optimizer that doesn't happen and javascript is interpreted on the go

#

if you have bad js code the worst that can happen is v8 crashing from a bug or a buffer overflow perhaps

quartz kindle
#

so far what i've been able to find was limited to some native node modules

#

being able to pre-compile malicious code and have v8 execute it

#

so i dont think browsers are directly affected, yet

north turtle
#

Hello it's me again and this will be final reply. sorry
The day before yesterday I had physical access to the server.
But I was really stupid and stupid
It wasn't a hack or a virus
It's just that my home internet had a dynamic IP and it changed once on 8/13.
After that, I kept trying to access the IP before it changed.
But just in case, I did a clean install.
I also used the router's DDNS feature to provide permanent access even from a dynamic IP.
Thanks, sincerely

lament rock
quartz kindle
#

isnt wasm even more sandboxed than js?

#

but yeah i guess

frosty gale
#

the core execution is the same except wasm allows more fine-tuned access to things

#

theyre still both interpreted and have some parts of it compiled into machine code

quartz kindle
#

wasm cant access aanything that js cant

#

in a browser at least

#

idk about purposeful memory corruption but i would imagine wasm uses a sandboxed memory region as well

#

but if we wanna target/manipulate v8`s compiler itself, wasm only has 2 compilers (liftoff, turbofan), js has 4 (ignition, sparkplug, maglev, turbofan)

past field
#

anyone willing to help me figure out what's going on with my game? smile_creepy

#

codes a but lengthy but mainly because of the logging... but i made another version of my click war game ( @quartz kindle knows about it) called Chaotic Click War but i'm trying to make it to where round 20, players who were previously eliminated can jump back in with 5 lives, or if you're still active you just gain 5 lives - but players get interaction failed when trying to jump back in, but i get no errors in the logs!

#

specifically, this is what handles the special round 20 button

#

oh wait.. is it because i have it defering the interaction and well as sending the ephemeral?

#
 await i.deferUpdate();
``` should i just get rid of this?
#

idk

#

use

#

instead?

past field
lyric mountain
#

Where is the part where you send the "you are not eligible"?

#

Nvm found it

#

Ok so, the user is neither in game.players nor game.lastEliminated

#

As being in either would mean not reaching the else

#

Are them supposed to be in either?

past field
# lyric mountain Are them supposed to be in either?

so the users who are using that button to jump back on the game are players who were eliminated in any round from 1-19, and if they werenโ€™t eliminated then they just gave 5 lives to their current count. so anyone thatโ€™s eligible is basically anyone who joined the game

lyric mountain
#

Ok ok, but then they are supposed to be there

#

Where are u removing them?

past field
lyric mountain
#

But are u ever removing from game.players?

#

Cuz you have to be somewhere, and in that place it'll not be adding to lastEliminated too

past field
lyric mountain
#

And then added to lastEliminated?

past field
lyric mountain
#

Show that part please

#

In some specific scenario it's not doing that transference properly

past field
lyric mountain
#

Which is why ur getting the "not elligible" issue

#

I'd actually advise never to remove the players, but set some variable to know they're no longer playing

#

This way you avoid both getting such issues and allocating a new array

#

oh ok, you're definitely getting a race condition there

past field
#

ah that makes more sense

lyric mountain
# past field am i?

Very likely, you're never checking if the turn that event is seeing is the same turn it was expected to see

#

Try saving the current turn somewhere before creating that collector

#

Then use if (turn === game.turn) or smth

#

Or have a variable somewhere to indicate the event was already ran

#

To prevent it from ever passing twice on the same code

#

Since ur reassigning game.lastEliminated

#

Optionally, put a console.log right before u reassign it

#

To see what array it's passing to that variable

#

Perhaps your filter isn't working as u expect too

pine willow
#

Ai spotted

#

Well it looks like it

past field
past field
pine willow
#

Alright. Good luck with your bot or other Project!

past field
#

put them in a room and tell them when they can come back in instead of kicking them out of the house and locking the door

lyric mountain
#

Yes I know, but the issue is in the part you're setting lastRemoved

#

Something there isn't doing what it should do

#

So put some logs there to check each value

past field
#

ok i think i see what youโ€™re saying g

proven lantern
#

idk if this has anything to do with it.

let playersToEliminate = [{id: 1}, {id: 2}];
let game = {};
game.lastEliminated = playersToEliminate;
playersToEliminate.push({id: 3});
console.log(game.lastEliminated); // [{id: 1}, {id: 2}, {id: 3}]
let playersToEliminate = [{id: 1}, {id: 2}];
let game = {};
game.lastEliminated = [...playersToEliminate];
playersToEliminate.push({id: 3});
console.log(game.lastEliminated); // [{id: 1}, {id: 2}
quartz kindle
civic scroll
#

in the first example, both playersToEliminate and playersEliminated are pointing to the same array, even though they are supposed to be different

#

2nd example eliminates that by explicitly constructing a new array from the prior via spread syntax

#

a shallow copy iirc

frosty gale
#

not sure why were still using javascript here when we should be using Rust

#

@quartz kindle

bitter granite
civic scroll
#

maybe if rust can be interpreted, perhaps people will hook in

proven lantern
#

why would you use rust in a sandbox when you could use zig

frosty gale
#

i considered adding zig as a comparison language but figured it would give you too much validation

proven lantern
#

you're going to love zig

lyric mountain
quartz kindle
# frosty gale <@180112943612952577>

can run in the browser: โœ… โŒ
does not need compilation: โœ… โŒ
very easy to use and code in: โœ… โŒ
extremely hackable: โœ… โŒ

neon leaf
#

tim approved: โœ… โŒ

quartz kindle
#

xDD

#

has 4 different JIT compilers: โœ… โŒ

pearl trail
#

i love it: โœ… โŒ

surreal sage
#

is

#
const str = `${undefined}`

str === "undefined"
// or
str === ""```
#

too lazy to check

neon leaf
#

first

surreal sage
#

damn

#

js sucks!! (<-- jsx nerd, null fan, not the person below)

radiant kraken
pearl trail
#

๐Ÿ™€

radiant kraken
#

javascript and rust are overrated

#

use C

neon leaf
#

all langs are overrated

#

just do x86 assembly

#

arm & riscv are cringe

pearl trail
#

that also cring

#

i use my brain's language

#

my gov forced kids to make their brain a compiler

radiant kraken
pearl trail
#

frfr

radiant kraken
#

i've been staring at this C code for hours now because i'm too scared to debug it

#

๐Ÿ˜ญ

earnest phoenix
radiant kraken
earnest phoenix
radiant kraken
#

nope

#

i gave up on that

ionic schooner
#

You cheater

#

Youโ€™ve betrayed us

past field
#

works!!!!

earnest phoenix
warm surge
radiant kraken
neon leaf
#

๐Ÿ”ฅ

harsh nova
sage bobcat
#

One message removed from a suspended account.

harsh nova
#

Running the 7950x3D

neon leaf
#

I mean I wouldve waited for x3d

#

but i need to switch asap cuz im in intel 14th gen

#

and already had 5+ crashes last week

sharp geyser
sharp geyser
#

๐Ÿ’€

neon leaf
#

well I got it for free

#

so lmao

#

(amazon managed to send me 2 cpus)

sharp geyser
#

Wth

#

Lucky mf

#

Lmk if you dont need the second one

#

๐ŸงŒ

neon leaf
#

im selling it on ebay sir

sharp geyser
#

how much ๐Ÿ‘€

neon leaf
#

650โ‚ฌ

sharp geyser
#

Damn

#

Bros charging more than retail

#

im sure someone will buy it tho

#

they are getting out of stock in a lot of major retailers

past field
#

you guys are truly the best

sharp geyser
#

we know

green kestrel
sharp geyser
green kestrel
#

i have Ryzen 7 5700x

sharp geyser
#

I heard thats a pretty decent one

#

for its price anyway

#

@neon leaf lmk how the 9900X is

#

Theres already a passmark report for it, but since its only 1 its not very believeable

radiant kraken
neon leaf
#

Pc almost ready

sharp geyser
proven lantern
solemn latch
#

the 9900x is very efficent

sharp geyser
#

do you have it?

solemn latch
#

all of the 9000 series are an efficency upgrade more than a performance upgrade from what I've heard

#

I dont ๐Ÿ˜ฆ

#

still waiting on 11000 series

sharp geyser
#

ic

#

the 11000 series likely isnt coming until mid 2025 no?

solemn latch
#

It will be a long time

#

I shouldnt need an upgrade for a long time anyway

sharp geyser
#

nah I predict 2025

#

amd will continue on their steamtrain going past intel

solemn latch
#

I would expect the x3ds to be coming out still in 2025

sharp geyser
#

After intel's fuck up with the 13 and 14th gen chips

sharp geyser
#

Like Feb 2025 is what I heard

solemn latch
#

Then my upgrade will hopefully be in 2026-2027

#

Should have plenty of power until then

#

I still have my 5900x under volted dramatically

frosty gale
neon leaf
#

alr it boots

sharp geyser
#

I've got an intel i7

neon leaf
#

i was scared to death

sharp geyser
#

in my macbook

neon leaf
#

ill pick up the gpu tomorrow

solemn latch
#

Congrats on the upgrade!

neon leaf
#

time to fix bios settings now

pine willow
#

Thank god i added a weekly stats reset

quartz kindle
sharp geyser
#

its higher than a trillian duh

pine willow
quartz kindle
#

you mean this?

sharp geyser
#

idk

#

maybe

quartz kindle
#

although in portugal thats 1 billion

pine willow
#

I have trillion after Billion???

#

and after trillion this comes

#

and i wrote the name

#

otherwise it would be T twice

#

or did i do smth wrong

sharp geyser
#

what

#

in

#

the

#

fuck

pine willow
#

WHat

quartz kindle
#

some countries use million->billion->trillion
other countries use million->milliard->billion->billiard->trillion
other countries use million -> thousand millions -> billion -> thousand billions -> million billions -> thousand million billions -> trillion

sharp geyser
#

What in the fuck is a milliard

#

I swear you countries are more confusing than the US

#

Million, Billion, Trillion

#

simple

quartz kindle
sharp geyser
#

anyway speaking about millions let alone billions is wild for me, I will never see that amount of money

#

๐Ÿ’€

deft wolf
quartz kindle
#

Previously in British English (but not in American English), the word "billion" referred exclusively to a million millions (1,000,000,000,000). However, this is not common anymore, and the word has been used to mean one thousand million (1,000,000,000) for several decades.[4]

The term milliard could also be used to refer to 1,000,000,000; whereas "milliard" is rarely used in English,[5] variations on this name often appear in other languages.

In the Indian numbering system, it is known as 100 crore or 1 arab.

deft wolf
#

๐Ÿค”

sharp geyser
#

yea tim

#

Ima be real

#

Im american

quartz kindle
sharp geyser
#

my brain is simple

#

that mumbo jumbo means nothing to me

#

All I know is million is a lot, same with a billion

#

trillion is unobtainable

quartz kindle
#

surprisingly a lot of countries use long scale

sharp geyser
#

Oh look

#

Antartica uses both scales

quartz kindle
#

damn scientists

real rose
#

me when science

sharp geyser
#

me when ur mom

real rose
#

what the fawk

sharp geyser
quartz kindle
#

Dutch-speaking
10^6, miljoen; 10^9, miljard; 10^12, biljoen; etc.

French-speaking
10^6, million; 10^9, milliard; 10^12, billion; etc.

Portuguese-speaking (except brazil)
10^6, milhรฃo; 10^9, mil milhรตes or milhar de milhรตes; 10^12, biliรฃo

Spanish-speaking
10^6, millรณn; 10^9, mil millones or millardo; 10^12, billรณn; etc.

sharp geyser
#

cmon tim

#

you should know this

quartz kindle
#

im speaking english

sharp geyser
#

nuh uh

quartz kindle
#

half of that message is in english

sharp geyser
#

milhรฃo

#

is not english

quartz kindle
#

or is english

#

and so is 10^9

sharp geyser
#

ok buddy

#

Actually

#

thats not only english

#

a lot of languages use numbers like that

quartz kindle
#

including english

#

therefore is not rule-breaking

#

:^)

sharp geyser
quartz kindle
#

oh no how scawy

timber hatch
#

do any devs here know of any freelance legal advisors that specifalise in UGC web app compliance?

i'm building a web app, but i'm not exactly a lawyer. Obviously i understand the general consensus of GDPR and stuff. But want to cover all bases prior to launch to ensure i'm compliant.

I realise it's not strictly a dev question, but since you guys are devs (often building your own web apps) i just thought you might be able to point me in the right direction. smile_frog

sharp geyser
#

@quartz kindle Got a question for you

#

I recently had this dumb idea, (as in 3m ago) to try my hand at making a database, not anything special really just a file database. Do you know what my first steps should be?

#

Theres a lot of information online, but a lot of it seems conflicting

quartz kindle
sharp geyser
#

I'd like to mimic a nosql type database

quartz kindle
#

with schemas or without schemas?

#

like pre-defined tables/structures, or freely editable json-like

harsh nova
lyric mountain
#

doing a json-like would prolly be the easiest option to start

neon leaf
#

I can prob run another passmark rn

fleet flower
#

Hello

sharp geyser
#

I dont want anything too crazy

#

I mainly am trying to write my own db solution for my plugins I make in rust (game)

#

The options they provide are absolutely terrible

#

and to use anything else in mono / netstandard 2.1 is annoying asf

quartz kindle
#

in any case, its a good idea to start with a key-value engine

#

you could use something like lmdb and build on top of that

#

or make your own from scratch of course

#

you will need to decide how to do the indexing, chose between hash table and b/b+ trees

sharp geyser
#

I feel like making my own from scratch would be more fun

#

but without a clear guide on what to do it will be more challenging

quartz kindle
#

so imagine this

#

you have keys and values

#

keys have to be converted into a fixed size

#

so you need to chose a hashing algorithm

sharp geyser
#

I see

quartz kindle
#

you hash the key, then you store the key hash into either a hash table, or a b+ tree

#

the key hash leads to another fixed-size value, a number representing some sort of location or position

#

could be the node number of a file on disk for example

#

then on the data itself you store both the non-hashed key and the full value

#

so basically:
key -> hashed key -> table/tree -> file index/number/position -> key+data

#

if you want multiple items per file on disk, you can define something like a bitwise number/index that contains file id and start position inside file

frosty gale
#

i made my own database and its not fun if you want it to be somewhat useful

neon leaf
#

@sharp geyser

quartz kindle
#

nice

sharp geyser
#

I will have to look into this more

#

should be fun :P

quartz kindle
#

the most complicated part is implementing the hash table or b+ tree

#

so you could instead use some library for that

#

the rest shouldnt be much difficult

sharp geyser
#

yea

#

I will look into it all

quartz kindle
#

i've never done trees before, but i did a hash table, if you wanna go that route

sharp geyser
#

Alrighty! Thanks a lot for the information :P

#

I have to try and make this as efficient as possible

#

anything that slows you down in a rust plugin is bad

neon flicker
#

Where may I view all the interaction.is...() functions? I couldn't really find them in the documentation

#

Such as interaction.isChatInputCommand()

lyric mountain
#

ctrl + space

quartz kindle
#

if you want best key-value read/write performance, hash tables are good, otherwise if you need ranges, searches and flexibility, trees are better

sharp geyser
#

ic ty

eternal osprey
#

hey guys

neon leaf
#

hi

eternal osprey
#

i have a very complex image i want to create in htm;/css.
though, i am just thinking should i just create an image in photoshop and import it?

#

Cuz i feel like the image i want to recreate will be ahrd to dynamically scale

quartz kindle
#

you want to recreate an image with raw html/css? like with elements and styling?

eternal osprey
#

yeah

#

i might just create an imnage to be fair

#

it's way too hard using css etc cuz the image is pretty complex

quartz kindle
#

complex as in what exactly?

#

because if its only geometry, lines, shapes, etc, then you can use SVG

#

but if its pixels like textures, shades, gradients, shadows, then it has to be an actual image

eternal osprey
#

let me send you a screenshot

quartz kindle
#

do you absolutely need it to be scalable to infinity?

#

you can simply make a high-res image and resize it to multiple size breakpoints

#

then serve each according to screen size/pixel density

eternal osprey
#

i have an svg generated of it, that scales pretty well right?

#

I could simply use bootstrap's grid system and breakpoint system to break it on small sized screens

quartz kindle
#

if it generated a good looking one without weird lines and edges, then youre good to go

eternal osprey
#

yessirr!

#

Let's go

#

thanks

sharp geyser
#

@quartz kindle do you have the docs for lmdb

#

implementing a b+ tree looks more annoying than I thought

#

๐Ÿ’€

eternal osprey
#

it works like a charm tim, thank you!

quartz kindle
sharp geyser
#

Im using C#

#

Also

#

is lmdb just an already made db?

quartz kindle
#

its like offline redis, sort of

#

but more barebones

sharp geyser
#

I see

quartz kindle
#

many databases use lmdb behind the scenes

sharp geyser
#

so its up to me to build it up and make more features

quartz kindle
#

ye

sharp geyser
#

Gotcha

#

well

#

looking up LMDB C# returns me shit from 6+ years ago

quartz kindle
sharp geyser
#

Oh shit

#

thanks

#

Noq

#

Question

#

If you were using a database, what features would you want

quartz kindle
#

well, i dont need much, i usually make my shit pretty dead simple

#

im using lmdb right now

#

only using sqlite for some more important stuff like user accounts

sharp geyser
#

๐Ÿ’€

#

I see

quartz kindle
#

not a lot of people know this

#

but there is a very good lmdb lib for node

#

which can be easily used to make a persistent cache that supports multiple processes

#

and its sync

#

imagine if bot devs knew about it

#

:^)

sharp geyser
#

hell would break loose

#

mongo would lose money

#

the day bot devs become smart

#

is the day pigs fly

brave saddle
#

@empty steppe could you please give an update on what going on with your bot?

sharp geyser
quartz kindle
sharp geyser
#

oh cool

quartz kindle
#

i've also used messagepack in a few projects

sharp geyser
#

I was thinking of using messagepack in someway

#

but im not exactly sure how it works

quartz kindle
#

and one of my shelved projects is a competitor to messagepack, or it will be some day lol

quartz kindle
#

converts objects into buffer, and buffer into objects

#

looks like memorypack is a more specific format for C#, so its probably better than messagepack

#

messagepack is a more generic format

sharp geyser
#

How exactly does get/set or get/init work in C#

#

I notice some people make private fields and then have public get / sets for that private field

#

like wtf is the point then?

scenic kelp
#
public int Property { get; set; }

is equivalent to

public int <Property>k__backingField;
public int Property { get => value; set => <Property>k__backingField = value; }
#

which getters and setters are further reduced down into actual methods

#

the reason for doing that is to reduce coupling* since fields are not a part of a class' public interface whereas methods are (think about how you cannot have a field in an interface)

sharp geyser
#

I see

#

how does init work?

#

Because I want a "readonly" field, that only gets set once at class instantiation

#

From there on it should be read only, and unchangeable

scenic kelp
#

although if it's constant you could also do say

public int FavouriteNumber => 25
sharp geyser
#

what is this => notation

scenic kelp
#

just shorthand for a get-only property

#

in that context

sharp geyser
#

I see

#

so it sets it to 25 and from there on out its get only

scenic kelp
#

kinda inline with the syntax for lambdas and expression bodies

public int GetFavouriteNumber() => 25
``` that would make a method that returns 25
scenic kelp
sharp geyser
#

oh?

scenic kelp
#

that's one weird part

#

but it's important to understand

sharp geyser
#

So it only "gets" 25?

scenic kelp
#

yes

sharp geyser
#

interesting

scenic kelp
#

if you did like DateTime.Now for example

sharp geyser
#

Im not quite sure how I would use this then

scenic kelp
#

it would always get the current datetime

sharp geyser
#
    public class ImpulseDb : IDisposable
    {
        private bool _isDisposed = false;

        private string? _dbPath = null;

        private LightningEnvironment? _env = null;

        public ImpulseDb(string databasePath)
        {
            _dbPath = databasePath;
        }
#

see I want _dbPath to be get only

#

and have it set only when ImpulseDb is instantiated

#

would I just do {get; init; } and then set it in the constructor?

scenic kelp
#

if you're prefixing it with a _ then by convention it should be a private field and not a property

#

so you should be using readonly rather than an init property

#

you should only be using properties for things you want to expose on your class's interface

sharp geyser
#

I see

#

fields = internal use
properties = other people use
this sound about right?

scenic kelp
#

p much

#

there's cases where you might want private properties but few and far between

#

they're there to reduce coupling

sharp geyser
#

I see

#

Now while you are here I have another question

scenic kelp
#

i also said reduce encaspulation earlier which was WRONG

#

reduce coupling is right

sharp geyser
#

I am writing my own database in C#, using LMDB as the backend.

#

Problem is, the way the wrapper for LMDB I am using works is that it requires you to dispose of the environment and quite literally everything else once you are done with it.

scenic kelp
#

quite literally everything else being

#

like the entire application?

sharp geyser
#
using System.Text;
using LightningDB;

using var env = new LightningEnvironment("pathtofolder");
env.Open();

using (var tx = env.BeginTransaction())
using (var db = tx.OpenDatabase(configuration: new DatabaseConfiguration { Flags = DatabaseOpenFlags.Create }))
{
    tx.Put(db, "hello"u8.ToArray(), "world"u8.ToArray());
    tx.Commit();
}
using (var tx = env.BeginTransaction(TransactionBeginFlags.ReadOnly))
using (var db = tx.OpenDatabase())
{
    var (resultCode, key, value) = tx.Get(db, "hello"u8.ToArray());
    Console.WriteLine($"{Encoding.UTF8.GetString(key.AsSpan())} {Encoding.UTF8.GetString(value.AsSpan())}");
}
#

Like anything using the environment

#

also has to be disposed of

#

this is an example on how to use it

scenic kelp
#

why aren't you using using var for everything

sharp geyser
#

Well

#

Because I don't want to dispose of the environment until AFTER they dispose of the ImpulseDb themselves

scenic kelp
#

ig technically yeah you want to control when they go out of scope

sharp geyser
#

Transactions and stuff dont matter

#

I can dispose of that after its out of scope

#

but the environment i NEED to have remain until they call .Dispose themselves, or when the finalizer kicks in (not sure how finalizer works)

        ~ImpulseDb()
        {
            if (!_isDisposed)
            {
                Dispose();
            }
        }

        public void Dispose()
        {
            // Dispose of connection
            _isDisposed = true;
        }

#

I somehow need to make sure I dispose of everything properly

#

otherwise memory go brrr

scenic kelp
#

i don't think you need finalizers with idisposable

sharp geyser
#

@dense flame

scenic kelp
#

finalizers should only really be used for unmanaged resources

sharp geyser
scenic kelp
#

so like C/C++ stuff

sharp geyser
#

It will ensure that everything is disposed of

scenic kelp
#

no that's what dispose is for

sharp geyser
scenic kelp
#

don't use finalizers if you're not using unmanaged resources

#

i've never written a single finalizer in C#