#development

1 messages · Page 183 of 1

solemn latch
#

I really love the new DJs docs, they're amazing.

#

Takes up a little too much space to describe a prop though, but its very readable

pale vessel
#

that's just not how the lib is designed

wheat mesa
#

djs = abstraction abstraction abstraction

sharp geyser
#

I wish it was designed that way though

#

You can still be beginner friendly without all those builders that abstract away from the point of the library

earnest phoenix
#

Alright I think I got it

#

client.on("interactionCreate", async (interaction) => {
  if (interaction.isChatInputCommand() && interaction.commandName === "ping") {
    const embed = new EmbedBuilder()
    .addtitle("Connect to our Server")
    .addDescription("Test description");
  };
});

#

is this correct?

wheat mesa
#

no

solemn latch
#

op ok, I was about to say I think so 👀

#

lmao

wheat mesa
#

It’s close but not going to run properly

#

It’s addTitle not addtitle

#

Camel case

deft wolf
#

Wait, addTitle?

#

Not setTitle?

solemn latch
vivid fulcrum
#

do you not have intellisense? what are you working in 🤔

solemn latch
#

setTitle

solemn latch
earnest phoenix
#

TypeError: (intermediate value).settitle is not a function

solemn latch
#

Capital T

#

setTitle not settitle

earnest phoenix
#

now the command doesn't respond but no errors? huh

wheat mesa
solemn latch
earnest phoenix
#

this works right

earnest phoenix
#

I was fine at making bots 2 years ago

#

3*

#

in 2021

#

which is why I have the developer role,

#

but I forgot all of it and now there are so many changes

wheat mesa
#

I’m not talking about learning the library

#

I’m talking about learning the language

#

That error told you exactly what was wrong but you (I’m assuming since you pasted it here) didn’t know what it meant

#

It’s important to understand the language before trying to make complex applications such as a discord bot

earnest phoenix
#

{
          name: "ban",
          description: "Bans a user from the server",
          DefaultMemberPermission: false,
          options: [
            {
              name: "User you wish to ban",
              description: "The user you wish to ban",
              type: ApplicationCommandOptionType.Mentionable,
              required: true,
            },
            {
              name: "Reason for ban",
              description: "The reason for the ban",
              type: ApplicationCommandOptionType.String,
              required: true,
            },
          ]
        },



Error: DiscordAPIError[50035]: Invalid Form Body
1.options[0].name[STRING_TYPE_REGEX]: String value did not match validation regex.
1.options[0].name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid
1.options[1].name[STRING_TYPE_REGEX]: String value did not match validation regex.
1.options[1].name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid
at handleErrors (/home/runner/atlasbackend/node_modules/@discordjs/rest/dist/index.js:722:13)

#

how does this not work? I don't understand

deft wolf
#

You can't use capital letters and spaces in command name if i remember correctly

#

For options too

earnest phoenix
warm surge
earnest phoenix
earnest phoenix
#

client.on("interactionCreate", async (interaction) => {
  if (interaction.isChatInputCommand() && interaction.commandName === "ban") {
    const { options, member } = interaction;
    const user = options.getUser("target-user");
    const ID = user.id;
    const banUser = client.users.cache.get(ID);

    if (!member.permissions.has(Discord.PermissionFlagsBits.BanMembers)) {
      return await interaction.reply({
        content: "You must have ban permissions to ban users.",
        ephemeral: true,
      });
    }

    if (member.id === ID) {
      return await interaction.reply({
        content: "You cannot ban yourself!",
        ephemeral: true,
      });
    }

    let reason = interaction.options.getString("reason");
    if (!reason) reason = "No reason provided";

    const dmEmbed = new Discord.MessageEmbed()
      .setColor("Blue")
      .setDescription(`You have been banned from the Atlas SMP | ${reason}`);

    const banEmbed = new Discord.MessageEmbed()
      .setColor("Blue")
      .setDescription(`${banUser.tag} has been banned | ${reason}`);

    await interaction.guild.bans.create(banUser.id, { reason }).catch((err) => {
      return interaction.reply({
        content: "I cannot ban this member",
        ephemeral: true,
      });
    });

    await banUser.send({ embeds: [dmEmbed] }).catch((err) => {
      return;
    });

    await interaction.reply({ embeds: [banEmbed] });
  }
});


Why does this code throw error:

TypeError: Cannot read properties of null (reading 'id')
at Client.<anonymous> (/home/runner/atlasbackend/index.js:47:21)

solemn latch
#
TypeError: Cannot read properties of null (reading 'id')

Means you're using .id on a null variable.

Just glancing at your code, user.id; user might be null.
banUser.id; banUser might be null.

earnest phoenix
# solemn latch ```cmd TypeError: Cannot read properties of null (reading 'id') ``` Means you're...

Ok I fixed that issue, and here is the updated code:


const express = require("express");
const app = express();
const { Client, Intents, Collection, MessageEmbed } = require("discord.js");
const { SlashCommandBuilder } = require('@discordjs/builders');

const {
  REST,
  Routes,
  ApplicationCommandOptionType,
  PermissionFlagsBits,
} = require("discord.js");


module.exports = {
  data: new SlashCommandBuilder()
  .setName("Ban")
  .setDescription("Bans a user from Atlas SMP!")
  .addUserOption(option => option.setName('user').setDescription('The user you wish to ban').setRequired(true))
  .addStringOption(option => option.setName('reason').setDescription('The reason for the ban').setRequired(true)),
  async execute(interaction, client){
    const user = options.getUser("target-user");
        const ID = user.id;
        const banUser = client.users.cache.get(ID);

        if (!member.permissions.has(Discord.PermissionFlagsBits.BanMembers)) {
          return await interaction.reply({
            content: "You must have ban permissions to ban users.",
            ephemeral: true,
          });
        }

        if (member.id === ID) {
          return await interaction.reply({
            content: "You cannot ban yourself!",
            ephemeral: true,
          });
        }

        let reason = interaction.options.getString("reason");
        if (!reason) reason = "No reason provided";

        const dmEmbed = new Discord.MessageEmbed()
          .setColor("Blue")
          .setDescription(`You have been banned from the Atlas SMP | ${reason}`);

        const banEmbed = new Discord.MessageEmbed()
          .setColor("Blue")
          .setDescription(`${banUser.tag} has been banned | ${reason}`);

        await interaction.guild.bans.create(banUser.id, { reason }).catch((err) => {
          return interaction.reply({
            content: "I cannot ban this member",
            ephemeral: true,
          });
        });

        await banUser.send({ embeds: [dmEmbed] }).catch((err) => {
          return;
        });

        await interaction.reply({ embeds: [banEmbed] });
      }

}

throws this error:

/home/runner/atlasbackend/node_modules/@sapphire/shapeshift/dist/cjs/index.cjs:46
throw this.error;
^

ExpectedConstraintError: Invalid string format

solemn latch
#

Shapeshift is input validation.
Its probably the name of your ban command, I think you just worked on this issue in another error you had above.

earnest phoenix
deft wolf
#

It should be .setName("ban")

earnest phoenix
#

Ah yes, it's fixed now tysm lol

#

However my slash command doesn't appear now?

deft wolf
#

Are you sure you registered it correctly?

earnest phoenix
#

it's in a ban.js file

deft wolf
#

Then you need to register it now

earnest phoenix
#

Should I just do that in my commands.js?

deft wolf
#

It depends on what it is. This is usually done in the main bot file (bot.js/index.js) because it is only launched once

