#development

1 messages ยท Page 1937 of 1

wooden ember
#

what the bot file or chalk

earnest phoenix
#

lemme look for a way to use chalk in cjs

earnest phoenix
wooden ember
#

bruh

#

i shoulda just used c# or something to code my bots

#

so i dont have to have this much pain every update

earnest phoenix
#

.NET has an intense learning curve

wooden ember
#

i know but i have to learn it for collage so it would atleast be usefull

earnest phoenix
#

well i couldn't find any way to use chalk in cjs

#

well fuck

wooden ember
#

should i just remove chalk from my bot

wheat mesa
#

C# is much less forgiving than js, but it's a great language imo

wooden ember
#

i know and thats one of the good things i think

#

cuz if i get an error i want it to crash so i can fix it

#

unlike in js where it just spams the console

earnest phoenix
#

try manually converting chalk to cjs

wooden ember
#

how do i do that?

sudden geyser
#

what's there to like in c#

#

I feel like it has the same issues as java

wooden ember
#

its more stable

sudden geyser
#

especially all that get this get that killing the reuse of your program

wooden ember
earnest phoenix
#
npx esbuild ./node_modules/chalk/source/index.js --platform=node --outfile=chalk.cjs
earnest phoenix
#

get it, see sharp

sudden geyser
#

thank god I'm going blind in my right eye ๐Ÿ˜„

wooden ember
#

lol

wooden ember
quartz kindle
#

ESM is a new module loader that was created to replace require. however due to how different it is, they are not easily compatible with each other, so to use ESM your entire project as to be ESM, otherwise the engine wont know how to load non ESM files

earnest phoenix
#

try this see what happens

quartz kindle
#

there are many different ways to deal with this

#

one way is to downgrade the chalk version to the last version that was not ESM

wooden ember
#

i might do that if this doesnt work

quartz kindle
#

another way is to use a dynamic async import, like this: chalk = await import("chalk")

wooden ember
#

or just not use chalk at all

earnest phoenix
quartz kindle
#

another way is to convert your entire project to ESM by setting "type": "module" in your package.json

wooden ember
#

i thryed that but i cant import discord then

earnest phoenix
#

another way is to not use chalk

earnest phoenix
wooden ember
#

and the error i got i googled and it just said to remove the "type" thing

earnest phoenix
#

you probably tried import { Client } from "discord.js";

quartz kindle
#

cjs named exports are runtime, only when the code is run, are the names checked and used

#

esm named exports are statically typed during file analysis, before loading

#

meaning its more like typescript

wooden ember
#

yeah its not working

#

ima just not use chalk

quartz kindle
#

it already knows what the file exports before actually running the file

quartz kindle
#

the easiest fix is to use dynamic async imports

#

const chalk = await import("chalk")

earnest phoenix
wooden ember
#

ah

earnest phoenix
#

do not fail me esbuild

quartz kindle
wooden ember
#

i just removed chalk from the bot but ill try to get it to work later cuz my other bots use chalk alot more

#

i know ima have alot more issues with getting my bot working after updating to v13

earnest phoenix
#

this is starting to feel like trading solana on an ethereum exchange

quartz kindle
#

lmao

#

dont remind me of solana T_T

wooden ember
#

how do intents work? cuz thats a new thing now (well to me probably)

#

i looked on the internet abit and the people on stackoverflow just say to enable everything

#

but i dont really want to do that

oak cliff
#

You want to enable intents for events you want to receive basically

#

So if you want your bot to be notified when someone sends a message in a guild, you want the guild message intent

wooden ember
#

ah ok

oak cliff
#

But if you don't want your bot to be notified when say, a new channel gets created, then you don't need the channel update intent

#

You only want to ask for intents you need as it saves your bot ram and cpu and stuff b_nod

wooden ember
#

my bot just saves a massage you send it so i will need the msg intent

#

isnt msg content a separite intent now too?

solemn latch
#

Message content intent will be privileged soon

wooden ember
#

yeah

oak cliff
#

Yeah guild message and message content is seperate

wooden ember
#

cool

oak cliff
#

But you will still received message content if your bot is pinged in the message

solemn latch
#

Or dmed it

oak cliff
#

Or if it's in dms

#

Ye

#

But you need the dm message intent iirc

wooden ember
#

yeah read about that cuz i might have to change the prefix for my bot to use mentions

oak cliff
#

Or slash commands, yep

wooden ember
#

eh

#

i dont like those

oak cliff
#

They're going to get better from where they are now

wooden ember
#

true

solemn latch
#

Normal commands will be harder and harder to use until everyone's kinda forced too.

wooden ember
#

yeah

oak cliff
#

I use mention prefix for like, eval and owner commands but that's it

sudden geyser
#

eh, some developers will choose the stubborn route regardless

oak cliff
#

Slash commands are pretty much what you gotta do at this point

wooden ember
#

i know just having a prefix for a bot is kinda messy but the way slash commands work is also abit wack too

wooden ember
sudden geyser
#

I wish slash commands were more dynamic, like allowing bots to dynamically add/require inputs

sudden geyser
solemn latch
#

Wait, why can't you dynamically have inputs? Optional fields and whatnot.

#

Especially with the command input thingy that got added

sudden geyser
#

For my case, I have a /tag command and wanted to add variables the user can use. For example, ?user jumps over the moon! and the user can run it with /tag get moon ... where ... is the variable value.

#

There's no good static way to do that

wooden ember
#

its for saving notes and info so for example you do

== write hello world this is an example

and the bot saves everything after the prefix formatting and all

sudden geyser
#

since there could be an arbitrary amount of variables

#

the solution would be to use a delimiter like ,, |, etc. but that's yucky

wooden ember
#

and its really hard to type out things that use code blocks and the likes in a slash command

earnest phoenix
solemn latch
#

Lines are an issue fair,
Could still use slash commands and require the user to dm the bot the values.

So you stay compliant with the goals of discord, while keeping usability.

sudden geyser
wooden ember
#

well that would be a step in the right direction

#

cuz then i would expect that it would work just like sending a normal msg

#

we'll have to see

#

so im reading the docs and it says

const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

for other intents do i just add them like

#
const client = new Client({ intents: [Intents.FLAGS.GUILDS], [MESSAGE.CONTENT] });
#

or is that not how it works?

oak cliff
#

You'll need to do Intents.FLAGS.[flag] for every one

wooden ember
#

ooh ok

#

like

const client = new Client({ intents: [Intents.FLAGS.GUILDS], [Intents.FLAGS.MESSAGE.CONTENT] });
```?
oak cliff
#

Make sure you've required Intents from discord.js as well

#

I believe that's right yeah

wooden ember
#

yeha did that

#

nice

wheat mesa
#

Stupid java question, but if I have a folder full of classes (that extend a base class) and I want to make an instance of each one of them without having to do T variable = new T(); for every class, is there a way to do that?

sudden geyser
#

Maybe with the reflection API

#

but with a static language like java? not so easy

#

I think @lyric mountain did something like this before

earnest phoenix
#

this will give a syntax error

#

intents is a single array, not multiple arrays

#

intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.MESSAGE.CONTENT]

wooden ember
#

yeah i descovered that

#

is setting the status in the client still a thing?

#
const bot = new Client({
    presence: {
        activity: {
            type: "PLAYING",
            name: "==help"
        }
    }
});
``` like this
#

cuz thats what i did in v12 to stop my status going away after 5 seconds