solemn latch
#

You realistically shouldn't register it every time your bot launches.

IIRC, you can register it once and never register it again unless its edited.
If your bots ever in a reboot loop it & it registers all commands every time its easy to get a rate limit.

But that can be an issue for another day.

earnest phoenix
#

in the ban.js

solemn latch
#

You're creating the command locally, but not sending any information to discord.

deft wolf
earnest phoenix
#

Can I register it in the same file?

#

How someone knows what is cooldown for Canvas api's rate limit?

deft wolf
earnest phoenix
#

Is there some documentation?

sterile lantern
#

i still get Cannot send empty message

#

i tried this as well

earnest phoenix
earnest phoenix
pale vessel
sterile lantern
#

same error

pale vessel
#

what error?

#

ah i see

sterile lantern
pale vessel
#

what's ur current code?

sterile lantern
#

oh

#

i changed type to image

#

and it worked

#

but how do i make it actually embed

spark flint
#

you're sending a PNG as a text filetype

#

so it will try and embed like a text file

sterile lantern
#

i changed the filetype to image

#

still appears like that

sterile lantern
sharp geyser
#

Make sure the image isn’t breaking discord’s restrictions

#

An image can only be a certain width and height

sterile lantern
#

it def isnt breaking file size

#

nor width/height

sharp geyser
#

Are you sure?

sterile lantern
#

yes

sterile lantern
sharp geyser
#

I’ve seen people say the same thing and it was actually the size of the image

sterile lantern
#

if it helps its being uploaded via a slash cmd and its an ephemeral img

sharp geyser
#

Doesn’t really matter here

pale vessel
#

this

sharp geyser
#

So long as it’s not too big or the file isn’t too large it will embed most of the time. Also yea what flaze said

sterile lantern
#

the img is an object

#

directly from the slash cmd

pale vessel
#

what obj?

sterile lantern
#

attachment object

pale vessel
#

that won't do

#

u need the image as a blob/buffer in order to upload it

#

something like formData.append("files[0]", await (await fetch(img.url)).blob(), "image.png");

sterile lantern
#

that worked

#

ty

sterile lantern
#

(message is the webhook msg obj)

#

it doesnt seem to work and idk why

pale vessel
#

what doesn't work

sterile lantern
#

the editing of the msg

#

it doesnt edit the message

#

the response.json just prints object Object

pale vessel
#

yea u JSON.stringify() it

sterile lantern
#

turns out webhook id is returning false

#

sigh

#

the editing changes it into that

solemn latch
#

I'm not 100% on this, but editing images attachments isnt possible on webhooks right?

sterile lantern
lament rock
#

console.log uses util.inspect on Objects. Either stringify it with JSON.stringify (not String or toString) or util.inspect

sterile lantern
#

yeah i stringified it

#

oh well

#

actually

#

i fixed it by simply not editing the image

#

since i dont need to

sterile lantern
#

does anyone know the rate limit for fetching members in a role? i want to fetch the members in 12 roles

#

actually i could probably fetch all the guild members and then map for each role

lament rock
#

If you perform a request, it tells you the bucket info. rate limits should not be hard coded

crystal wigeon
#

What’s wrong with topgg?

#

I’ve been receiving lot of complaints of people not being able to vote

#

Cause the site keeps crashing or just says something went wrong

#

It’s been like this for the past week entirely

deft wolf
#

This is nothing new, top.gg has such an episode on average every few days

#

Apparently the website is as stable as it has ever been

fossil bone
#

ok so my bot used to work a few months ago, i haven't changed a thing in the code so i tried to revive and use it now it refused to work
any ideas why?
i get these in the console outputs
2024-02-12 10:04:37 INFO discord.client logging in using static token
2024-02-12 10:04:38 INFO discord.gateway Shard ID None has connected to Gateway (Session ID: 34fe665d4ebee525888f9a4cc97a1607).
but yet it doesn't interact whit any command i use in the server
i checked the priviliged intents and all were toggled on like they always were, so idk at this point i'm lost, and i think it can only be a new discord update that i'm not updated to causing this, so help me out here?

earnest phoenix
fossil bone
# earnest phoenix It would help if you sent the code for your bot

import discord
import os
import csv

intents = discord.Intents.default()
#intents.typing = False

client = discord.Client(intents=intents)

@client.event
async def on_ready():
print('the {0.user} is ready'.format(client))

@client.event
async def on_message(message):
if message.content.startswith('.'):
with open('chat.csv', 'r') as csv_file:
csv_reader = csv.reader(csv_file)
for line in csv_reader:
if message.content.startswith(line[0]):
await message.channel.send(line[1])

msg = message.content
list = ["*", "-", "/", "+"]

if message.author == client.user:
    return

if message.content.startswith('pp'):
    await message.channel.send('Hello!')

if any(x in msg for x in list):
    def a_plus(a, b):
        return a + b

    def a_minus(a, b):
        return a - b

    def a_times(a, b):
        return a * b

    def a_division(a, b):
        return a / b

    for i in msg:
        if i in list:
            c = i
            a, b = msg.split(c)
            a, b = int(a), int(b)

    if c:
        if c == "+":
            await message.channel.send(a_plus(a, b))
        elif c == "-":
            await message.channel.send(a_minus(a, b))
        elif c == "*":
            await message.channel.send(a_times(a, b))
        elif c == "/":
            await message.channel.send(a_division(a, b))
    else:
        await message.channel.send("bye")

client.run(os.environ['TOKEN'])

#

#it can't get any simpler it's just a calculator bot that with a csv file for chatting

civic scroll
#

damn

pale vessel
#

you might need to explicitly add message content intent

#

i don't think it's included inside the default intents

civic scroll
#

resisting my urge to optimise this code

#

😔

pale vessel
#

keep ur ego down Trol

civic scroll
earnest phoenix
#

if i open visual studio code, with my bot code and everything and i keep that running on like a non-used computer, does it go forever until i turn it off?

civic scroll
#

but why would you need vscode just to run the bot?

#

you can run it from powershell or command prompt

earnest phoenix
#

oh

#

well now i feel really stupid buying from a bot hosting site

spark flint
#

thats not stupid

#

its cheaper to use bot hosting instead of an old pc

earnest phoenix
spark flint
#

because with an old pc

#

you are paying for power

#

you are paying for bandwidth

earnest phoenix
#

yeah but its just a bot for my server

spark flint
#

oh if its just for you

#

then yes

#

if its a public bot, i would use hosting

pseudo grotto
#

Is there a way for bots to verify members to bypass server filters, like normal human admins can do by right clicking on a member and clicking verify? For example, waiting 10 minutes in a server when verification is HIGH.

spark flint
#

you can give them a blank role

#

that bypasses

#

(at least it used to)

pseudo grotto
#

roles could bypass?

spark flint
#

thats why the role <@&432583476659879936> exists here

pseudo grotto
#

but it doesnt anymore?

spark flint
#

i'm not sure

#

pretty sure it still works

pseudo grotto
#

i mean why would you guys make a role for it

#

when you can just right click

#

and verify?

#

idk

spark flint
#

because that feature is relatively new

pseudo grotto
#

so the people who specially verified, still have that role

spark flint
#

the roles existed since 2018

#

yes

pseudo grotto
#

lol so we can just ping em

#

or i cant

spark flint
#

the role doesn't ping

#

you can mention a role without pinging it

pseudo grotto
#

hm

#

ok

spark flint
#

<@&265125253443878912>

pseudo grotto
#

<@&585528734904352769>

spark flint
#

doesn't ping

#

<@&585528734904352769>

#

would be funny if that pinged

earnest phoenix
#

application_id[NUMBER_TYPE_COERCE]: Value "YOUR CLIENT ID" is not snowflake.

#

what does this error mean

#

nvm fixed it

low orbit
#

Am i going crazy or why can it not find this entry

lyric mountain
low orbit
lyric mountain
#

and I'm using == so it shouldn't matter anyways
for one never ever use double equals, it's a recipe for hard-to-find bugs, and using it for certain things like discord ids wouldn't work anyway

#

because the string will be cast to int, which will truncate the value

#

I believe the issue might be that you're using this inside an arrow function

#

try storing the lookup id in a constant

low orbit
#

nah i've just found it, console.log(getData) wasn't where it was in that screenshot, i had moved it just so i could show what i was logging when i sent here, but when i ran it, it was an empty array 🤦‍♂️

deft wolf
# spark flint if its a public bot, i would use hosting

In my opinion, even if it is a bot for only one server, it is still worth buying normal hosting. Even 512MB of RAM for a dollar or two a month is not that much, but the bot will work 24/7, especially if it is a bot that is supposed to deal with user verification, role assignment and such general server matters

frozen linden
#

Hello

#

Hi

#

NyNu

deft wolf
lyric mountain
#

linux knowledge is never wasted

surreal sage
#

always try spread operator when objects arent object-ing

sterile lantern
#

for some reason when i try to update a field it just completely removes it

#

im using mongo-http

#

i tried w/out update and just $set, that didnt work either (just completely removed the array from the doc)

low orbit
earnest phoenix
#

how do i make it so they have to vote before using a command?

spark flint
#

On mobile so hard to show

#

Then remove the “ around $set

sterile lantern
#

still deletes the array entirely

spark flint
#

hm

#

idk if this works with that lib but