#

but i cant do that with the intents aswell aparently

earnest phoenix
#

why will it go away

wooden ember
#

cuz my internet is bad

#

if the hartbeat times out or something and the disconnects and then reconnects so if its set normally it just disapears

earnest phoenix
#

that's a problem with the entire bot going down not just the status

wooden ember
#

i know you can just do it on a settimout loop but thats too messy for my liking

wooden ember
quartz kindle
#

that should still work in v13 yes

wooden ember
#

but how would i integrate that with setting intents aswell

wooden ember
#

lol

quartz kindle
#

{ option1: blah, option2: blah }

wooden ember
#

yeah im dumb i forgot the comma at the end of the intents line

#
const botIntents = new Intents();
botIntents.add(Intents.FLAGS.GUILDS, Intents.FLAGS.MESSAGE_CONTENT);

const bot = new Client({
    intents: botIntents,
    presence: {
        activity: {
            type: "PLAYING",
            name: "==help"
        }
    }
});
``` i found you can just do this
#

but it just says

#

knowing me i just spelled somthing wrong

sudden geyser
#

You're probably looking for GUILD_MESSAGES

wooden ember
#

ah cool

quartz kindle
#

MESSAGE_CONTENT is not a thing yet

sudden geyser
#

I think you posted in the past dynamically creating your command classes

#

in Java

wooden ember
lyric mountain
#

Not exactly creating classes

#

But I used reflection to load annotated commands without needing to specify each one

sudden geyser
#

ye that

lyric mountain
#

I was going to release a command manager lib but...too lazy ig

#

You can still find the repo under my profile, it should be pretty functional as it is

#

It's named UCH, used the same method I used for my own commands

quartz kindle
#

scroll down

#

and you'll find this

lyric mountain
#

Tf

quartz kindle
wooden ember
#

oh fair enough

#

I'm ahead of the game

#

lol

earnest phoenix
#

like everything else

split hazel
#

why does everything use java

earnest phoenix
split hazel
#

there's probably life support machines written in java

#

imagine there's an exploit or buffer overflow

earnest phoenix
#

EXPLOITKOPTER EXPLOITKOPTER

split hazel
#

did you know your mother is powered by apache log4j

sudden geyser
earnest phoenix
#

like the fact that you're talking to the mirror

split hazel
#

yeah that's right

#

your mother hit up my dns server

#

and was exploited

quartz kindle
#

i like this one

earnest phoenix
#

i like your mom

quartz kindle
#

and to think java is only third place in the languages with most vulnerabilities

earnest phoenix
quartz kindle
#

scala idk

earnest phoenix
wheat mesa
#

Okay so I've got a weird Java issue, java public void addOrModifyValue(String key, int value) { if(this.getValue(key) == -1) { this.addValue(key, value); } else { int i = 0; String[] content = new String[512]; // If you make more than 512 lines, you need help. try { Scanner scan = new Scanner(this.file); while(scan.hasNextLine()) { content[i] = scan.nextLine(); ++i; } scan.close(); } catch(Exception e) { // File 100% exists by now, this will never be executed } i = 0; StringBuilder sb = new StringBuilder(); for(String s : content) { if (s.contains(key + ": ")) { content[i] = key + ": " + value + "\n"; } sb.append(content[i]); ++i; } try { FileWriter writer = new FileWriter(this.file, false); writer.write(sb.toString()); writer.close(); } catch(Exception e) { // Failed to write } } } I have this code for a basic K/V store (for config stuff, making a minecraft mod to learn some more java), and I keep getting a NullPointerException on the line if (s.contains(key + ": "))

lyric mountain
#

Java is unreadable on mobile ic

wheat mesa
#

lol

lyric mountain
#

You could use stream sir

#

I mean, what is this?

wheat mesa
#

ig but that still doesn't change the problem

earnest phoenix
lyric mountain
#

What is the current class?

wheat mesa
#

this is an instance of a class I've made for managing basic config settings in txt files

short pilot
#

it just occurred to me, is this a bug in my top.gg code? Seems to happen randomly like once a day...

lyric mountain
#

Like a properties file?

wheat mesa
#

It doesn't really have anything to do with the issue since I've verified that the file exists

#

Yeah basically, just as a .txt

lyric mountain
#

Java has native support for that

wheat mesa
#

I know but I'm doing this to learn

sudden geyser
lyric mountain
#

If it's a key=value

sudden geyser
#

and that's as far as it goes

wheat mesa
#

It's a key: value

quartz kindle
lyric mountain
#

Properties with different separator then

wheat mesa
#

I'm assuming that it's not reading the lines correctly or smth

#

Lemme do some logging and I'll give you more details

lyric mountain
#

Put that code in hastebin

#

So I can see it formatted on mobile

wheat mesa
#

Oh I'm an idiot

#

I forgot that initializing an array like that makes all the other entries null since they're strings

#

That would make a lot more sense since I'm using a foreach loop so it's going over the null entries

lyric mountain
#

Ah, yeah

#

Didn't see that

quartz kindle
#

the most vulnerable programming languages by flaws per megabyte of code:

Classic ASP โ€“ 1,686 flaws/MB (1,112 critical)
ColdFusion โ€“ 262 flaws/MB (227 critical)
PHP โ€“ 184 flaws/MB (47 critical)
Java โ€“ 51 flaws/MB (5.2 critical)
.NET - 32 flaws/MB (9.7 critical)
C++ โ€“ 26 flaws/MB (8.8 critical)
iOS โ€“ 23 flaws/MB (0.9 critical)
Android โ€“ 11 flaws/MB (0.4 critical)
JavaScript - 8 flaws/MB (0.09 critical)
lyric mountain
#

Btw u can use Objects.equals() which is null safe

#

Or use reverse equals

#

(key + ": ").equals(s)

earnest phoenix
#

the dotnet programming language

sudden geyser
#

so they're just looking at codebases

#

makes sense for Android beating iOS given low-level C/C++/Objective-C history

quartz kindle
#
Taking a closer look at PHP:

86% of applications written in PHP contained at least one cross-site scripting (XSS) vulnerability.
56% of apps included SQLi (SQL injection), which is one of the dangerous and easy-to-exploit web application vulnerabilities.
67% of apps allowed for directory traversal.
61% of apps allowed for code injection.
58% of apps had problems with credentials management
73% of apps contained cryptographic issues.
50% allowed for information leakage.
earnest phoenix
#

their git server was compromised right?

quartz kindle
#

idk dont remember that

earnest phoenix
#

google it

#

you're in for a treat

quartz kindle
#

lmao

wooden ember
#

the bot has no status

quartz kindle
#

follow the docs

wooden ember
#

it doesnt say anything about setting it when the client is made

#

or am i blind

#

wait lemme try somthing

quartz kindle
#

it shows you what is accepted inside presence: {}

#

inside Client()

wooden ember
#

oh i see

#

but

#

ok

#

im pretty confused now

#
const bot = new Client({
    intents: botIntents,
    presence: {
        activity: {
            type: "PLAYING",
            name: "==help"
        }
    }
});
``` i have this and it doesnt work
#

no errors nothing

#

however i cant see any other way of doing it since thats all you need

quartz kindle
#

did you read the docs?

wooden ember
#

yeah

quartz kindle
wooden ember
#

i looked at the status one

quartz kindle
wooden ember
#

ah...

#

i see

#

but then whats the status then?