#
await db.collection('points').updateOne({ _id: "points" }, { $push: { "Approved Points": user } }, { upsert: true });```
#

thats how i'd do it personally

sterile lantern
#

push doesnt work either

#

so weird

spark flint
#

very weird

sterile lantern
#

its also not the db operation failing.. it says its successful and modified 1 doc

sterile lantern
#

nvm, it was a bracket issue

sharp geyser
#

Is that a lib for mongo?

sterile lantern
#

im using cf workers so im using a http lib of mongo

sacred marten
#

TopGGAPIError: 504 Gateway Timeout

warm surge
sacred marten
#

ik

#

when will be fixe it ?

warm surge
#

no eta

low orbit
earnest phoenix
earnest phoenix
harsh nova
hushed patrol
#

anyone knows a good host for expressjs?

warm surge
hushed patrol
warm surge
#

no

hushed patrol
#

k thx

earnest phoenix
low orbit
earnest phoenix
sterile lantern
#

if i fetch guild members (which returns guild member objs and their role ids), can i filter the users with a specific role name or would i have to use id

quartz kindle
#

so to filter by name, you need to have the role object in the guild, so you can check its name with the id from the member

#

most libs will already do that for you as long as the roles are cached

sterile lantern
#

meh i think id is just better

#

im using http so it would be a manual req

#

and theres like 10k+ members

quartz kindle
#

afaik there is no way to filter members by roles without fetching all members, which is a pain in the arse

sterile lantern
#

yeah im just fetching members then looping through them to see if they have a role

pale vessel
summer torrent
#

hi tim, how's it going

stiff dust
#

Hello I want to create new Private Bot and give activity roles
for example if someone sent 500 messages in last 7 days I want to give them an specific role
Just need a little help for the structure can someone explain what is the best way to do it? thinKappa

The idea I have is this!

For each user set an array and a number called DailyMessagesCount in DB
And also create a DJS Collection called users and assign it to client like client.users
and count their messages in each hour like client.users++ for each message by them in messageCreate event and update DailyMessagesCount for each user in hour and then after that in the end of the day in 00:00 I will push DailyMessagesCount to that array in the DB and also I count the sum of the elements in the array and if the element is more than 500 I will assign them as Active Member and give them that role also after that if the elements of the array reach 7 I remove the first one and add new one so this way it will only count messages during last 7 days

sterile lantern
#

how would i first defer a response, and then update it after the code completes? rn it just returns a response at the end

#

i tried this but it said unknown interaction

#

(the id and token are correct)

solemn latch
#

👀 raw api? I like it

#

are you writing a lib? 👀

sterile lantern
#

no im just using cf workers haha

solemn latch
#

OH COOL
I love those types of projects

#

so neat

sterile lantern
#

yep its very cool but yet so tedious at the same time with all of these manual reqs

solemn latch
#

Yeah, for sure.

I have webhooks being sent from a cf worker, loved making it. PITA to maintain

sterile lantern
solemn latch
sterile lantern
#

is that not the id ur supposed to provide

#

i couldve sworn i saw interaction id

#

lol that fixed it, thanks

solemn latch
sterile lantern
#

but is it possible to make it ephemeral

solemn latch
#

I haven't used a slash command bot in months.
you need to set it as ephemeral in the defer message right?

sterile lantern
#

oh its just flags

#

so when i defer

#

should i create followup msg, or edit original response

solemn latch
#

it should be a follow up iirc.

sterile lantern
#

alr ty

sterile lantern
#

this works

#

this doesnt

#

the return is in the else if (message.type ...

#

this is what response1 is

solemn latch
sterile lantern
#

let me fix that lol thanks

#

oof still doesnt respond

solemn latch
#

status code/text?

sterile lantern
#

none of it is printing

#

cf workers just show canceled

solemn latch
#

It might help to wrap fetch in a function which logs every single fetch status and status text for every request. At least for development.

sterile lantern
#

logs still empty

solemn latch
#

👀 is it not even reaching fetch?

sterile lantern
#

might be that

#

altho i dont see why it would

#

let me try putting it inside the cmd block instead of the interaction

#

still nothing

#

its not even recognizing the cmd

#

let me try moving the defer into the cmd block

#

ok so i think the defer is somehow cancelling the interaction

#

bc after the defer, nothing prints

#

nothing works

#

and cloudfare shows up as canceled

solemn latch
#

👀 I'm not sure how to help with that.

solemn latch
#

Are you possibly running out of cpu time?
if you're on the free teir you get 10ms of cpu time before it cancels.
it also has 15 seconds of real time per request right?

sterile lantern
#

yeah im on the free tier

#

but does deferring not work with cf workers then?

solemn latch
#

You can defer, as long as you follow up within those 15 seconds(and dont run out of cpu time)

sterile lantern
#

well i defer and then instantly respond

#

so thats weird

solemn latch
#

Why are you defering if you instantly respond?

sterile lantern
#

to just test it

#

its meant for a larger command

solemn latch
#

fair

sterile lantern
#

(scanning all guild members)

#

idek if i can do that now

solemn latch
#

ah, thatll probably take longer than 15 seconds right?

sterile lantern
#

yeah

#

10k+ members

solemn latch
#

You can store the relevant info in KV

#

You'll probably want to use an actual server for handling that specific command tbh.

#

even if its defered by a cf worker, then handled on server.

sterile lantern
#

oof i wanted 2 do this for free

#

no other way to do this?

#

might just go manual way and keep the users stored in a database

#

and update it as we go along

#

wait

#

cpu time is 30 seconds

#

nvm looking at diff plan

solemn latch
#

a 30 second cpu time per request would be wild for free

#

Imagine

spark flint
#

i think thats $5/month for 30s

#

30 million CPU milliseconds included per month
+$0.02 per additional million CPU milliseconds

Max of 30 seconds of CPU time per invocation
Max of 15 minutes of CPU time per Cron Trigger or Queue Consumer invocation

solemn latch
#

yeah, but then it uses up your duration pricing

spark flint
#

yeah

solemn latch
#

workers are the best priced, but somehow the most expensive thing ever.

$5 and you get 8 hours of cpu time

#

meanwhile you can get hundreds of hours of cpu time a month for $3

#

but somehow cf workers still feel cheap

sterile lantern
#

unfortunate that role obj doesnt contain a member list

#

😔

solemn latch
#

Sadly not

#

In order to keep an updated database of users with a specific role you'd need to use the gateway I think.

sterile lantern
#

time to manually add all of these users into a database and add/remove when necessary

#

how fun

little meadow
#

hey guys i need a template nodejs for my discord bot djs v13, if someone vote my bot, it will send to my channel/their dms to thank them

#

nvm i read the docs

copper cradle
edgy tendon
#

what module am i suppose to use for the api with python.

green kestrel
#

if you ever have need for an anti DDOS tunnel, do NOT use x4b.

#

if you have unused credit in your account, they will never ever let you transfer it back to your card or paypal.

#

so its a case of "fine, you want to be a dick, i'll raise a disupute, not like i plan to continue using your service anyway"

surreal sage
#

are there any npm packages that cache a value for some time unless fetched before expiry?

#

like memory optimization caching

#

i want to store mongoose models in it

#

ima just write my own ig

green kestrel
#

i got my refund

#

they are NOT happy

#

lol

#

they basically called me a fraud

#

so i complained to paypal, i wont be taken for a mug

tulip ledge
surreal sage
digital swan
sharp geyser
surreal sage
sharp geyser
#

I said if you wanted to

surreal sage
#

ohhhh im gonna dieee

sharp geyser
#

That’s just one of the many options

#

You could also just use a map

#

Also Id say it’d be pretty fun to make your own implementation of a map that has expiry entries

#

So why use a lib

#

Unless you just want to get it over with

sharp geyser
#

It’s lib requires another lib that also requires another lib that also requires another lib

surreal sage
#

is it smart for companies that use mongodb to actually give the _id of a document to the user

#

e.g. an order's document

solemn latch
lyric mountain
#

even if it did it's hashed anyway

spark flint
#

ID just resolves to date

#

thats it really

#

The 12-byte ObjectId consists of: A 4-byte timestamp, representing the ObjectId's creation, measured in seconds since the Unix epoch. A 5-byte random value generated once per process. This random value is unique to the machine and process.

lyric mountain
#

oh, so not a hash

pale vessel
#

the eval was so fast it didn't even need to put the time it took to evaluate

quartz kindle
#

fool of a took

spark flint
#

i just don't handle under 1s evals

#

(forgot)

surreal sage
spark flint
#

lazy

#

👍

#

bot eval easy for stuff like this

surreal sage
#

oh yeah

#

mb

#

you can just windows button

#

type node

#

enter

#

and do stuff there

spark flint
#

lol

wheat mesa
#

Why do that when I can run something with my bot that’s on a version of node from 2.5 years ago? I want the legacy experience

copper cradle
pale vessel
#

its great for simple js evals

surreal sage
delicate vine
#

Hello everyone . I'm looking for a coder for a bot project. Preferably French

deft wolf
surreal sage
eternal osprey
#

heyy, this is more of a theoretical question. Is it possible to convert a non-deterministic turing machine to a deterministic one using a powerset construction?

lyric mountain
#

holy fuck chitty KEKW

wheat mesa
#

Top 10 things you will never use in the real world™️

real rose
harsh nova
#

Speaking facts as usual

wheat mesa
#

@lyric mountain did you ever use textures in opengl? I'm trying to do a batch renderer but I can't seem to figure out why my texture is rendering as a black square

sacred python
#

How can I create buttons that still work after a restart with discord.py?

lyric mountain
#

how did u load it?

solemn latch
wheat mesa
#

It worked for a while so I know it's not my loading

lyric mountain
wheat mesa
#

It broke after I added a "white square" dummy texture to use for plain color rendering

lyric mountain
#

for example, if it's a role button, save the message ID to database and whatever else you need to re-create it

wheat mesa
#

It works for colors so I'm really confused on why it doesn't work with proper textures

#

I'm going to clean up the code rq and see if I can figure it out

smoky copper
#

/buy

sacred python
lyric mountain
#

no

#

"still work after restart" will always require using a database of some sort

sacred python
#

ok thanks

wheat mesa
#

I hate this

#

turns out my texture was being loaded wrong

#

I was loading it as GL_RGBA8 when it wanted GL_RGB

#

fucking jpg

green kestrel
#

opengl: graphics library by committee

lyric mountain
#

what are the chances of voltrex being involved with it in some way?

#

I swear he's in every open source project

sharp geyser
#

Hes probably part of it

#

any large library that involves C++ he likely has his hands in it

radiant kraken
#

why are y'all still talking about him smh

lyric mountain
#

I mean, he's a legend like tim

#

Dude is part of the backbone of most major frameworks while coding on a phone

radiant kraken
#

he may be smart but not really emotionally

lyric mountain
#

Wasn't here when it happened

radiant kraken
#

¯_(ツ)_/¯

quartz kindle
radiant kraken
#

no u two

sterile lantern
#

rn i use slash cmd attachment option. if someone were to submit a video instead of a picture, how would i differentiate between them?

#

when someone tries a video it just uploads an img bc its being forced as an image

lyric mountain
#

Your best bet is reading the first 4 (?) bytes of the file

#

Most if not all formats use magic bytes, which is unique for each format

sterile lantern
#

actually

#

i could probs just use content type

lyric mountain
#

Content type can be spoofed easily

sterile lantern
#

wdym

#

well in theory

lyric mountain
#

You can write whatever you want on the headers

sterile lantern
#

if they tried to make a photo a video, wouldnt it still upload it as a photo

lyric mountain
#

Kinda, but you can intercept and modify the headers sent to the server

sterile lantern
#

who?? the user or me?

lyric mountain
#

The user

sterile lantern
#

via a slash command?

lyric mountain
#

Ah you mean through discord, thought you were doing for a sitr

sterile lantern
#

no haha

lyric mountain
#

In that case it's even easier

sterile lantern
#

using cf workers :')

lyric mountain
#

Just rename the extension

sterile lantern
#

wdym

#

users can either submit photo or video

#

rn its just forced as img

lyric mountain
#

Discord trusts the extension too much

sterile lantern
#

wait

#

so if i forced imgs

#

as videos

#

they would still upload as images right

lyric mountain
#

Rename png to mp4 and send it

sterile lantern
#

lol ok

lyric mountain
#

Would be an invalid video yeah, but discord would allow

#

Just read the first few bytes in the file, you can identify the format right away

sterile lantern
#

if someone uploaded .mov and i forced to mp4, still a vid right

#

or .webm

lyric mountain
#

Yeah, kinda

#

Whatever codec you use will be angry, but they usually ignore the extension and read the magic bytes as a fallback

frozen ridge
quartz kindle
#

what do you guys think about nginx now?

#

main dev split from them and created his own fork "freenginx"

spark flint
lyric mountain
#

wasn't nginx open source already?

pale vessel
quartz kindle
#

apparently the company behind nginx made some decisions without discussing with the dev team first

#

and some devs didnt like it

radiant kraken
#

nice

vernal vector
#

( sorry for the ping )

deft wolf
#

You are the chosen one Null

vernal vector
civic scroll
vernal vector
#

To do a command system

#

I want to make a python discord bot with a cog command that requires voting in top.gg.

civic scroll
#

ah

civic scroll
#

(don't think about implementation, just idea - "as a discord bot, how can i do {...}")

vernal vector
civic scroll
#

yw

ionic schooner
#

Who has experience with elasticsearch? if so what are your thoughts on it, and if you don't like it what are some other free self-hosted options

eternal osprey
#

hey guys

#

is there anyone out here that has used hadoop before?

#

how can we know how much mappers/reducer instances are being used for a map/reduce action?

#

Imagine i had a folder with 10 txt files across various datanodes within a cluster, and i wanted to like get one file that contains each word and their occurence.

eternal osprey
#

if anyone could explain this, i would be trhilled.

lament rock
#

if the function takes a callback, just increment a number in the callback

eternal osprey
#

i cant lie this might be the best class i have had so far, about dockers and hadoop an allat

#

finally something pratical instead of theoretical like turing machines

lament rock
#

yeah

quartz kindle
#

fucking hell

#

authy decided to shutdown its desktop authenticator app

#

what a pain

pale vessel
#

yeah i got an email about that too

green kestrel
#

so, we went bowling after work because one of the guys was leaving. turns out when developers go bowling, we spend all our time abusing and finding xss exploits in the bowling management system lol

#

poor lane attendants had no clue wtf was happening lol

warm surge
#

whos gonna win

green kestrel
#

I lost at the actual bowling

#

but won at disrupting the system lol

#

I was the big lol

#

2nd from bottom

deft wolf
#

This is probably the longest "hello" I've ever seen on this channel

frosty gale
#

me and my coworkers found the same thing haha

#

but you cant do much with it

#

looks like minimal html rendering so no script tags

#

would be considered very low severity

sterile lantern
#
        formData.append("payload_json", JSON.stringify({content: message, allowed_mentions: {"roles": ["roleid1", "roleid2"]}, avatar_url: <url here>, components}));

im trying to make a webhook ping two roles, but its not pinging any roles at all - any idea?

#

does the bot need permissions to ping roles in order for its webhook to ping roles?

i tried allowed_mentions: { "parse": ["roles"] } as well

eternal osprey
#

TypeError: Failed to execute 'fetch' on 'Window': Failed to read the 'headers' property from 'RequestInit': String contains non ISO-8859-1 code point

#
fetch("http://127.0.0.1:4000/api/completed", {
                method: "POST",
                headers: {
                    "Content-Type": "application/json",
                    sessionkey: cookie,
                    cart: JSON.stringify(data), 
                },
                body: JSON.stringify({ email: "data" }),
            })```
#

i am unsure what this error even means

#

i mean it had to do with my headers, but it seems perfectly fine?

lament rock
lament rock
#

On top of that, ISO-8859-1 refers to latin1 character encoding

#

So if it's non latin1, you should fix that

exotic ivy
#

Can a competent dev take topgg over please and fix it finally so it'd work for more than just a few hours at a time, this is just unimaginable to always hear it's impossible to be fixed

lament rock
#

If you think you can do better, make a competitor

#

competition is healthy

real rose
#

Lowkey wish it worked

sterile lantern
#

the webhook was created by the bot

sterile lantern
#

bruh so in order for it to ping roles, @ everyone has to be able to ping roles???

#

I thought webhooks could always ping

pale vessel
#

webhooks are disconnected from the bot

sterile lantern
#

this can be channel based right

#

like if i allowed the @ everyone role to ping in that specific channel

pale vessel
#

yeah

sterile lantern
#

it seems like it uses bot permissions actually

green kestrel
green kestrel
lament rock
# sterile lantern it seems like it uses bot permissions actually

The checking bot permissions is only for POST /channels/:channel_id/messages
Like Flaze said, webhooks are detached from the bot since you can use a webhook url on other services other than Discord and giving webhooks the same channel perms as the author isn't a good idea.
allowed_mentions also doesn't alter permissions like if the permission is denied on <@&guild_id> then it won't make a difference if it's present or not, just if the message would notify users, check if it should push those notifications

pale vessel
#

one can't be pinged (it's just a role) and the other could if allowed

lament rock
#

It's just the chat identity that's different

#

<@&guild_id> resolves to at at everyone

#

It's what you edit for permissions as well on an API level for the everyone role

#

but typing two ats is cringe so at everyone is just shorthand

#

strange that at everyone "works" in DMs

pale vessel
#

it's probably meant for group DMs

eternal osprey
green kestrel
#

discord only supports utf8

#

so whatever you're doing in whatever charset remember to convert it

#

when you display it

radiant kraken
#

utf-8 my beloved

#

probably the only sane encoding

green kestrel
#

it's all about utf-32 /s

#

utf8 ftw

austere linden
#

yo guys,
wanna ask by which time zone this website decides thats its a weekend or not ?

green kestrel
#

utc

warm surge
green kestrel
#

damn cross posts pepowot

radiant kraken
green kestrel
#

ah yes the sensible standard

radiant kraken
#

why waste the 11 bits

green kestrel
#

for use on 21 bit systems

radiant kraken
#

yes

green kestrel
#

sounds like the sort of data structures dpp has lol

radiant kraken
#

wdym

green kestrel
#

we bit pack stuff to save memory

#

like the 40 or so booleans in stuff like users and guilds

wheat mesa
#

C++ devs when they find out a boolean uses an entire byte (7 bits wasted, cannot let this happen)

green kestrel
#

and integers that can only hold a value up to 15 etc

wheat mesa
#

Must use bitsets instead!

green kestrel
#

indeed

#

we bit pack booleans into sets of 32 or 64

wheat mesa
#

Bitsets are a wonderful thing

green kestrel
#

and bit pack very small ints into 32 or 16 bit ints

#

2, 4, 6 or 7 bit ints

wheat mesa
#

I haven’t ever looked at the internal implementation, do they occupy the same number of bytes as using bitwise operators over an integer would occupy? (Assuming that you set the size to be 32)

radiant kraken
#

i use it in my library too

wheat mesa
#

I’m assuming it’s a thin wrapper over bitwise operations so you don’t have to use your brain too hard for it

green kestrel
#

yesnt

wheat mesa
#

I need to use bitsets for signatures in my ECS when I start developing it that’s why I’m wondering

green kestrel
#

we just use bitwise operators internally

wheat mesa
#

I meant the stdlib bitset

green kestrel
#

but to the user we represent it via a set of methods that return or take bools

#

nah we don't use std::bitset

radiant kraken
green kestrel
#

bit fields aren't complicated enough in my mind to need an abstraction

wheat mesa
#

You’d be surprised the amount of kids in my CS classes that think booleans occupy 1 bit

green kestrel
#

it's just |, &, ^ and ~

wheat mesa
#

Stdlib bitset is convenient when you need to specify a maximum size

radiant kraken
green kestrel
wheat mesa
#

Instead of having to manage multiple 64-bit numbers with bitwise operations

radiant kraken
#

fuck alignment

green kestrel
#

00000001
----------^
the boolean

radiant kraken
#

make an operating system where there is no alignment

#

:^)

wheat mesa
#

It’s even funnier when kids stuff an extra boolean into a struct and think that it’ll only increase the size by 1 byte

lyric mountain
#