#

cuz i thought thats what that is

earnest phoenix
#

today firenado learned discord.js sucks

wooden ember
#

i descovered that a while back im just lazy and dont fancy recoding all my crap in another language

solemn latch
#

djs isnt the only library for javascript

#

theres a few options that are better

earnest phoenix
#

don't use the actual docs tho

quartz kindle
wooden ember
#

yeah read that and thats why i was confused cuz theres an example thing there and the way you set that is very symilar to the way you set the other thing

earnest phoenix
#

status: "online"

#

bruh

wooden ember
#

well idk do i this crap seems to change on a daily basis and i havent updated anything in like a year

wheat mesa
# sudden geyser Ye so you could do something like this https://github.com/OtagamerZ/ShiroJBot/bl...

So I'm still not quite sure how to do this properly. I've got ```java
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommand;
import org.reflections.Reflections;
import java.util.ArrayList;
import java.util.Set;

public class Commands {
private final ArrayList<ICommand> commandList;
private final Reflections refl = new Reflections("dev.jwaffled.dragsimutils.Commands");
private final Set<Class<? extends CommandBase>> cmds = refl.getTypesAnnotatedWith(Commands.class);

public Commands() {
    this.commandList = new ArrayList<ICommand>();
    for(Class<? extends CommandBase> cmd : cmds) {
        commandList.add(cmd);
    }
}

public ArrayList<ICommand> getCommandList() {
    return this.commandList;
}

}
``` which is certainly wrong. All the classes in this folder extend CommandBase, but I can't figure out how to call the getTypesAnnotatedWith() function correctly

wooden ember
#

i cant see anything about why it wouldnt be working
type is set as PLAYING
name is set as ==help
i see no reason why this code does not work

wheat mesa
#

(Also the commandList.add(cmd) gets mad at me since the type isn't matching, but anything extending CommandBase should be ICommand)

earnest phoenix
#
if(id === 'yes') 
 ButtonInteraction.first()
return; {
 
  
  ButtonInteraction.editReply({ embeds: [yesembed], components: [row2] })```
How come it doesn't update?
#

Y'all just love seeing me everyday ikik ๐Ÿคฃ

quartz kindle
wooden ember
#

and i dont get what you are saying

#

at all

earnest phoenix
wooden ember
#

i just did and it just said what i already know

quartz kindle
wooden ember
#

its the same thing

quartz kindle
#

what same thing?

wooden ember
#

the docs say these are the only options

#

and i have set my thing to playing

#

and that should work

quartz kindle
#

the problem is not what you have inside your activity

earnest phoenix
#

This is why I use a client.on('ready') for my status's ๐Ÿคฃ

quartz kindle
#

activity does not exist in the docs

#

its activities

#

and its an array, not an object

wooden ember
#

ah well

quartz kindle
wooden ember
#

why did they change it to activities though

quartz kindle
#

Client({ presence: { activities: [{ your activity data here}] } })

earnest phoenix
#

whyGod They just did ๐Ÿคฃ

quartz kindle
#

because discord supports multiple activies

wooden ember
#

my brain hurts

wooden ember
quartz kindle
#

yes, not sure if bots support them tho

earnest phoenix
#

Heyo big man Tim, can you check out my little questionnn above^?

#

I deleted all my files by accident last night, I woke up and they aren't here, now nothing is working. ๐Ÿคฃ

#
const filter = (interaction) => {
if(interaction.user.id === interaction.member.id) return true;
return interaction.reply({ content: "You can't use this button" })

}

    const collector = interaction.channel.createMessageComponentCollector({ 
      filter,
      max: 1,
     })
      
collector.on('end', (ButtonInteraction) => {
const id = ButtonInteraction.first().customId;

if(id === 'yes') 
 ButtonInteraction.first()
return; {
  ButtonInteraction.editReply({ embeds: [yesembed], components: [row2] })
lyric mountain
#

Aaand that's why u use git kids

earnest phoenix
#

๐Ÿคฃ ikr

#

I gotta start backup my stuff, but I keep forgetting.

royal portal
#

how to set folder limit in ubuntu?!?!1

earnest phoenix
#

It says "this interaction failed"

#

I think that's right iirc I did something like that, but idk if I did the return; {} right

quartz kindle
#

show full code

#

return; {} makes no sense

earnest phoenix
#
const { SlashCommandBuilder } = require('@discordjs/builders');
const { Permissions, Discord, MessageActionRow, MessageButton, MessageEmbed, MessageSelectMenu } = require('discord.js')
const db = require('quick.db')
module.exports = {
    data: new SlashCommandBuilder()
        .setName('allow')
        .setDescription('Allow Bumps to be Sent to the #bumps Channel.!'),
        async execute(interaction, message) {


if(!interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) return interaction.reply({content: `You may **not** use this Command.`, ephemeral:true})



const embed = new MessageEmbed()
.setAuthor(interaction.user.username, interaction.guild.iconURL())
.setDescription(`**Are You Sure**?\n> \`Allowing bumps will allow other servers to send their servers Advertisement Automatically to your Servers Incoming Chanenl. Note: These are w/o pings, so you can Mute the channel.\` `)

const yesembed = new MessageEmbed()
.setAuthor(interaction.user.username, interaction.guild.iconURL())
.setDescription(`**Bumps are now allowed to be sent in ${interaction.guild}.**`)

const noembed = new MessageEmbed()
.setAuthor(interaction.user.username, interaction.guild.iconURL())
.setDescription(`Interaction Cancelled`)

 const row = new MessageActionRow().addComponents(
new MessageButton()
.setLabel("Yes")
.setEmoji('917576157472362496')
.setStyle('SUCCESS')
.setCustomId('yes'),
    
new MessageButton()
.setLabel('No')
.setEmoji('917577322696171550')
.setStyle('DANGER')
.setCustomId('no'));

 const row2 = new MessageActionRow().addComponents(
new MessageButton()
.setLabel("Yes")
.setEmoji('917576157472362496')
.setStyle('SUCCESS')
.setDisabled(true)
.setCustomId('yes2'),
    
new MessageButton()
.setLabel('No')
.setEmoji('917577322696171550')
.setStyle('DANGER')
.setDisabled(true)
.setCustomId('no2'));


 interaction.reply({ embeds: [embed], components: [row] })


const filter = (interaction) => {
if(interaction.user.id === interaction.member.id) return true;
return interaction.reply({ content: "You can't use this button" })

}

    const collector = interaction.channel.createMessageComponentCollector({ 
      filter,
      max: 1,
     })
      
collector.on('end', (ButtonInteraction) => {
const id = ButtonInteraction.first().customId;



if(id === 'yes') 
 ButtonInteraction.first()
return; {
 
  
  ButtonInteraction.editReply({ embeds: [yesembed], components: [row2] })

        }})}}```
quartz kindle
#

that return makes no sense

earnest phoenix
#

lmfao, yeah ik

wooden ember
#

are you kidding me all i had to do was d and "ies" and [] to fix this the whole time
AAAAAAGH

earnest phoenix
#

I figured.

wooden ember
#

anyway thx for the help guys

quartz kindle
cinder patio
#

Do you guys think regex would be faster than using a for loop on a string? I want to write something like a markdown parser and I'm not sure If I should just use a for loop or regex, all the major markdown parsers are using regex

earnest phoenix
lyric mountain
#

Regex is never faster

earnest phoenix
#

๐Ÿคฃ

wooden ember
#

now my bots working on d.jsv13 so that cool

sudden geyser
#

regex is some parser

wooden ember
quartz kindle
#

regex will be faster than a loop, if your loop is gonna iterate over all characters

earnest phoenix
#

I think I can just do this if(id === 'yes') {

#

Yep

cinder patio
#

I see, well yeah it's gonna iterate through all of them

wheat mesa
#

fuck reflection

cinder patio
#

but the thing is that multiple different regexes will be ran on the same string a lot of times

quartz kindle
earnest phoenix
#
        let clientPerms = [];

        command.ClientPerms.forEach((perm) => {
            if(!client.member.permissions.has(Discord.Permissions.perm))
            {
              clientPerms.push(perm);
            }
        });

ClientPerms: ["BAN_MEMBERS"],


 RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number: undefined.
earnest phoenix
lyric mountain
quartz kindle
#

string.indexOf is stupid fast

wheat mesa
lyric mountain
#

What are u struggling?

wheat mesa
#

I'm trying to make a command handler for some minecraft commands with reflection to get each command class, and I just don't know what to do

#

I've got this atm: ```java
package dev.jwaffled.dragsimutils.Commands;