Chaotic neutral system

wheat mesa
#

inb4 word alignment

wheat mesa
green kestrel
#

and depending it may take 64 bits!!!

#

imagine 8 bytes used for your boolean

#

because of alignment

wheat mesa
#

Yup

green kestrel
#

you can use pragma no pack and introduce a whole world of performance hurt

#

or pack stuff by hand

wheat mesa
#

One 8 byte number + 1 boolean = 16 byte struct for x64

#

Crazy how I’m gonna actually need to think about this sort of stuff soon 😭

#

Game engines are fun

radiant kraken
#

nice

#

which part of it is fun?

#

is it the math/physics

wheat mesa
#

The optimization

#

And the architecture

radiant kraken
#

oh lmao

wheat mesa
#

You can implement something super naive if you want but overall you have to think differently to get it to be more efficient

green kestrel
#

these optimisations are why I love c++ and developing dpp and why I don't use js

wheat mesa
#

I think that if I can implement a really nice entity component system I’ll be set for making the game I want to make

radiant kraken
green kestrel
#

these days my optimizations be nuts

wheat mesa
#

Biggest issue at the moment is figuring out how to actually design an ECS

green kestrel
#

it's essentially fixed at around 60mb

radiant kraken
#

nice

green kestrel
#

ecs aren't the hotness now

wheat mesa
#

Damn, that’s about 3x as much ram as my engine eats right now

#

Granted all I have is a renderer

green kestrel
#

they hurt cpu cache

wheat mesa
#

ECS is better for cpu cache

green kestrel
#

depends

radiant kraken
#

imagine how much ram it occupies if it was coded in djs

wheat mesa
#

Storing everything in contiguous arrays is wonderful for caching

green kestrel
#

you need a good block allocator to go with it that keeps the entities allocated in order in a block near the components

wheat mesa
#

Entities are merely a thin wrapper over an ID

#

My biggest issue is that I don’t think I really want “systems”, but I don’t know how else to handle communication between components

#

I suppose I could just update every component in each componentarray and attach the entity they’re updating for to the update function

#

That sounds really slow though

#

Idk

#

If anyone has pointers on where to find resources for making an ECS without systems please lmk

eternal osprey
#

hey guys, i made a UDP parser for my raw socket to basically mimic wireshark. I wanted some clarification if what i was doing is correct. So basically the full segment is all the data including the header which is a 64 bit, so 4 byte header. The data itself is 4 bytes as well. If we want to unpack the header, we get the full data segment and parse it into 4 equal sized segments, then we unpack the structures and format them correctly using encoding !HHHH as they are unsigned shorts. Once that's done, we can just get the rest of the data starting from indice 8, and that's basically how the packages work right? But does that mean that if a packet goes through the network pool each intermediate router must unpack and check the header for the source and destination ports? Isn't it really time consuming or do they use a different way of unpacking

#

someone has to end my suffering please

green kestrel
#

yes

#

each hop in the route analyses the header of an IP packet and may rewrite the destination IP if it's doing NAT

#

if it alters the packet it must recalc the checksum

#

ip stacks don't examine the packet payload it's treated as opaque data only

#

so 99.9% of the time they don't change the packet to route it but must be able to parse the header to know where to route the packet

eternal osprey
#

i see!

#

That's really interesting can't lie

#

isn't there a faster method then instead of parsing the header etc?

#

wait no that's dumb. I think that with this header there can't really be a faster way?

green kestrel
#

there is but you can't do it

#

modern network cards have hardware acceleration for parsing and routing TCP/IP and UDP packets

#

but at the user level you don't have access to that, would have to be a kernel module or network card driver

#

I've written a TCP stack before which kinda half works and I didn't use any hardware acceleration

#

it's in C, what are you using?

eternal osprey
#

i see. I didnt know all that.

eternal osprey
#

I might use java in the end though if that's possible

green kestrel
#

anything is possible

wheat mesa
#

speed and python don't go together very well :c

green kestrel
#

bigger q is, is it practical

eternal osprey
#

would a tcp parser be more different compared to a udp one?

green kestrel
#

yes TCP is far more complex

eternal osprey
#

I guess the header is the same but tcp has no data limit right?

green kestrel
#

udp is just fire and forget

#

source port dest port hope it gets to you glhf

eternal osprey
#

yeah exactly

green kestrel
#

TCP operates on a sliding window system to handle throttling, back off and retries

#

a bit like zlib

eternal osprey
#

i see, ofc you need way more error handling and basically need to retry sending if it fails. But the parser itself, would still have to unpack 8 bytes for the header but what about the data? Would that be any sized data?

#

like, in udp you are restrited to 8 bytes of actual data within the package

green kestrel
#

yes up to the max IP packet size

eternal osprey
#

but iirc tcp has a no-limit protocol in data

eternal osprey
green kestrel
#

64400+ someghing

eternal osprey
#

bits?

#

or bytes

green kestrel
#

bytes

eternal osprey
#

damn that's a big packet

green kestrel
#

but most network cards don't allow that

radiant kraken
green kestrel
#

it's basically the same as the MTU

#

couple of kb

#

or you have to deal with IP fragmentation

#

which is ew

eternal osprey
#

i see that's pretty interesting.

#

i might move over to tcp just to see how it is.

green kestrel
#

"enjoy"

eternal osprey
green kestrel
#

it's like being kicked in the teeth by a horse

eternal osprey
#

nah i got this (i think)

#

i find it fun

green kestrel
#

it's like someone made a sane standard and over time people shoehorned shit on top until it's a mess

#

like http basically

#

that didn't happen to udp

eternal osprey
#

whahahah damn i hope i can still manage to do it

#

btw

#

while we are at it with the questions and the life lessons

#

i had a question about assigning ports

#

i read through the documents of ietf and found this part:
o The Well-Known Ports, 0 through 1023.

o The Registered Ports, 1024 through 49151

o The Dynamic and/or Private Ports, 49152 through 65535

#

what do they refer to with well known, registered, etc etc? Also, when i am in development process i sometimes assingn port 4000 or 5000 to a localhost process. I assume that's private right? Why does it work while it does not fall inbetween the given ranges here or do these ports above stand for a different usecase?

sterile lantern
lyric mountain
#

Basically standardized ports

#

Which are immutable and unusable for anything else

zinc plume
#

hello

#

I left the server a few months ago and now I have to resume my role as Bot Developer, what can I do?

zinc plume
#

Thanks

stiff dust
#

Error

(process:22152): Pango-WARNING **: 00:23:26.417: couldn't load font "Chewy Not-Rotated 90px", falling back to "Sans Not-Rotated 90px", expect ugly output.

Code

const Canvas = require("canvas");
Canvas.registerFont(`./font/Chewy-Regular.ttf`, { family: "Regular" });

ctx.font = '90px Regular';
ctx.fillStyle = `#FFFFFF`;
ctx.fillText(name, 430, 200);
hidden gorge
#

Reload Command Crashes

const { SlashCommandBuilder } = require('discord.js');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('reload')
        .setDescription("[RoSearcher Developer Command]")
        .addStringOption(option =>
            option.setName('folder')
                .setDescription("Command Folder")
                .setRequired(true))
        .addStringOption(option =>
            option.setName('command')
                .setDescription('The command to reload.')
                .setRequired(true)),
    async execute(interaction) {
        const commandName = interaction.options.getString('command', true).toLowerCase();
        const command = interaction.client.commands.get(commandName);
        const folderName = interaction.options.getString('folder', true).toLowerCase();

        if (interaction.user.id == "919674489581731842") {
            if (!command) {
                return interaction.reply(`There is no command with name \`${commandName}\`!`);
            }

            const resolvedPath = require.resolve(`${__dirname}/commands/${folderName}/${command.data.name}.js`);
            console.log(resolvedPath);

            delete require.cache[resolvedPath];

            try {
                interaction.client.commands.delete(command.data.name);
                const newCommand = require(`./commands/${folderName}/${command.data.name}.js`);
                interaction.client.commands.set(newCommand.data.name, newCommand);
                await interaction.reply(`Command \`${newCommand.data.name}\` was reloaded!`);
            } catch (error) {
                console.error(error);
                await interaction.reply(`There was an error while reloading a command \`${command.data.name}\`:\n\`${error.message}\``);
            }
        }
    },
};

Error:

-Error executing command: Error: Cannot find module 'C:\Users\FRC 7722\Desktop\Projects\Bots\RoSearchBot\commands\developer/commands/misc/about.js'
Require stack:
- C:\Users\FRC 7722\Desktop\Projects\Bots\RoSearchBot\commands\developer\reload.js
- C:\Users\FRC 7722\Desktop\Projects\Bots\RoSearchBot\index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Function.resolve (node:internal/modules/helpers:187:19)
    at Object.execute (C:\Users\FRC 7722\Desktop\Projects\Bots\RoSearchBot\commands\developer\reload.js:25:42)
    at Client.<anonymous> (C:\Users\FRC 7722\Desktop\Projects\Bots\RoSearchBot\index.js:632:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\FRC 7722\\Desktop\\Projects\\Bots\\RoSearchBot\\commands\\developer\\reload.js',
    'C:\\Users\\FRC 7722\\Desktop\\Projects\\Bots\\RoSearchBot\\index.js'
  ]
}
#

/reload folder:misc command:about

sterile lantern
#

in your code you do /commands/${foldername} ...

hidden gorge
sterile lantern
#

change the / to a \

hidden gorge
#

i did and it crashes

hidden gorge
sterile lantern
#

yes

#

``` const newCommand = require(./commands/${folderName}/${command.data.name}.js);

#

this line

#

change the / to \

hidden gorge
#

ok ima try it

#
Error executing command: Error: Cannot find module 'C:\Users\FRC 7722\Desktop\Projects\Bots\RoSearchBot\commands\developer/commands/misc/about.js'
#

at Object.execute (C:\Users\FRC 7722\Desktop\Projects\Bots\RoSearchBot\commands\developer\reload.js:25:42)

sterile lantern
#

why is it doing \commands\developer/commands/misc

hidden gorge
#

idk

sterile lantern
#

your paths are messing up

#

hm

#

that happened after you changed it to a \ right

hidden gorge
#

its erroring at:

            const resolvedPath = require.resolve(`${__dirname}/commands/${folderName}/${command.data.name}.js`);
hidden gorge
#

its always happened

sterile lantern
#

the two errors are different

#

oh

#

nevermind

hidden gorge
#

WAIT

sterile lantern
#

youre forgetting to go outside

#

of the folder

hidden gorge
#

ITS TRYING TO FIND THE COMMAND IN THE FOLDER IT WAS RAN IT

sterile lantern
#

..

#

yeah

hidden gorge
sterile lantern
#

global commands can take up to 1 hour to propagate

hidden gorge
#

ooooh

sterile lantern
#

guild specific commands on the other hand update instantly, so you could use those if your bot is only in one guild

sterile lantern
#

interesting, what'd you do

wheat mesa
eternal osprey
#
  let data = JSON.parse(localStorage.getItem("data"))     
    let cookie = JSON.parse(localStorage.getItem('key'))
    console.log(cookie)
    console.log(data)
  fetch("http://127.0.0.1:4000/api/completed", {
                method: "POST",
                headers: {
                    "Content-Type": "application/json",
                    sessionKey: JSON.stringify(cookie),
                    cart: JSON.stringify(data), // Converting cart to a string
                },
                body: JSON.stringify({ email: "data" }),
            })```

hey guys why is this error occuring here?
#