import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommand;
import org.reflections.Reflections;

import java.util.ArrayList;
import java.util.Set;

public class Commands {
private final ArrayList<ICommand> commandList;
private final Reflections refl = new Reflections("dev.jwaffled.dragsimutils.Commands");
private final Set<Class<? extends CommandBase>> cmds = refl.getTypesAnnotatedWith(Commands.class);

public Commands() {
    this.commandList = new ArrayList<ICommand>();
    for(Class<? extends CommandBase> cmd : cmds) {
        commandList.add(cmd);
    }
}

public ArrayList<ICommand> getCommandList() {
    return this.commandList;
}

}

quartz kindle
earnest phoenix
#

while saving slash commands

wheat mesa
#

But the problem is that commandList.add(cmd) doesn't accept it because it has to be of type ICommand, but anything that extends CommandBase should be ICommand

quartz kindle
wheat mesa
#

(And I've got this problem with creating the set of commands: Cannot resolve method 'getTypesAnnotatedWith(java.lang.Class<dev.jwaffled.dragsimutils.Commands.Commands>)')

earnest phoenix
#
    let MemberPerms = file.MemberPerms || [];
    let ClientPerms = file.ClientPerms || [];
      const data = { name, description, options, MemberPerms, ClientPerms };
quartz kindle
#

and then you do command.ClientPerms = ClientPerms?

earnest phoenix
#

Yes

quartz kindle
#

or how do they get to command?

#

so what is file.ClientPerms?

earnest phoenix
#
module.exports = {
    name: 'user',
    description: 'Get some info about Discord User',
    options: [{
      name: 'target',
      type: 'USER',
      description: 'Select a user',
      required: false,
    }],
    MemberPerms: ["BAN_MEMBERS"],
    ClientPerms: [],
    async run(client, i, lang, options) {
#

I know this is wrong needed perm just did for try

quartz kindle
wheat mesa
# wheat mesa I've got this atm: ```java package dev.jwaffled.dragsimutils.Commands; import n...

although seems everything works except for adding the command to the ArrayList when I do ```java
public class Commands {
private final ArrayList<ICommand> commandList;
private final Reflections refl = new Reflections("dev.jwaffled.dragsimutils.Commands");
private final Set<Class<? extends CommandBase>> cmds = refl.getSubTypesOf(CommandBase.class);

public Commands() {
    this.commandList = new ArrayList<ICommand>();
    for(Class<? extends CommandBase> cmd : cmds) {
        commandList.add(cmd);
    }
}
earnest phoenix
quartz kindle
#

well thats not BAN_MEMBERS, that literally perm

#

if you want the value of perm you need to use []

#

Discord.Permissions[perm]

#

otherwise its literally perm

earnest phoenix
#

I looped it

#

Checking by one by

earnest phoenix
wheat mesa
#

oh wait I think I might've got it

#

lemme test

#

nvm

quartz kindle
earnest phoenix
#
    async member({member, command})
    {
        let memberPerms = [];

        command.MemberPerms.forEach((perm) => {
            console.log(perm)
            if(!member.permissions.has(Discord.Permissions[perm]))
            {
                memberPerms.push(perm);
                console.log(perm)
            }
        });

        if(memberPerms.length > 0)
        {
            return `Looks like You're missing the following permissions:\n${clientPerms.map((p) => `\`${p}\``).join(", ")} `
        }        

    }


      const MP = permChecker.member({
        member: int.member,
        command: command
      })

earnest phoenix
#

i get BAN_MEMBERS when i log perm

quartz kindle
#

show full error

earnest phoenix
#
Unhandled Rejection at: Promise {
  <rejected> RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number: undefined.
      at Function.resolve (C:\Users\aydin\Desktop\absda-main\node_modules\discord.js\src\util\BitField.js:152:11)
      at Permissions.has (C:\Users\aydin\Desktop\absda-main\node_modules\discord.js\src\util\BitField.js:44:28)
      at Permissions.has (C:\Users\aydin\Desktop\absda-main\node_modules\discord.js\src\util\Permissions.js:54:85)
      at C:\Users\aydin\Desktop\absda-main\util\PermChecker.js:29:36
      at Array.forEach (<anonymous>)
      at PermChecker.member (C:\Users\aydin\Desktop\absda-main\util\PermChecker.js:27:29)
      at Object.execute (C:\Users\aydin\Desktop\absda-main\events\interaction.js:25:30)
      at processTicksAndRejections (node:internal/process/task_queues:96:5) {
    [Symbol(code)]: 'BITFIELD_INVALID'
  }
}
quartz kindle
#

PermChecker.js:29 is that code?

earnest phoenix
#

Yes

quartz kindle
#

console.log(perm || "undefined")

earnest phoenix
#

BAN_MEMBERS

earnest phoenix
quartz kindle
#

BAN_MEMBERS then the error?

earnest phoenix
#

No

#

Its log result

quartz kindle
#

then when does the error happen?

earnest phoenix
#

When someone doesnt have BAN_MEMBER perm and tried to run code

quartz kindle
#

did you test it after changing .perm to [perm]?

earnest phoenix
#

Yes

quartz kindle
#

how did you test?

#

you removed your permission?

earnest phoenix
#

With perm and with no perm

quartz kindle
#

then why are you not testing now?

earnest phoenix
#

Testing what?

earnest phoenix
quartz kindle
#

you said there is no error

#

where is the error?

earnest phoenix
#

Bitfield is invalid

quartz kindle
#

...

#

you said there is no error in the logs

#

im asking you to test WITH the error

#

i want to see where the error happens

#

in the logs

#

and what is logged right before it

earnest phoenix
#

Okay
I tested with perms = no error
I tested without perms = bitfield is invalid

quartz kindle
#

show logs

earnest phoenix
#

i console logged perm and get BAN_MEMBERS result

quartz kindle
#

show logs with the error

earnest phoenix
quartz kindle
#

thank you

earnest phoenix
#

Dont take care Promise { undefined }

quartz kindle
#

are you using v12 or v13?

earnest phoenix
#

13

quartz kindle
#

v13 is Discord.Permissions.FLAGS[]

earnest phoenix
#

Oh lol

#

I forgot it

#

Thanks

subtle kiln
#

Hi! Is there a more concise way of writing emojis because I'm hitting the character limit in the embed (I'm constructing a game board with emojis). Even saving one character would save me