In all my other fetch operations this error does not happen, while i use the exact sme method (though i don't retrieve data from the localStorage.

wheat mesa
#

Are you sure there isn’t like some sort of weird Cyrillic letter in that string or something

eternal osprey
#

it might

#

i might consider not encrypting the email

sterile lantern
#

is there a reason why some of my button interactions fail but some of them work?? even if they fail, they still run through the entire cmd (just dont give the response) so im a bit confused

#

ik we should be replying within 3 seconds, which im pretty sure it does, but idk why its failing

#

it happens randomly

#

same with some commands

deft wolf
#

Sometimes the bot may take a little longer to execute the code, sometimes it's the code, sometimes the hosting

sterile lantern
#

its using cf workers

#

if i were using gateway i would just defer

#

but i cant even defer with cf workers which sucks

lament rock
#

You can defer immediately within the worker and then edit the original interaction response later on

#

the HTTP response from the worker should be the defer

#

then you can use rest to edit

#

alternatively, you can "load balance" interactions by receiving over the gateway, but if Discord asks you to reconnect, then the interactions might expire

#

depends on how fast you can reconnect and resume

sterile lantern
#

i tried deferring

#

and it is stuck on thinking

#

and doesnt respond

#

even tho i do the post request and reply to the original interaction

lament rock
#

Dont followup or use the reply to interaction endpoint. You have to edit the original interaction response after deferring

sterile lantern
#

oh

#

i was following up

#

ill try that, thanks

lament rock
#

You also need to wait for the http response to be sent before you can PATCH the interaction response

sterile lantern
lament rock
#

Yea

sterile lantern
#

will try that

sterile lantern
#

response1 is the reply

ionic schooner
#

Does anyone have any suggestions for SMTP services?

lament rock
sterile lantern
#

hmm

#

would

#

try { return the deferred response } finally { do the actual stuff } work as well

sterile lantern
#

(setimmediate isnt supported)

#

it does defer, but it doesnt execute the setTimeout

spark flint
# ionic schooner Does anyone have any suggestions for SMTP services?
MailerSend

Start sending emails with our top-rated service. Sign up for free now to streamline your email sending process with API or SMTP.

#

i use both, i love them

#

postmark has amazing support

#

so does mailersend

ionic schooner
spark flint
#

no worries 🔥

#

easier to setup and use compared to sendgrid

#

(and cheaper)

ionic schooner
#

I should be good with the free tier, since I'm really only using this for login and such

#

using mailersend that is since SMS, not sure if I'll have a use for SMS but we shall see

spark flint
#

fairs

soft gazelle
#

Is there a code for punishments, promote, demote and terminate like

Username: {username}
Rank: {rank}
Punishment: {punishment}
Reason: {reason}

?

wheat mesa
#

Yeah that's not how this works

#

You're gonna need to start by learning a programming language

#

While I would normally recommend something like Java, if you only intend to program as a hobby/for discord bots and not as a profession, you can start off with javascript

#

Developing a system like that is going to require a relatively large amount of knowledge and there is no 20 line script that does it all for you

soft gazelle
#

Okay, so is there a video? Or is the a format I can copy and paste it?

wheat mesa
#

For what you want specifically? No, there is no video. There is no copy paste. You have to learn how to develop something like that by learning how a programming language works

craggy pine
wheat mesa
#

This is not a quick process, so if you're just looking for a custom bot for your server, you're probably just going to want to hire a developer or find a friend that happens to know how to code

#

However if you intend on learning a programming language, feel free to ask for help here and in other programming related servers

soft gazelle
#

Thanks

sharp geyser
wheat mesa
#

oracle docs

sharp geyser
#

Yikes

radiant kraken
#

it's basically JavaScript just slightly different

#

should be easy if you come from a JS background

wheat mesa
#

@sharp geyser did u give up on learning C++

#

you should do opengl

#

🧌

#

Here's a method I just wrote

#
    std::vector<std::tuple<glm::vec2, glm::vec2, const unsigned char *>> Pack();
#

now THAT is cursed

radiant kraken
#

@wheat mesa you should do OpenSSL

wheat mesa
#

beyond belief

radiant kraken
#

🧌

#

write an entire discord bot with just openssl calls

wheat mesa
#

The return type is unreadable but so is the actual function

#
std::vector<std::tuple<glm::vec2, glm::vec2, const unsigned char *>> TextureAtlas::Pack() {
    // ((x, y), (w, h), data)
    std::vector<std::tuple<glm::vec2, glm::vec2, const unsigned char *>> returnValue;
    stbrp_context ctx;
    auto *nodes = new stbrp_node[m_Width];
    stbrp_init_target(&ctx, m_Width, m_Height, nodes, m_Width);
    auto *rects = new stbrp_rect[m_Textures.size()];
    for (int i = 0; i < m_Textures.size(); i++) {
        const auto &entry = m_Textures[i];
        rects[i] = stbrp_rect{entry.id, entry.texture.Width(), entry.texture.Height(), 0, 0, false};
    }
    stbrp_pack_rects(&ctx, rects, m_Textures.size());
    delete[] nodes;
    int notPacked = 0;
    for (int i = 0; i < m_Textures.size(); i++) {
        const auto &entry = rects[i];
        // Guaranteed to exist
        const auto &texture = m_Textures[entry.id];
        if (!entry.was_packed) {
            notPacked++;
        } else {
            returnValue.emplace_back(glm::vec2(entry.x, entry.y), glm::vec2(entry.w, entry.h), texture.texture.Data());
            m_IdToUV[entry.id] = {{entry.x / static_cast<float>(m_Width), entry.y / static_cast<float>(m_Height)},
                                  {entry.w / static_cast<float>(m_Width), entry.h /
                                                                          static_cast<float>(m_Height)}}; // (x, y), (w, h)
        }
    }
    delete[] rects;

    if (notPacked > 0) {
        std::cout << "[WARNING]: " << notPacked << " textures could not fit in texture atlas!";
    }

    return returnValue;
}
#

and holy shit

#

it ACTUALLY WORKS

#

FIRST TRY

radiant kraken
#

looks pretty readable to me

#

i have seen worse C++ code

wheat mesa
#

I think I'm leaking memory in there somewhere but I do not give a fuck right now

radiant kraken
#

with less lines

wheat mesa
#

i am genuinely impressed with myself

#

managed to do all of that with just 50 firefox tabs of obscure opengl documentation and a 2am flow state

lament rock
#

I thought I understood Quaternions, but I had to double check with ChatGPT and now I think I get it. The w component was really confusing as I'm more used to Euler angles and 360° representations, but I guess the w component just helps with performance somehow and makes interpolation between rotations smoother

wheat mesa
#

Quaternions are scary man

#

Good thing I’m only doing 2d!

lament rock
#

Now I got it down actually. That's really confusing to understand

#

Well I mean it makes sense now that I was able to correctly feed it a scenario and tell me if I was right

#

but at that point, I just don't understand what use case it has outside of animation

wheat mesa
#

(The “just” part was a joke)

sharp geyser
#

I’m just not certain on what to do anymore, I’d love to continue learning the language but quite honestly I’ve lost the love I had for programming largely due to discord bots and doing them for 3 years

#

I also never learned properly so my knowledge was very limited in the languages I did learn. I’m also just not as smart as everyone else I see pursuing it and it honestly bums me out

radiant kraken
#

i still harbor some impostor syndrome around my friends

civic sundial
#

Can someone tell me about this

Error: Not enough sessions remaining to spawn 1 shards; only 0 remaining; resets at 2024-02-18T151615.578Z"

pale vessel
#

i am stupid and i am happy

civic sundial
#

"Happy"

solemn latch
#

dont ping random people for development questions

#

If someone knows they will answer.

civic sundial
#

unless you are not ? thinking_ggblackpearl

solemn latch
#

I am, but I cant help you right now.

civic sundial
#

Okie

#

Np

spark flint
civic sundial
#

btw thanks

civic scroll
#

restarting on every single file change won't be good

deft wolf
#

Especially if you often make small typos like me kappalul

civic scroll
#

maybe consider code a watchdog for your bot, but for the command files
so that when said file changes, your bot can just re-import said modules

#

without having itself restarting

civic scroll
#

me when silly syntax error

civic scroll
# civic sundial Ohh

saves the full restart for when you change the core mechanics of the bot itself

#

reminded me that i wanted to make an interactive shell of the bot back in the day
so i can issue hot reload right there without stopping the bot from running

#

i was too lazy 😔

civic sundial
surreal sage
past field
#

can i have some help pls 😅 trying to make a bot.. i typed in npm i in the terminal and it says it can’t find the “package.json” file

solemn latch
past field
#

no, i thought since the file was already in there it would load it up! sorry I’m new to this

solemn latch
#

package.json is?

past field
past field
sterile lantern
#

how do i go about implementing context.waitUntil for deferring replies and stuff (cf workers)

sterile lantern
solemn latch
#

^
The terminal is in a different folder

past field
sterile lantern
#

cd <path to your project>

past field
#

in the terminal?

sterile lantern
#

yes

past field
#

in which file?

#

thank you so much for your help!

sterile lantern
#

what do you mean?

#

you need to type the command into your terminal

past field
#

really sorry if i’m asking stupid questions lol i’m new to this

sterile lantern
#

no worries

past field
#

so it doesn’t matter which one of the files on the left is selected?

sterile lantern
# past field

based on this picture, your path is donm0/Da-High-Roller-Bot

so the command would be cd donm0/Da-High-Roller-Bot

#

nope

#

you need to type this into your terminal

#

nothing to do w files

past field
#

ok thank you i’ll try this

#

hm

sterile lantern
#

im not sure where your project is located so you need to find the path to it

past field
#

i have it connected to github! is that what you mean?

sterile lantern
#

no, i mean the location of your repo on your laptop

#

where is the folder located on your laptop?

past field
#

ok let me see if i can figure that out

#

i don’t remember making a folder, let me see if i can find one

#

i must have skipped that step lol

sterile lantern
#

you mightve ran a command to clone a repo which would automatically create a folder

#

open your files and try to look for the folder

solemn latch
# past field in which file?

right click on any file in the explorer it should say "reveal in (something)" your file explorer or whatever its called in mac terms.

past field
#

is there a way for me to download this onto my desktop and create that folder so i can have a path?

#

for some reason i’m not seeing a folder 😭

solemn latch
#

is it not already downloaded?
it looks like you've been modifying local files

past field
#

that might be why

solemn latch
#

The M next to config.json means modified

past field
#

i created a fork in github of this, i thought that was me making my own copy

solemn latch
past field
#

@solemn latch

solemn latch
#

👀 so weird, I wonder how you got here

past field
#

i was following the video mac posted on youtube lol, should i just start over from the beginning?

#

or is there a way to fix it here

solemn latch