#

\<a\:_:012345678901234567>

#

ok, ignore backslashes but it's what I use

pale vessel
#

Are you using embed descriptions for the content?

subtle kiln
#

I'm using a field

pale vessel
#

That's why

#

A field is only 1024 characters but description supports up to 4096 characters

subtle kiln
#

oh ok I'll try that, thanks!

earnest phoenix
#

Back again
TypeError: Cannot read properties of undefined (reading 'guilds')

${client.guilds.cache.size}``` 
*Istg if this is a easy fix, which ik it is ![dieeeeeeee](https://cdn.discordapp.com/emojis/899295219709804564.webp?size=128 "dieeeeeeee")*
pale vessel
#

Check what client is

#

You might have provided wrong parameters

earnest phoenix
#
const client = new Client({
   // partials: ['MESSAGE', 'CHANNEL', 'REACTION' ],
    allowedMentions: { parse: ["users", "roles"] },
    intents: [
        Intents.FLAGS.GUILDS,
        Intents.FLAGS.GUILD_MESSAGES,
       // Intents.FLAGS.GUILD_MEMBERS,
        //Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
       // Intents.FLAGS.GUILD_WEBHOOKS,
       // Intents.FLAGS.GUILD_INVITES,
       // Intents.FLAGS.GUILD_PRESENCES,
    ],
});```
#

That's client

#

In my main file.

pale vessel
lyric mountain
earnest phoenix
#
        async execute(interaction, message, client) {
pale vessel
#

Add console.log(client) in the next line

earnest phoenix
#

undefined

pale vessel
#

Then client is undefined

wheat mesa
pale vessel
#

Check your handler

#

How did you execute that execute method?

lyric mountain
#

Then get all classes annotated by that

earnest phoenix
woeful pike
#

I spent 3 hours debugging a network problem caused by listening on 127.0.0.1 instead of 0.0.0.0 I'm gonna go stop programming forever now bye

wheat mesa
#

I would just do class @CommandName then?

lyric mountain
#

Nono

quartz kindle
lyric mountain
#
@Command
public class Somewhat {
wheat mesa
#

oh

#

decorators

#

I forgor those existed

quartz kindle
lyric mountain
#

With annotations you can also pass pre-defined values like name, category, misc shit, etc

earnest phoenix
quartz kindle
#

show setchannel.js

earnest phoenix
#
const { SlashCommandBuilder } = require('@discordjs/builders');
const { Permissions, Discord, MessageActionRow, MessageButton, MessageEmbed, MessageSelectMenu } = require('discord.js')
const db = require('quick.db')

module.exports = {
    data: new SlashCommandBuilder()
        .setName('channel')
        .setDescription('Yep Yep!')
        async execute(interaction, message, client) {

if(!interaction.member.permissions.has(Permissions.FLAGS.ADMINISTRATOR)) return interaction.reply({content: `You may **not** use this Command.`, ephemeral:true})


interaction.reply({ content: `Server count: ${client.guilds.size}.` })```
woeful pike
#

literally is a skill issue cuz I didn't know about internal/external networks

earnest phoenix
#

await command.execute(interaction);

quartz kindle
#

thats your problem

earnest phoenix
#

hm?

quartz kindle
#

you dont give it a message nor a client

wheat mesa
#

that makes life a hell of a lot easier, thank you so much @lyric mountain

quartz kindle
#

where is message and client supposed to come from?

earnest phoenix
#

Ah got it

quartz kindle
#

async execute(whatever you write here only exists if you give it to the function when you use it)

quartz kindle
#

command.execute(write here whatever you want to exist inside the function, in order)

lyric mountain
#

It's a great way to start in reflection

#

And you can make some sick stuff with it

earnest phoenix
#

Same error @quartz kindle

quartz kindle
#

then you did it wrong

#

show what you did

earnest phoenix
#
        await command.execute(interaction, client);
quartz kindle
#

the order has to be correct

#

you did interaction, client

earnest phoenix
#

interation, message, client?

quartz kindle
#

but in the file you have interaction, message, client

#

client is the 3rd one, not the second one

#

or remove message altogether

#

there is no message in interaction events anyway, so its useless to have it there

wheat mesa
round cove
#

Anyone know how I can verify that a message link is a valid link? Trying to move from message ID's to be more user friendly.

sudden geyser
#

You could verify each one (HTTP request), but I'd rather just leave it in whatever store and run the validation when it's read

delicate zephyr
#

and then do a fetch to the dapi/cache

round cove
wheat mesa
#

But how? It says the types are incompatible

#

oh wait I might be big stupid

lyric mountain
#

Get constructor -> new instance

#

It'll build into an object, which can be cast to whatever u extended it to

wheat mesa
#

I think I might've got it, time to test

#

fuck

lyric mountain
#

Big success?

wheat mesa
#
    public Commands() {
        this.commandList = new ArrayList<ICommand>();
        for(Class<?> cmd : commands) {
            try {
                commandList.add((CommandBase) cmd.getConstructor().newInstance());
            } catch(Exception e) {
                // Nothing
            }
        }
    }
``` this doesn't produce any compilation errors
#

but it doesn't work

lyric mountain
#

Does ur constructor have args?

wheat mesa
#

Nope

lyric mountain
#

Also, put sout inside catch

#

Reflection never causes compilation time errors

wheat mesa
#

I tried logging the error in the catch but nothing was produced

#

But there is a crash log

#
// I bet Cylons wouldn't have this problem.

Time: 12/12/21 1:22 PM
Description: There was a severe problem during mod loading that has caused the game to fail

net.minecraftforge.fml.common.LoaderException: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile
    at net.minecraftforge.fml.common.LoadController.transition(LoadController.java:162)
    at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:739)
    at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:310)
    at net.minecraft.client.Minecraft.startGame(Minecraft.java:538)
    at net.minecraft.client.Minecraft.run(Minecraft.java:364)
    at net.minecraft.client.main.Main.main(Main.java:116)
        ... more garbage below
boreal iron
#

Minecraft Crash Report

lyric mountain
#

Do you have a public constructor for that cmd?

boreal iron
wheat mesa
#

all of the constructors are public yes

lyric mountain
#

Try devving in a clean cmdline environment

#

See if the error persists

wheat mesa
#

Not entirely sure how to do that, I don't think that's the issue though

#

If it helps this is my annotation: ```java
public @interface Command {

}

#

Does it have to not be empty?

lyric mountain
#

Nono

#

Annotats go above

#

Not inside

wheat mesa
#

No I meant that's how I'm declaring my annotation

lyric mountain
#

Declare it bove

#

Ah wait

wheat mesa
#
@Command
public class HelpCommand extends CommandBase {
    public HelpCommand() {

    }
lyric mountain
#

I see what u mean

wheat mesa
#

That's how I'm using it

lyric mountain
#

Then how are u retrieving?

#

U could compare with my cmd handler

wheat mesa
#
    private final Reflections refl = new Reflections("dev.jwaffled.dragsimutils.Commands");
    private final Set<Class<?>> commands = refl.getTypesAnnotatedWith(Command.class);
lyric mountain
#

There I retrieve and build the command

wheat mesa
#

Doing it essentially the same way you're doing it

lyric mountain
#

Hm

#

Lemme think

earnest phoenix
#

Hey there, so how would I make it so like
/setupdates #channel
Get's saved to the quick.db db

Then when I run
/publish [update]
It finds each channel that was saved into the DB, and sends it to that channel?

lyric mountain
#

U forgor retention

wheat mesa
#

I didn't even know I had to do that lol

lyric mountain
#

Annots aren't present during runtime by default

wheat mesa
#

that probably explains it

#

Do I also have to have the @Target annotation?

lyric mountain
#

Target defines what will be annotated

wheat mesa
#

oh ok

lyric mountain
#

Type means only classes will be

#

It helps performance too since it'll be less guessing for the runtime

wheat mesa
#

Crashes once again with the same error

#

Even with retention

#

I really think it's something to do with this line commandList.add((CommandBase) (cmd.getConstructor().newInstance()));

wheat mesa
#

Actually wait

#

It's crashing before it even gets to that line

#

Since nothing logs

#

It's saying line 12 which is ```java
private final Reflections refl = new Reflections("dev.jwaffled.dragsimutils.Commands");

#

Wait maybe it's a circular dependency issue or something since I have the CommandLoader class in the same directory as the commands

#

I'll move it rq

#

Nope

#

damn it java why can't you be simple D:

lyric mountain
#

ok ok, let's go step by step

#

is the path right?

feral aspen
#

I have a ping command, and I want to add a button that reloads the ping, what should I be exactly calculating in that button?

earnest phoenix
#

Just re-put in the ping code tbh

wheat mesa
feral aspen
#

Uhh, that's not how it works? (ItsNoah)

earnest phoenix
#

one sec.

lyric mountain
#

let before = new Date().getTime()
do some api operation
let ping = new Date().getTime() - old

lyric mountain
#

probably not the issue, but it might cause some circular issues

earnest phoenix
#

Yeah*^*, since you are updating the embed, it sends a new description with the updated ping.

#

At least from what I know

wheat mesa
#

Alright, did that

feral aspen
lyric mountain
#

also, refrain from having titlecased folders

lyric mountain
wheat mesa
#

Yeah I'm used to naming conventions for C# and stuff so that's why it's title cased

lyric mountain
#

that time is the ping

wheat mesa
#

I'll change it in a little bit though

lyric mountain
#

are u using intellij?

wheat mesa
#

Yup

feral aspen
lyric mountain
#

record the time before

#

on update, do the calc

#

.setDescription('My ping is ${new Date().getTime() - old}ms')

feral aspen
#

old as in.. OHH I got you.

lyric mountain
#

the time before you update

lyric mountain
#

like, run the code directly

sudden geyser
#

This sounds like a lot of work for convenience.

lyric mountain
#

to check if it isn't some forge limitation

wheat mesa
#

welp this might be a forge limitation

lyric mountain
earnest phoenix
#

Worked lol @lyric mountain

#

Anywhoo

lyric mountain
earnest phoenix
#

KuuHaKu, can you help me rq?

lyric mountain
#

with?

earnest phoenix
#

Hey there, so how would I make it so like
/setupdates #channel
Get's saved to the quick.db db

Then when I run
/publish [update]
It finds each channel that was saved into the DB, and sends it to that channel?

#

That ๐Ÿคฃ

sudden geyser
wheat mesa
#

agh this looks sucky

lyric mountain
#

also easier maintenance, better data visualization and less ram usage (since you aren't instantiating a biggus list)

earnest phoenix
#

I'm pretty positive q.db supports array's so would I just add all the channels to a array?

sudden geyser
#

reflection is fun since you can write a lot of metaprogramming

wheat mesa
#

I'm mostly doing this because it's an interesting problem to solve

#

And it'll pay off when I don't have to write new TCommand() every time I want to add a new command

lyric mountain
#

my deck command

#

imagine that inside a constructor

#

yikes

sudden geyser
#

better data visualization
[citation needed]

and less ram usage (since you aren't instantiating a biggus list)
but you're still keeping it in memory. unless you're recomputing the commands list every time (worried)

lyric mountain
#

also I can filter by annots without even initializing the class

lyric mountain
#

instead of having dual reference

wheat mesa
#

Looking at the forge ReflectionHelper class I don't think I'm going to be able to do what I want to do

lyric mountain
#

lul

#

[citation needed]
my image above

#

you can have huge amount of data describing a class without going for static fields or having to construct the object to read

#

also annots allow optional fields (and default values), which is nice

sudden geyser
#

oh that kind of visualization

#

fair

lyric mountain
#

tbh default values was what made my eyes shine

#

damn that shit is useful

#

you received 500

#

not something you can fix on your side

#

unless the api is shitty and didn't properly check inputs

#

nice webhook url btw (delete that or get it spammed by someone)

simple stump
#

mb thx

lyric mountain
#

I meant the webhook actually, not the image

#

but anyway

#

check if you're passing all the required arguments

#

and that they're within expected types

earnest phoenix
#

So why does this not add to the array, rather than replacing it?

#
db.push(`bchannels`, [channel.id])
lyric mountain
#

never used quick.db

earnest phoenix
#

I've never used array's in quick.db before ๐Ÿคฃ

lyric mountain
#

usually in sql you'd not have arrays at all

oak cliff
#

iirc quick.db sucks with arrays

lyric mountain
#

they'd be either serialized data (like json arrays) or secondary tables

oak cliff
#

its been like 3 years since i used quick.db tho

earnest phoenix
oak cliff
#

try asking in their support server?

lyric mountain
oak cliff
#

youd find more people there that know then here i would think

lyric mountain
#

I imagine using raw sql would be easier and probably more optimized

#

quick db stores data in key-json pairs

#

which idk how it could be a good idea

wheat mesa
#

just got told in the forge discord "we're not going to support reflections for the purpose of being lazy"

#

๐Ÿ˜Ž

lyric mountain
#

I mean, they also have a shitton of boilerplate code and unoptimized shit

#

like reloading ALL resources (I mean ALL) during startup or when you change packs

#

guess why fabric exists?

#

I wish they did accept outside opinions and reworked their codebase, much of the old code still exist for absolutely no reason

earnest phoenix
wheat mesa
#

forge is pretty terrible

#

it's against their rules in their discord to ask questions about any versions before 1.16

earnest phoenix
#

I stopped using forge recently

wheat mesa
#

and they took down all their javadocs for 1.8.9 and stuff

#

no idea why

earnest phoenix
#

now i use fabric

lyric mountain
#

the only redeeming qualities of forge is the amount of mods and the cross-mod compatibility stuff

#

like FE and fluids

#

other than that, fabric would easily win against it

wheat mesa
#

they have a large userbase from when it became popular as one of the only modding tools out there

lyric mountain
#

ye

wheat mesa
#

that's the only reason it wins against fabric and other stuff

lyric mountain
#

the issue is that for most (including me) they are chained to forge due to their mod catalogue

quartz kindle
#

what kind of fabric does fabric use?

#

hopefully 100% cotton

earnest phoenix
#
let channels = db.fetch(`channels`)
let ch = client.channels.cache.get(channels)


ch.send({ content: `Testing` })```
#

The let channels are in a array.

quartz kindle
#

you cant do that

earnest phoenix
#

wym?

quartz kindle
#

get() only accepts an id

#

not an array of ids

earnest phoenix
#

what would I use for that?

#

fetch()?
find()?

quartz kindle
#

no

earnest phoenix
#

Lost ๐Ÿคฃ

#

.getID()? (jk)

quartz kindle
#

you have to loop over your array, and do something with each id

earnest phoenix
#

whaat

#

There are gonna be hundreds of id's

quartz kindle
#

thats what loops are for

earnest phoenix
#

How do I loop tho?

#

Never done that before o-o

quartz kindle
#

for(let item of array) { do something with item }

earnest phoenix
#

I don't think I can.

solemn latch
#

does it matter which?

#

channels[0]
will get the first id

quartz kindle
#

inside the loop, item is one of the ids

#

so you use item to get the channel

solemn latch
#

Oh, i misunderstood the question iara_rip_dead

earnest phoenix
#

confusion

quartz kindle
#

what dont you understand?

earnest phoenix
#

so like

#

idek

quartz kindle
#

if you had this array: let array = [1,2,3,4,5]

#

and you did this for(let item of array) { console.log(item) }

#

you would get in your logs: 1 2 3 4 5

earnest phoenix
#

So I litearlly put

quartz kindle
#

each item would be separately logged

earnest phoenix
#
{}```
quartz kindle
#

for(let <variable> of <array>)

#

or const

#

or var

#

doesnt matter

earnest phoenix
#

What do I put for the variable and array tho?

quartz kindle
#

<variable> is the name you want each item of the array to have

#

<array> is the array holding all your items

earnest phoenix
#

Whaaat

#

There is 1 Array!

#

In a db lol

#

Confusion man

quartz kindle
#

have you ever used .forEach()?

earnest phoenix
#

Nope

#

besides message.guild.channels.forEach()

quartz kindle
#

...

#

forEach is exactly the same thing

#

forEach(item => do something with item)

earnest phoenix
#

```for(channel => channel.send({ content:Testing }))

#

?

quartz kindle
#

.....

earnest phoenix
#

Do I define channel before for(channel) or what?

#

This is making literally no sense

quartz kindle
#

please read this

earnest phoenix
#

Ah

#

Okay.

#

That cleared things up

#
let channels = db.fetch(`channels`)
for (const element of channels) {
channels.send({ content:`Testing` })
}```
#

Correct?

cinder patio
#

nope

earnest phoenix
#

That's literally what the thing is telling me to do!!!

quartz kindle
#

no its not

#

first of all, the example in the link above is doing console.log(element) not console.log(array1)

earnest phoenix
#

mhm?

quartz kindle
#

you are doing the same as array1.send()

#

you cant send stuff to an array

earnest phoenix
#

So I need to send the stuff to the array smart

quartz kindle
#

no

#

...

earnest phoenix
#

lmfao, so confused.

quartz kindle
#

look at the example

earnest phoenix
#

I dfid

quartz kindle
#
const array1 = ['a', 'b', 'c'];

for (const element of array1) {
  console.log(element);
}

// expected output: "a"
// expected output: "b"
// expected output: "c"
earnest phoenix
#

mhm

#

mhm

quartz kindle
#

you see console.log(element)?

cinder patio
#

dude seriously

quartz kindle
#

why do you think that is?

earnest phoenix
#

Ohhh

#

It's doing the individual elemant taken from the array1

quartz kindle
#

exactly

earnest phoenix
#

Tim, god bless you you just made that make so much sense ๐Ÿคฃ

cinder patio
#

bruh

earnest phoenix
#

let channels = db.fetch(`channels`) for (const element of channels) { element.send({ content:`Testing` }) }

#

Element

#

Woooo

quartz kindle
#

yes

#

now

#

that probably still wont work

earnest phoenix
#

Oh jeez

quartz kindle
#

because your code is assuming that each element is a discord.js Channel object

#

which probably isnt

#

so first console.log(channels) to check what they actually contain

#

(before the for line)

earnest phoenix
quartz kindle
#

alright, so its an array of ids

earnest phoenix
#

2 of em hmm think_bold

quartz kindle
#

so first, you need to use the id to get a discord.js Channel object

#

you already know how to do that

earnest phoenix
#

So uh

#

Okay yeah

quartz kindle
#

hint: ...get()

earnest phoenix
#

foncusion

#

Oh nvm

#

Okay, you explain it out step by step, and I will write what I think makes sense, then you can tell me if I followed along or not.

#

```let channels = db.fetch(channels)
for (const element of channels) {
let ch2 = client.channels.cache.get(element)

}```

#

Sum like that?

quartz kindle
#

yup

earnest phoenix
#

Wooo!

#

So then that moved it to a seperate channel ID of its own

#

So then I can run ch2.send

#

Right?

quartz kindle
#

yes

#

you probably also want to await it

earnest phoenix
#

Tim, your a god!

#

Ty.

cinder patio
#

Hey tim how would I get the content between two characters using indexOf thoonk considering they could be nested, for example:

{}
}

I can't think of a way to do it without looping through every character

earnest phoenix
#

May have taken me a second to understand, thanks for being patient with me tho lol

quartz kindle
#

or you can use regex to search for one of opening or closing

#

there is a way to use regex with indexes

#

so you can properly navigate through substrings

cinder patio
#

Actually I think looping here wouldn't be bad because I'm going to loop only through a part of the string

#

from the start of the character to the end

#

While using regex I'd have to test against the entire string or create a copy

earnest phoenix
#

Okay now what did I do

deferUpdate?

let channels = db.fetch(`channels`)
for (const element of channels) {
let ch2 = client.channels.cache.get(element)
await interaction.reply({content: `Bump Sent to all Receiving Channels.`})


await ch2.send({ content: `Testing` })
}```
quartz kindle
#

thats essentially the regex way of defining a starting index like indexOf supports

quartz kindle
#

so if you have two channel ids, you send 2 messages, and you reply to the same interaction twice

#

so dont reply to the interaction in there

#

do it outside of the loop

cinder patio
#

I see

proven lantern
#

should i fix my rate limiting?

#

it's going to be hard to do

#

this wont work when it scales to multiple lambdas

quartz kindle
#

you will need to track it in your db

proven lantern
#

which one do i need in the CAP theory?

#

consistency right?

#

i want to make sure two people cant join in the same slot

#

the db needs locks

#

i think

quartz kindle
#

yes, consistency first, then if you have a central db availability would be second

#

is the db partitioned/horizontally scaled?

proven lantern
#

it'll be central db.
yeah horizontally scaled. they are all smol lambdas

#

hopefully dynamodb is consistent

quartz kindle
#

but if the db itself is central and automatically scaled, then it should take care of consistency by itself

proven lantern
#

idk what aws does

#

i need to do some research

quartz kindle
#

Amazon DynamoDB lets you specify the desired consistency characteristics for each read request within an application. You can specify whether a read is eventually consistent or strongly consistent.

proven lantern
#

damn fine

#

what a great db

quartz kindle
#

A strongly consistent read in Amazon DynamoDB returns a result that reflects all writes that received a successful response prior to the read. To get a strongly consistent read result, you can specify optional parameters in a request. It takes more resources to process a strongly consistent read than an eventually consistent read. For more information about read consistency, see Data Read and Consistency Considerations.

proven lantern
#

noice

quartz kindle
#

Apache HBase reads and writes are strongly consistent. This means that all reads and writes to a single row in Apache HBase are atomic. Each concurrent reader and writer can make safe assumptions about the state of a row. Multi-versioning and time stamping in Apache HBase contribute to its strongly consistent model.

#

DynamoDB uses eventually consistent reads, unless you specify otherwise. Read operations (such as GetItem, Query, and Scan) provide a ConsistentRead parameter. If you set this parameter to true, DynamoDB uses strongly consistent reads during the operation.

#

A strongly consistent read might not be available if there is a network delay or outage. In this case, DynamoDB may return a server error (HTTP 500).
Strongly consistent reads may have higher latency than eventually consistent reads.
Strongly consistent reads are not supported on global secondary indexes.
Strongly consistent reads use more throughput capacity than eventually consistent reads. For details, see Read/Write Capacity Mode

proven lantern
#

im too lazy to setup Apache HBase

#

Strongly consistent reads are not supported on global secondary indexes

#

oof

#

right in the gut

quartz kindle
#

basically, just add ConsistentRead:true to your requests, and you're fine

proven lantern
#

actually that will work

#

i dont need my queries to be consistent, just my get calls

#

noice

earnest phoenix
#

How can I delete a global command again?

sudden geyser
earnest phoenix
#

How do I get the command ID?

quartz kindle
#

you can fetch all commands, then search for it by name

earnest phoenix
#

If only it was that simple whyGod

sudden geyser
#

it is pretty simple

neat ingot
#

how come my bot can respond with slash commands in channels it cant even see ?

sudden geyser
#

especially if you set the global commands on startup

#

since discord will return all the commands on that APi call

#

so you could store it in some value

quartz kindle
earnest phoenix
#
let commands222 = client.api.applications(client.user.id).commands.get()

console.log(commands222)```?
solemn latch
#

slash commands dont even need a bot in the server

neat ingot
#

it also doesnt seem to need a permission?

earnest phoenix
#

Just says Promise : <pending>

neat ingot
#

wait what?

#

lol

lyric mountain
solemn latch
quartz kindle
#

also you dont need that

#

you can use client.application.commands.fetch()

neat ingot
#

so then how do i actually restrict my bot to only reply in channels its actually allowed to? lol

lyric mountain
solemn latch
#

yeah

#

works no problem

lyric mountain
#

you can exec cmds without the bot?

#

tf

#

that's cursed beyond salvation

neat ingot
#

^

quartz kindle
#

you can invite the bot with the application scope

#

without the bot scope

solemn latch
#

got a bot with slash commands?
just invite without bot scope

#

ye

neat ingot
#

hax

lyric mountain
#

botghost got a new meaning

quartz kindle
#

and reject it

neat ingot
#

yea im just gonna check bot permissions in the channel and then do nothing if not enabled

#

thats crazy though, im gonna have to try that out ๐Ÿ˜„

earnest phoenix
neat ingot
#

do the await in the console.log

quartz kindle
#

not the console.log

neat ingot
#
console.log(await client.application.commands.fetch())
earnest phoenix
#

Just added that^ ty

#

Will try it now

neat ingot
#

is discord gonna change the bot being able to reply to commands without being in the server thing?

solemn latch
#

no

neat ingot
#

feels like that could reduce ram a huge amount for the bot if it doesnt actually have to be in 500+ servers ๐Ÿ˜„

solemn latch
#

thats intentional

neat ingot
#

interesting

solemn latch
#

imo, there's a future which its standard.

quartz kindle
#

finally people start getting it

solemn latch
#

it looks way cleaner, no more worrying about the fact you have 6 bots to get all the features you need

quartz kindle
#

about time people start realizing they dont need the websocket at all

neat ingot
#

yea the slash commands is a huge step in the right direction to standardizing bots a bit more imo

lyric mountain
#

although you'd sacrifice any and every feature that require seeing the server

#

like xp

neat ingot
#

^untrue

lyric mountain
#

howso?

neat ingot
#

trigger your exp gain upon interaction

lyric mountain
#

cursed

neat ingot
#

lol

wheat mesa
#

kuuhaku do you know a good way to register subcommands in forge, or should I just do one massive switch case for all my commands

#

and pass off their args and such to different functions

solemn latch
#

still can have one xp bot I guess

lyric mountain
#

what do you mean by "subcommands"?

wheat mesa
#

like using /dsu subcommand args

lyric mountain
#

doesn't minecraft already support that out of the box?

sudden geyser
#

Personally I'm worried that as soon as a bot need some data that's only available to websockets, they'll need to inherit all the stuff they worked towards avoiding

wheat mesa
#

Do they?

lyric mountain
#

like /time set day

wheat mesa
#

Yeah but I don't know how to do that with my custom commands

#

Forge docs have been scraped off the internet I swear

quartz kindle
lyric mountain
#

I guess they are like discord slashes

sudden geyser
#

yeah but requirements change

quartz kindle
#

so you can decide correctly whether to go for websocket or not

lyric mountain
#

most commands have type checking

sudden geyser
#

I only want this small sliver

#

not the entire cake pls

#

yay intents

#

now more

quartz kindle
#

ยฏ_(ใƒ„)_/ยฏ

#

im prepared to give up on websockets altogether

lyric mountain
#

I'm once again asking for multiple slash signatures

quartz kindle
#

im fine with giving up on stuff like server count

neat ingot
#

tim am i right in recalling you had some lightweight discord js library going on a year or two ago?

quartz kindle
#

yeah

neat ingot
#

still going?

sudden geyser
quartz kindle
#

yeah, discord.js-light is up to date with discord.js v13

neat ingot
#

๐Ÿ˜ฎ

#

i tried that! ๐Ÿ˜„

quartz kindle
#

but there wont be a version for v14

neat ingot
#

๐Ÿ˜ฎ how come?

quartz kindle
#

im moving out of discord.js

neat ingot
#

sadness, what you moving to?

lyric mountain
quartz kindle
#

my own lib

#

tiny-discord

lyric mountain
#

what do you mean exactly?

neat ingot
#

oohh, fair enough then ๐Ÿ˜„

#

js still i guess?

quartz kindle
#

ye

#

im not moving out of js anytime soon

lyric mountain
#

make timscript

neat ingot
#

any idea when v14 will be a thing?

quartz kindle
solemn latch
#

timscript sounds great

quartz kindle
#

probably still a long way ahead

lyric mountain
#

I mean, there's already toml

#

Tim's Obvious Markup Language

neat ingot
#

please tell me thats an actual thing, and if so, i need a link ๐Ÿ˜„

lyric mountain
#

toml is, the meaning could be slightly off

quartz kindle
#

lmao

neat ingot
#

๐Ÿ˜„

earnest phoenix
#

So what from there am I deleting?

#

the commandId right?

quartz kindle
#

show code

earnest phoenix
#

The one amazing line of code:

#

I swear, if you say its wrong mad

client.api.application.commands.delete('842493762621538364')
#

When I removed api it worked

quartz kindle
#

๐Ÿ‘

earnest phoenix
#

No it didn't.

#

whyGod nothing ever works for me

spark flint
#

mood

earnest phoenix
#

my coding language: computer delete command 'id here'

neat ingot
#

and that doesnt work? ๐Ÿ˜„

earnest phoenix
#

** S I M P L E - W O R D S**

quartz kindle
#

you said it worked once?

earnest phoenix
quartz kindle
#

well it should work only once, since now its deleted

neat ingot
#

you can just remove the bot from the server to remove its commands i think?

earnest phoenix
#

or does it do that hour thing?

earnest phoenix
#

Global commands load instantly when you add it.