#development

1 messages · Page 156 of 1

crystal wigeon
#

When i use a string literal with an escaped character in knex.raw query build its throwing a syntax error for bindings, like its not accepting some bindings weirdly

#

it looks like its an issue, even on their github

#

anyone know any word around?

#

same

lyric mountain
crystal wigeon
#

Anyway I’ve fixed it actually.

covert ingot
#

hello, im back to programming after like a year

#

and im struggling to send an object to my frontend in ejs

#

this is my dir so far

#

need to send object through express from index.js to base.ejs

#

cant use res.render('base'...) cuz it will probably error and if it doesnt its still not practical to put that in every get

#

@ me if i dont reply straight away

solemn latch
#

I don't quite understand the question.

You just want to do a api request?

covert ingot
#

no

#

I have object i want to send to front end

#

and the usual way is res.render('..', { object here })

#

but, the thing is base.ejs is a partial, shouldve clarified that. so basically in home.ejs and other website.com/....(forgot the word) i just do <%- include('./base.ejs') %>

quartz kindle
#

you have to put it in the render function one way or another

#

since base is included, you put it in the render of the file that includes base

covert ingot
#

surely thats not right ? in every router ill have to put that

#

there has to b a middleware or something

#

it does exist i just forgot

#

maybe not a middleware but there is something

quartz kindle
#

probably yeah, look for it in the ejs docs

covert ingot
#

yh cant find it

quartz kindle
#

inside app.use

covert ingot
#

thank u a lot

quartz kindle
earnest phoenix
#

Hi, I have a command that does set a channel for logs. When I do /set channel and choose the channel it does work and it is being put on the database ( mongodb ) but if I want to change channel I can’t because it’s already registered in the database. It’s there any way to like overwrite the new channel on the database?

quartz kindle
#

how did you save it as? like what is the structure/model/schema like?

earnest phoenix
quartz kindle
#

it should be working, youre doing the correct command

#

the thing is your if

#

youre only updating if the guild id is not found in the database

#

because of the if(!result)

#

so you need to change that

earnest phoenix
#

What should I change that into?

quartz kindle
# earnest phoenix What should I change that into?

you should be able to figure it out, like when do you want to allow the update to work? if you just remove that if it will always update. if you dont want to always update but only under certain conditions, then you need to put what those conditions are in the if

wooden ember
#
const bot = new Discord.Client({ autoReconnect:true, intents: [ Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MESSAGES, Discord.Intents.FLAGS.GUILD_VOICE_STATES ]});
``` put my bot on another server that just had a new os installd and now nothing works because js updated a milion versions and now the code above no longer works. aparenly d.js "doesn't suport flags" anymore from what i have looked at. What is the new way of writing the code above so that it works again?
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wooden ember
#

idk what ever one installed when i ran npm install discord.js

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wooden ember
#

uuuuh originally v12 but I updated it to work with v13

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wooden ember
#

I forgot you could do that to be honist

#

but also thats just gonna mean the code gets even more outdated and will be harder to fix next time

#

cuz if it wasnt for that I would still be using v12

#

also bruh windows screwed my clock up again

sage bobcat
#

One message removed from a suspended account.

wooden ember
sage bobcat
#

One message removed from a suspended account.

wooden ember
#

is that stable or just dev

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wooden ember
#

ah are they back to using odd numbers as dev and even numbers as stable or is that out the window entirly now

sage bobcat
#

One message removed from a suspended account.

wooden ember
#

bruh

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wooden ember
#

I envy you

#

i mean don't get me wrong i like hosting bots and making them but god is it tedious when i have to run to stand still

#

I wish I wrote my bots in c# or something

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

wooden ember
#

yeah

#

fun

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

wooden ember
#

i mean i wrote my bots during covid when I had alot of time but now Im not in collage anymore real life takes presidence

sage bobcat
#

One message removed from a suspended account.

wooden ember
#

I just tinker with these things and thats about it these days

#

fair enough though i though that was just js but with different formatting or something

#

anyway thinking of real life I need to sleep cuz I didnt realise my clock was an hour behind

solemn latch
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

solemn latch
#

c#

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

solemn latch
#

good to know

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

radiant kraken
sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

radiant kraken
#

but i dont find any good use cases for it besides unity

sage bobcat
#

One message removed from a suspended account.

radiant kraken
#

what do you use C# for?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

solemn latch
#

Id like to spend some time playing around with the basics of a few languages, I've been using JS and TS for so long now

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

radiant kraken
#

learning C#'s basics was a bit time consuming for me but it was a lot of fun

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

radiant kraken
#

is it compiled or interpreted?

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

radiant kraken
#

alright

sage bobcat
#

One message removed from a suspended account.

radiant kraken
#

good enough poggythumbsup

#

i already know the basics of C# thanks

#

but i haven't tried the newer versions

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

radiant kraken
#

i believe i was using C# 4 or 5 when i started learning 2.5 years ago onesieKEKW

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

#

One message removed from a suspended account.

lyric mountain
sharp geyser
slender wagon
#

What linux OS would u guys suggest for a discord bot

#

Or for hosting anything lol

wheat mesa
#

pretty much any distro is probably fine as long as you're not using the graphical version of it

slender wagon
#

Any in particular?

marsh lark
#

Most popular I'd say is ubuntu

slender wagon
#

How about rocky linux

marsh lark
#

If you want to use it

sharp geyser
#

Why not just stick with debian/ubuntu

civic scroll
#

debian is goofy

#

(idk linux)

radiant kraken
#

windows is a good distro

peak drum
green kestrel
#

just found this gem of really bad advice on stack overflow for how to grow your open source project... needless to say this is bad, "build it and they will come" is bs and has never worked. you gotta PUT YOURSELF OUT THERE!

radiant kraken
#

most of the time its a gamble for me

hasty falcon
#

hi, sorry if i wrong channel, i want ask, how to get the server count?
do bots have to be verified?

deft wolf
#

No, you need to make a request to top.gg api

#

With server count/shards count

marsh lark
eternal osprey
#
main file:
 let builder = new Builder(interaction);```

builder.js file:
```js
class Builder {
  #interaction;
  #ranking = {
    Bronze: ":Bronze:",
    Silver: ":Silver:",
    Gold: ":Gold:",
    Diamond: ":Diamond:",
    Platinum: ":Platinum:",
    Ace: ":Ace:",
    Grandmaster: ":Grandmaster:",
    Legend: ":Legend:",
  };
  constructor(interaction) {
    this.#interaction = interaction;
    console.log("builder has been created");
  }
#

let me guess i should use export class? Currently giving error: builder not defined, yet it's shown in the vsc suggestion menu...

#

i thought that it had the same way of creating a class as in java

#

So if i understand it correctly, first export the class, import it in the main and then instiantate a new class.

desert verge
#

I need help!
I don't know why it does that
It is super strange why it doesn't switch

 async function startFight(chara, aimedChara) {
      // let action_chara = new ActionAPI(chara._id, interaction.guildId);
      // let action_aimedChara = new ActionAPI(
      //   aimedChara._id,
      //   interaction.guildId
      // );

      // let chara_speed = (await action_chara.getStat("speed")) || 0;
      // let aimedChara_speed = (await action_aimedChara.getStat("speed")) || 0;

      async function repeatCallback() {
        if (!tour) {
          await damage(aimedChara, chara, repeatCallback);
          tour = 1;
          return;
        }

        await damage(chara, aimedChara, repeatCallback);
        tour = 0;
      }

      interaction.deleteReply();

      async function damage(attacker, receiver, repeatCallback) {
        let actionApi_attacker = new ActionAPI(
          attacker._id,
          interaction.guildId
        );
        let actionApi_receiver = new ActionAPI(
          receiver._id,
          interaction.guildId
        );

        let damage = await actionApi_attacker.getStat("damage");
        let receiver_health = await actionApi_receiver.getStat("health");
        let receiver_resistance =
          (await actionApi_receiver.getStat("resistance")) || 0;

        if (!damage || !receiver_health)
          return interaction.editReply(
            ":x: Couldn't fight: No damage and health stats defined."
          );

        let crit_chance =
          (await actionApi_attacker.getStat("crit_chance")) || 0;
        let crit_perc = (await actionApi_attacker.getStat("crit_perc")) || 0;

        let crit_value = 0;

        if (crit_chance && crit_perc) {
          if (Math.random() < crit_chance / 100) {
            crit_value = (1 + crit_perc / 100) * damage;
          }
        }

        let resist_val =
          (crit_value ? crit_value : damage) - receiver_resistance;
        resist_val = resist_val < 0 ? 0 : resist_val;

        let final_health = receiver_health - resist_val;
        final_health = final_health < 0 ? 0 : final_health;

        await actionApi_receiver.setStat("health", final_health);
        interaction.channel.send(
          `**${attacker.name}** attacks **${receiver.name}** ${
            crit_value ? `(EFFECTIVE!)` : ""
          }, they loose :heart: ${resist_val} Health (Current health: ${final_health})`
        );

        if (final_health === 0) {
          let max_health_receiver = await actionApi_receiver.getStat(
            "max_health"
          );

          let max_health_attacker = await actionApi_attacker.getStat(
            "max_health"
          );

          await actionApi_receiver.setStat("health", max_health_receiver);
          await actionApi_attacker.setStat("health", max_health_attacker);

          return interaction.channel.send(
            `**${receiver.name}** has been defeated!`
          );
        }

        await repeatCallback();
      }

      await damage(aimedChara, chara, repeatCallback);
    }
#

the tour variabe is outside the startFight function, and inside it doesn't work too

#

Alright I found a fix, now, tour switches 1 to 0, 0 to 1 in the damage function

tulip ledge
desert verge
#

1 is faster to write and 0 too

desert verge
#

Okay it's a round or turn

tulip ledge
#

Ah so it switches turns basically?

desert verge
#

yup

tulip ledge
#

then why don't you make it recursive?

#

so in your damage function you do like:

function damage(dealer, receiver, ...) {
  ...
  // Deal damage
  if (receiver.health <= 0) {
    // Do stuff when receiver died
  } else damage(receiver, dealer, ...);
}
desert verge
desert verge
#

I didn't know how to switch parameters

#

Thank you

tulip ledge
#

no problem

#

but it works now?

desert verge
#

Yup, I'll optimize my code with what you proposed later

#

I'm doing the dashbord

tulip ledge
#

cool

#

good luck

#

also if you're optimizing

desert verge
#

But I just don't know how to put stats on the center of the right box

tulip ledge
#

calculate the stats before the damage function because now you're calling the api like 20 times

#

when you only need to do so 2 times

tulip ledge
#

and add it to the receiver and dealer objects

#

ah alright

desert verge
#

I just get damage, resistance, health first, then calculate, then just change the health stat

tulip ledge
#

yes ok but

#

in your damage function you sset the health every time

desert verge
#

Yes because it changes

tulip ledge
#

why not save it to the dealer and receiver object and then only save it after someone dies

#

this way if the bot crashes, the user's don't lose health

desert verge
#

Aahh

tulip ledge
#

and you save yourself api traffic

desert verge
#

Alright I see

tulip ledge
#

I mean it's fine how you're doing it

desert verge
#

So i just create a local variable ?

tulip ledge
#

or save it to the objects of the dealer and receiver

#

like dealer.currentHealth or something

desert verge
#

No because dealer and receiver are instance of class using the db

tulip ledge
#

mmmh well yeah you could make local variables

desert verge
#
class ActionAPI {
  constructor(chara_id, guild_id) {
    this.chara_id = chara_id;
    this.guild_id = guild_id;
  }

  static async leave(chara_id) {
    charaStats.deleteOne({ chara: chara_id });
  }

  async updateStats() {
    let charaapi = new CharactersAPI(null, this.guild_id);
    let chara = await charaapi.getChara(this.chara_id);
    let level = await charaapi.getLevel(this.chara_id);
    let guildapi = new GuildAPI(this.guild_id);
    let actionapi = new ActionAPI(this.chara_id, this.guild_id);

    let stats = await guildapi.allStats();

    for (let stat of stats) {
      let doTheThing = async (starter_value) => {
        if (!(await actionapi.getStat(stat.type)))
          return this.giveStat(
            stat.type,
            starter_value + level * stat.multiplier
          );

        await this.setStat(
          stat.type,
          Math.ceil(starter_value + level * stat.multiplier)
        );
      };

      let statsSpecies = stat.species;

      if (!(stat.type === "health")) {
        if (!statsSpecies) return doTheThing(stat.starter_value);
        let statSpecies = statsSpecies.find((s) => s._id.equals(chara.species));
        if (!statSpecies) return doTheThing(stat.starter_value);
        doTheThing(statSpecies.starter_value);
      }
    }
  }

  async getBonusStat(type) {
    let resultAll = await this.getAll();
    let result = resultAll.find((r) => r.type === type);

    return result ? result.bonus_value : undefined;
  }

  async setBonusStat(type, bonus_value) {
    if (await this.getStat(type))
      return charaStats.updateOne(
        { type, guild: this.guild_id, chara: this.chara_id },
        { $set: { bonus_value } }
      );
  }

  async getStat(type) {
    let result = await charaStats.findOne({ type, chara: this.chara_id });
    return result ? result.value : undefined;
  }

  async giveStat(type, value) {
    return await charaStats.insertOne({ type, value, chara: this.chara_id });
  }

  async setStat(type, value) {
    return await charaStats.updateOne(
      { type, chara: this.chara_id },
      { $set: { value } }
    );
  }

  async getAll() {
    return await charaStats
      .find({
        chara: this.chara_id,
      })
      .toArray();
  }
}
tulip ledge
#

but when switching between receiver and dealer it might be hard

desert verge
#

it's using mongodb

#

charaStats is a mongodb collection

desert verge
#

just chara1 and chara2 variables

tulip ledge
#

yea you could do it like that

#

how I do it in my rpg bot is I call my db and then create a class like so:

let profileData = await db.get(...);
let profile = new profile(profileData);

class profile {
  constructor(data) {
    this.health = data.health
    ...
  }
}
#

Well it's a bit more complicated

#

but you get the gist

#

this way I have class representations of the players

#

and can change them like this

#

then you can add a .save method to save the profile

#

but it's a suggestion right

#

because how you are doing it is also fine

#

it'll just introduce the need of extra local variables

desert verge
#

recursiveness doesn't work

tulip ledge
#

how are you implementing it?

eternal osprey
#

what does the _ after a variable name mean?

tulip ledge
tulip ledge
eternal osprey
#

i've seen it used in many programs

tulip ledge
#

I thought it was a completely different question

#

mb

eternal osprey
#

like variable_ = ...

desert verge
#

instead of do like: db.findOne({_id: id}), I'm just doing db.findOne({_id})

#
async function damage(attacker, receiver, repeatCallback) {
        let actionApi_attacker = new ActionAPI(
          attacker._id,
          interaction.guildId
        );
        let actionApi_receiver = new ActionAPI(
          receiver._id,
          interaction.guildId
        );

        let damage = await actionApi_attacker.getStat("damage");
        let receiver_health = await actionApi_receiver.getStat("health");
        let receiver_resistance =
          (await actionApi_receiver.getStat("resistance")) || 0;

        if (!damage || !receiver_health)
          return interaction.editReply(
            ":x: Couldn't fight: No damage and health stats defined."
          );

        let crit_chance =
          (await actionApi_attacker.getStat("crit_chance")) || 0;
        let crit_perc = (await actionApi_attacker.getStat("crit_perc")) || 0;

        let crit_value = 0;

        if (crit_chance && crit_perc) {
          if (Math.random() < crit_chance / 100) {
            crit_value = (1 + crit_perc / 100) * damage;
          }
        }

        let resist_val =
          (crit_value ? crit_value : damage) - receiver_resistance;
        resist_val = resist_val < 0 ? 0 : resist_val;

        let final_health = receiver_health - resist_val;
        final_health = final_health < 0 ? 0 : final_health;

        await actionApi_receiver.setStat("health", final_health);
        interaction.channel.send(
          `**${attacker.name}** attacks **${receiver.name}** ${
            crit_value ? `(EFFECTIVE!)` : ""
          }, they loose :heart: ${resist_val} Health (Current health: ${final_health})`
        );

        if (final_health === 0) {
          let max_health_receiver = await actionApi_receiver.getStat(
            "max_health"
          );

          let max_health_attacker = await actionApi_attacker.getStat(
            "max_health"
          );

          await actionApi_receiver.setStat("health", max_health_receiver);
          await actionApi_attacker.setStat("health", max_health_attacker);

          return interaction.channel.send(
            `**${receiver.name}** has been defeated!`
          );
        }

        if (!tour) {
          tour = 1;
          await damage(receiver, attacker);
        } else {
          tour = 0;
          await damage(attacker, receiver);
        }
      }
    }```
tulip ledge
#

what is repeat callback?

eternal osprey
#

Using an underscore (_) in front of variable names is a convention often used in programming languages to indicate that a variable should be considered private or internal to a class, module, or function. It's not a strict rule enforced by the language itself, but rather a convention that developers follow to signal the intended visibility and usage of a variable.

tulip ledge
#

Also you don't need to use the tour anymore

desert verge
tulip ledge
#

just add an else statement to if the user died

#

and swap the attacker and receiver

desert verge
desert verge
#
if (final_health === 0) {
          let max_health_receiver = await actionApi_receiver.getStat(
            "max_health"
          );

          let max_health_attacker = await actionApi_attacker.getStat(
            "max_health"
          );

          await actionApi_receiver.setStat("health", max_health_receiver);
          await actionApi_attacker.setStat("health", max_health_attacker);

          return interaction.channel.send(
            `**${receiver.name}** has been defeated!`
          );
        }


      damage(aimedChara, chara);
#

I'm using clause guard

tulip ledge
#

yeah ok

#

but doesn't it work?

desert verge
#

I'll try it

#

But I think damage function inside the damage function will be undefined

tulip ledge
#

It wont be

eternal osprey
#

It won't. It's inside its own scope.

hasty falcon
hasty falcon
marsh lark
#

np

desert verge
#

But intellisense tells it's undefined

eternal osprey
#

show code of what you've done rn cuz it shouldn't be.

desert verge
#

Wait

#

I know why it was undefined the damage func inside the damage function

#

I had a variable called damage

desert verge
#

@tulip ledge Actually, the idea I proposed for the health update is not valid

#
async function startFight(chara, aimedChara) {
      let action_chara = new ActionAPI(chara._id, interaction.guildId);
      let action_aimedChara = new ActionAPI(
        aimedChara._id,
        interaction.guildId
      );

      let attacker_damage = await action_aimedChara.getStat("damage");
      let receiver_resistance = (await action_chara.getStat("resistance")) || 0;

      let crit_chance = (await action_aimedChara.getStat("crit_chance")) || 0;
      let crit_perc = (await action_aimedChara.getStat("crit_perc")) || 0;

      // let chara_speed = (await action_chara.getStat("speed")) || 0;
      // let aimedChara_speed = (await action_aimedChara.getStat("speed")) || 0;

      interaction.deleteReply();

      async function damage(attacker, receiver) {
        let action_receiver = new ActionAPI(receiver._id, interaction.guildId);
        let receiver_health = await action_receiver.getStat("health");

        if (!attacker_damage || !receiver_health)
          return interaction.editReply(
            ":x: Couldn't fight: No damage and health stats defined."
          );

        let crit_value = 0;

        if (crit_chance && crit_perc) {
          if (Math.random() < crit_chance / 100) {
            crit_value = (1 + crit_perc / 100) * damage;
          }
        }

        let resist_val =
          (crit_value ? crit_value : attacker_damage) - receiver_resistance;
        resist_val = resist_val < 0 ? 0 : resist_val;

        let final_health = receiver_health - resist_val;
        final_health = final_health < 0 ? 0 : final_health;

        await actionApi_receiver.setStat("health", final_health);

        interaction.channel.send(
          `**${attacker.name}** attacks **${receiver.name}** ${
            crit_value ? `(EFFECTIVE!)` : ""
          }, they loose :heart: ${resist_val} Health (Current health: ${final_health})`
        );

        if (final_health === 0) {
          let max_health_receiver = await actionApi_receiver.getStat(
            "max_health"
          );

          let max_health_attacker = await actionApi_attacker.getStat(
            "max_health"
          );

          await actionApi_receiver.setStat("health", max_health_receiver);
          await actionApi_attacker.setStat("health", max_health_attacker);

          return interaction.channel.send(
            `**${receiver.name}** has been defeated!`
          );
        }
      }

      damage(aimedChara, chara);
    }
#

Bruh it's not correct

#
async function startFight(chara, aimedChara) {
      // let chara_speed = (await action_chara.getStat("speed")) || 0;
      // let aimedChara_speed = (await action_aimedChara.getStat("speed")) || 0;

      interaction.deleteReply();

      async function damage(attacker, receiver) {
        let action_receiver = new ActionAPI(receiver._id, interaction.guildId);
        let action_attacker = new ActionAPI(attacker._id, interaction.guildId);

        let receiver_health = await action_receiver.getStat("health");
        let receiver_resistance =
          (await action_receiver.getStat("resistance")) || 0;

        let attacker_damage = await action_attacker.getStat("damage");

        let crit_chance = (await action_attacker.getStat("crit_chance")) || 0;
        let crit_perc = (await action_attacker.getStat("crit_perc")) || 0;

        if (!attacker_damage || !receiver_health)
          return interaction.editReply(
            ":x: Couldn't fight: No damage and health stats defined."
          );

        let crit_value = 0;

        if (crit_chance && crit_perc) {
          if (Math.random() < crit_chance / 100) {
            crit_value = (1 + crit_perc / 100) * damage;
          }
        }

        let resist_val =
          (crit_value ? crit_value : attacker_damage) - receiver_resistance;
        resist_val = resist_val < 0 ? 0 : resist_val;

        let final_health = receiver_health - resist_val;
        final_health = final_health < 0 ? 0 : final_health;

        await action_receiver.setStat("health", final_health);

        interaction.channel.send(
          `**${attacker.name}** attacks **${receiver.name}** ${
            crit_value ? `(EFFECTIVE!)` : ""
          }, they loose :heart: ${resist_val} Health (Current health: ${final_health})`
        );

        if (final_health === 0) {
          let max_health_receiver = await action_receiver.getStat("max_health");

          let max_health_attacker = await action_attacker.getStat("max_health");

          await action_receiver.setStat("health", max_health_receiver);
          await action_attacker.setStat("health", max_health_attacker);

          return interaction.channel.send(
            `**${receiver.name}** has been defeated!`
          );
        }
      }

      damage(aimedChara, chara);
    }
#

@eternal osprey

eternal osprey
#

heey

#

what's not correct

eternal osprey
#

yeah but about what are you talking?

#

The resursive function?

desert verge
eternal osprey
#

Also, in js it's not really common to use variable_name but camelCase: variableName.

desert verge
#

I use both

#

camelCase more of course

frosty gale
#

well in c you tend to use snake case

#

hence i use it in js too

#

(sometimes)

desert verge
eternal osprey
#

ms

eternal osprey
peak drum
#

If it ain’t broke, don’t fix it xD

desert verge
#

oke

eternal osprey
peak drum
frosty gale
#

promotes resistance to change and advancement

eternal osprey
#

Okay ms mindset.

peak drum
peak drum
eternal osprey
#

in js we only have classes, hence only support extends right?

#

no interfaces nor implements?

neon leaf
#

that only exists in typescript

#

so yes

eternal osprey
#

is typescript hard to learn?

tulip ledge
#

So if the parameters switch so should these variables

tulip ledge
desert verge
eternal osprey
#

but when you call a new damage, it's undefined the 2nd time as you do not call the startFight again.

#

Try passing these parameters explicitly to the damage and try again. That should work.

tulip ledge
#

He calls it in the damage function

#

So they are defined

eternal osprey
#

Personally i don't think it has access to the parameters in the outer function but i could be wrong... trying can never hurt right.

tulip ledge
#

Yeah

frosty gale
#

typescript is literally so cursed

#

you worry more about types than actual programming

#

because its a messy layer over javascript

#

i think so anyways after using it

#

you still have to use the any type in a lot of instances

#

bc some js features that make things easier or faster arent very strictly typed

#

also annoying to get a project up and running since you have to fiddle with a tsconfig which beginners likely would struggle with

tulip ledge
frosty gale
#

what are you saying 😠

marsh lark
#

I never use any in ts

desert verge
#

replace the any type by that

lyric mountain
#

But I do agree ts has a weird syntax

frosty gale
#

since everything has to be typed anyways

#

well c++ is questionable in that regard considering their weird std types but in general

#

i dont use like 99% of the modern c++ functions and features

#

i would use c if it wasnt for the lack of classes and some helpful algorithms

frosty gale
solemn latch
#

Isn't unknown supposed to be used, not any?

#

I mean, both can be used.
But in most cases any is used unknown is typically 'more' correct. Right?

grizzled raven
#

ik it's been forever but i wanna look into this host

#

how like lengthy is the verification process

neon leaf
#

wdym verification

deft wolf
#

I might be interested in this hosting too pogey

#

Nooooo angeryBOYE

neon leaf
#

just use the sale servers

#

smh

spark flint
#

wtf

#

where

#

i can't see

neon leaf
#

top of the page

#

the fat banner

spark flint
#

oh

deft wolf
#

Oh

#

Ty dude

#

I think I'm starting to like Germany even more KEKW

grizzled raven
# neon leaf wdym verification

like, when you buy a server don't you have to verify your identity? send your passport or other form of identification? anything like that

neon leaf
#

no

grizzled raven
#

so you just buy the server and you get it?

neon leaf
#

yes

grizzled raven
#

how long would you say you have to wait

neon leaf
#

30s

spark flint
#

mine was instant

grizzled raven
#

lmao

spark flint
#

i just paid and it is up within 15s

grizzled raven
#

that's nice

#

the epyc servers are out of stock right

neon leaf
#

yes

grizzled raven
#

actually nevermind about that i'll just get a different one

#

which one aside from epyc would you recommend

neon leaf
#

what are you planning to host

grizzled raven
#

lmao just a bot and a db

neon leaf
#

the sale servers are fine then

grizzled raven
#

hm

#

alright thanks for your help 😁

tulip ledge
quartz kindle
deft wolf
desert verge
#

Hello I would like help

#

I don't know how to position correctly the stats

river gust
lyric mountain
desert verge
#

On the middle of the right box

lyric mountain
#

you mean both on the middle?

desert verge
#

Yes all the stats that load

lyric mountain
#

wrap them in a single div and margin: auto auto

desert verge
#

It's already in a div

lyric mountain
#

I mean both in a div so they're moved as a single element

desert verge
#
.box-2 {
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      margin: auto auto;
      gap: 5px;
      width: 30%;
    }

    .box-2 p {
      border: 1px solid #ebd4cb;
      padding: 7px;
      height: 30px;
    }
#

It doesn't work

lyric mountain
#

u need to wrap them in a div

#

that div cannot be the box itself

#

actually

#

do padding: auto auto on it

desert verge
#

on the .box-2 ?

lyric mountain
#

on whatever the right box is

#

this should make the inner elements center on it

desert verge
#

It doesn't move

lyric mountain
#

try justify-content: center

desert verge
lyric mountain
#

weird

desert verge
#

ah no

#

Edited a bit

#

Does that

#

align-content doesn't work for vertical

lyric mountain
#

so align-items for vertical and justify-content for horizontal

desert verge
#

Okay

lyric mountain
#

the inverse for flex column

desert verge
#

Alright thank you !

lyric mountain
#

yw

jaunty basalt
#

Code:

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

module.exports = {
    name: 'avatar',
    aliases: ['av'],

    async execute(message, bot, args) {

        let user = null;

        if (args.length > 0) {

            let userID = args[0];

            try {
                user = await bot.users.fetch(userID);
            } catch (error) {
                user = message.mentions.users.first();
            }

        } else user = message.mentions.users.first() || message.author;

        if (!user) return await message.reply({
            content: ":Smike_x_mark: Please mention a valid user or provide a valid user ID!",
            allowedMentions: {
                replied_user: false
            }
        });

        let member = await message.guild.members.cache.get(user.id);

        if (!member) return await message.reply({
            content: ":Smike_x_mark: The user mentioned is no longer within the server!",
            allowedMentions: {
                replied_user: false
            }
        });

        let avatar = user.displayAvatarURL({ size: 2048, dynamic: true });

        let embed = new EmbedBuilder()
            .setTitle(`${user.username}'s avatar`)
            .setURL(avatar)
            .setImage(avatar)
            .setColor('#00008b');

        await message.reply({
            embeds: [embed],
            allowedMentions: {
                replied_user: false
            }
        });

    },

};```

Can anyone pls tell why my bot respond with `:Smike_x_mark: The user mentioned is no longer within the server!` when I provide a user ID? 
Pls tell me how to fix
desert verge
#
let member = await message.guild.members.cache.get(user.id);

why is it async ?

#

.get is not async

#
let member = await message.guild.members.fetch(user.id);
#

Here:
use .parsedUsers instead of .users

#

It works every times, message.mentions.users.first() never works for me

#

Here:
User may not have already started a DM

#

so use await message.guild.users.fetch(userID)

#

@jaunty basalt

#

the, user and member variables are the same thing, then use one of them. And as it returns a GuildMember instance, to get avatar url is: member.user.displayAvatarURL()

tulip ledge
desert verge
#

and member is cached, member.user too

tulip ledge
#

Yeah but you said member and user were the same variable

desert verge
#

Ah I see, but they created a member variable just to get the user

#

the verification of if the user exists is triggered twice

#

Ahh I see, it's to not get a user off the guild

earnest phoenix
#

Me when discord.js users has no idea about message.mentions.members to get the member version of the mentioned user

civic scroll
#

wouldn't a message mension be <@UID>

desert verge
#

@desert verge where do you see the guild id

earnest phoenix
#

?

civic scroll
desert verge
civic scroll
quartz kindle
#

wat

civic scroll
#

since, technically a mention is a message that has a pointer to other message that it responds to

desert verge
earnest phoenix
#

discord.js provides a way to get the mentioned user as a member through message.mentions.members instead of having to get the user first and then to get the member version of them yourself

quartz kindle
#

wat⅔

civic scroll
desert verge
#

Ah then use .get

quartz kindle
#

message.mentions is a separate class that holds all mentions that exist in the parent message

#

message.mentions has users, members, channels, everything

earnest phoenix
#

Yeah

quartz kindle
#

you dont need to separately parse any of that because it has already been done for you

desert verge
#

Because it did not parse

earnest phoenix
quartz kindle
#

message.mentions.members.has(member => member.id === botid)

desert verge
#

for me, message.mentions.users.first() is undefined

#

the debug tells this

quartz kindle
#

do you have caching disabled or limited or something?

desert verge
#

Nope, but is caching disabled by default ?

quartz kindle
#

no

earnest phoenix
quartz kindle
#

ye mb

desert verge
#

.has() is same as .get(), .has() it's like adding !! before to make it falsy then make this true

quartz kindle
#

then mention your bot

desert verge
#

Okay

desert verge
quartz kindle
#

wat

#

well yeah

#

but thats kinda inneficcient

earnest phoenix
quartz kindle
#

.get returns the result, .has doesnt return it, so its technically more performant

#

ye

desert verge
#

I was just saying

sharp geyser
#

wtf was I just reading

deft wolf
#

I have no idea

quartz kindle
#

warhammer 40k

#

js edition

#

starring the god emperor of dune

sharp geyser
#

old man

desert verge
#

Does it look good on mobile?

sharp geyser
#

why the red

desert verge
#

Idk I chose red

#

what is the better color for roleplay ?

#

green ?

#

Like plants?

#

I'll change the logo, so maybe change the color

earnest phoenix
#

how to convert text to an hexadecimal color (@ me)

desert verge
#

Did you search for that on stackoverflow ?

sharp geyser
#

text?

desert verge
#

string containing hexadecimal

#

Well I think, no need to convert

craggy pine
#

Only thing I can even think of is having a db of colors and their hex value and then when someone says “blue” it goes and grabs the hex.

earnest phoenix
#

blue to hex yes

#

but i found the chroma-js modul thx

desert verge
#

oh ok

sharp geyser
#

There are too many to even make your own database of colors

#

and something like that will highly likely end up being a paid api or a shitty api with shit rate limits anywhere else

craggy pine
#

I mean very true, but just thinking of the basic colors, a simple json db or hell even defining them within the js file itself would be fine. No library needed. But i guess for convenience sake chroma-js probably does the job fine.

wheat mesa
#

Could probably go buy one of those giant paint swatches with like every single color ever in them and manually type them out lmao

#

Or use computer vision to automate the process

desert verge
#

You can still put the name of the color

#

and hex

earnest phoenix
desert verge
#

Okay I see

#

french to english then ?

#

there is a deepl lib

earnest phoenix
#

yes to convert it to an hex color

#

ok thx lets see

desert verge
#

Oh it's not convenient if we need an api key

#

sorry

#

A ever did a deepl lib using puppeteer, but don't know if it works

#
eternal osprey
#

how do i override a method in js?

tulip ledge
tulip ledge
earnest phoenix
#

thx all

tulip ledge
#

Or if you’re talking built in you like string.replace you do so with string.prototype.replace for example

eternal osprey
#

Like i have a class that inherits a super class, but want to change one of the inherited methods

tulip ledge
#

Oh just in the class you redefine kt

#

It*

earnest phoenix
#

You just implement the method in the subclass that inherits the other class

tulip ledge
#

class parent {
foo() {
return “bar”;
}

class child extends parent {
foo() {
return “hello”;
}
}

#

Sorry for bad formatting am on phone

eternal osprey
#

Oowh i see!

#

I was thinking with java where we must use @override

#

so i thought there would be a method in js as well

scenic kelp
#

you don't actually have to use @override in java, hence why it's an annotation and not a language keyword

lyric mountain
#

It's required yes, but even if u don't include it it's inferred

scenic kelp
#

it's best practice to use it because the compiler can tell that fooo isn't a method on the parent class

#

so it'll know that you done fucked up

lyric mountain
# scenic kelp

Yes, it's not required to write it, cuz the compiler can infer it

#

Just like semicolons in js

scenic kelp
#

the compiler isn't "inferring" the annotation exists

lyric mountain
#

I mean the override itself, not specifically the annotation

scenic kelp
#

well yeah

#

that's why the annotation exists though, to be explicit

lyric mountain
#

Yes

scenic kelp
#

because java doesn't have a keyword to explicitly override a method (unlike say C# which does)

lyric mountain
#

I somewhat like the annotation approach

scenic kelp
#
class A {
    public virtual void Foo() {}    
}

class B : A {
    public void Foo() {}
}
``` in C# for example you'd get a warning here
lyric mountain
#

Easier to see on a glimpse, as it's usually highlighted differently

#

Tf high res

scenic kelp
#

(also in C# you have to explicitly mark stuff that can be overridden with virtual forgot about that)

lyric mountain
#

Another thing that's pretty neat is the @Contract annot

scenic kelp
#

but the warning tells you to either override it or to mark it as shadowing the A.Foo() method with new

#
class A {
    public virtual void Foo() {}    
}

class B : A {
    public override void Foo() {}
}

class C : A {
    public new void Foo() {}    
}```
#

i quite like that approach

scenic kelp
lyric mountain
#

there are a bunch of jetbrains annotations too for documentation

#

like @Range

#

the compiler takes them into account too

surreal sage
#

I want to use it for jsdoc param type

surreal sage
covert ingot
#

anyone know why boostrap nav hamburger doesnt work? First i throught it was my code then i codied it exact but nothing happens when i press it

#

on computer it works fine, but when u go on mobile view -> press hamburger nothing happens

#

my code is exact same so im not sure if im missing something, using cdn

#

everything else on boostrap is working fine so far

covert ingot
surreal sage
covert ingot
#

I have it in the head

sage bobcat
#

One message removed from a suspended account.

#

One message removed from a suspended account.

covert ingot
#

is that going to solve my problem ?

neon spruce
#

Is it normal to have had this message for more than 5 days?

craggy pine
#

Buy a server. 🤷

lyric mountain
#

You'll eventually need a server

marsh lark
#

Self host

#

If you have an old laptop/Android phone it will work

lyric mountain
#

No like, really, there's an upper cap you'll hit regarding host capacity, no matter how efficient your code is

#

Replit ceiling is really low

#

I mean, there are hosts for like $7

#

But yeah, 13 is too early

#

Btw, I noticed u have a green name, I'd be wary about getting too many servers too fast

#

Else you might get capped at 100 due to inorganic growth

marsh lark
lyric mountain
#

If ur under 100, u definitely dont

#

Theres a high chance of being declined during verification

#

No, not much u can do now

#

Just dont advertise it

#

And pray people don't notice it too much

#

At least until discord verification

#

Are u developing ur bot by yourself or following a tutorial/template?

#

You'll need to fill a form at 76 servers, make sure u pay attention to what you code

#

Especially regarding stored data

#

Privacy reasons

#

You'll need to justify what and why you're storing

#

Like username or messages

#

Or general activity

#

I'd shouldn't matter much, as it's anonymous enough

#

But you'll still need to explain what u use it for regardless

marsh lark
#

you dont have to disclose IDs iirc since theyre not personal info

#

yeah message content is something to consider

lyric mountain
#

Discord will give u some (superficial) info on what u need to answer when the time comes

marsh lark
#

If you're storing it for a reason and a user consents to storing it then you can store it as long as it's encrypted during transit and rest

lyric mountain
#

Not too complicated, but people who blindly follow tutorials/guides often get stuck at it

#

Cuz they can't answer what they didn't develop

#

If ur coding yourself you'll be fine

marsh lark
#

If it's stored locally dw about it

lyric mountain
#

Please learn a database

marsh lark
#

Just make sure non-devs of your bot cant access it

warm surge
#

It’s better

marsh lark
#

DB scales more and is generally better though

lyric mountain
#

Json is very prone to corruption, and heavily bottlenecks your I/O throughput

#

It's fine for read-only data, but a nono for read/write

marsh lark
#

You don't technically need a db at 13 servers but it's good to have, plus corruption

warm surge
#

I got 49 servers, all of it is in MongoDB

lyric mountain
#

Also I bet discord won't accept a "I use json as a database" answer in the form

marsh lark
#

They dont rly care how you store it as long as its secure

lyric mountain
#

Sqlite is a very beginner-friendly database

#

Little setup, little data types to worry about

#

Veeeeery simplified queries

warm surge
#

Exactly

#

also im school nerd so no one will anyways

#

But MongoDB is easy and secure database anyone can use.

soft laurel
#

I'm attempting to remove channel permissions from a discord user. Right after removal it seems to be given immediately back. The channel dissapears from the user's perspective and immediately comes back. It doesn't seem to be giving the permissions back anywhere. Is there some setting i'm missing?

Code to remove permission:

VoiceChannelManager manager = voiceChannel.getManager();

for (SummonerInfo summoner : replacedSummoners) {
    manager.putMemberPermissionOverride(summoner.getDiscordId(), null, permissions).queue();
}            
lyric mountain
#

I advocate for sqlite, as it can be easily ported to postgres once you get enough data flow

lyric mountain
marsh lark
#

SQLite also stores data in a file doesnt it

lyric mountain
#

And that there's no other bot to intervene

warm surge
lyric mountain
marsh lark
#

Well yeah but sqlite stores it in 1 file

lyric mountain
#

All databases do KEKW

#

They just hide it inside

lyric mountain
#

Sqlite isn't enough for big data

lyric mountain
#

Any will do, what I mean is that all databases boil down to a file holding data

#

Mongo is different to sql databases, kinda like 2 sides of a coin

warm surge
lyric mountain
#

Both are fine, it's just a different flavor

#

A thing to take into account, is that mongo is terrible if you're dealing with relationships

#

As mongo isn't meant for that

soft laurel
lyric mountain
#

Some bots have a similar feature, to prevent griefing

soft laurel
lyric mountain
#

See the audit logs then

#

It'll appear what's giving the perms back

soft laurel
lyric mountain
#

And reset the token, just to be sure there's no ghost instance running around

lyric mountain
soft laurel
#

ty

covert ingot
#
:root {
    background-color: black;
}``` is in /public/base.css https://pastebin.com/pjzjaKs3
#

any idea why my css doesnt show?

#

^ booststrap is overriding my css for some reason still looking for fix

real rose
#

p sure the style tags go into the head btw

#

you also only have a closing head tag?

desert verge
#

Try this

#

And show me the code of where you are serving the public folder

#

@covert ingot

desert verge
#

Hello I need help!

#

bot.better-roleplay.xyz redirects to my ip:port of my bot server which have a webserver for requests

#

What can I use to allow the connection ? I'm using express

deft wolf
#

Well, I have different message

desert verge
#

Ah ok so it's not spread yet in France

#

OH NO

#

I need to have this in https

deft wolf
#

You should be able to access it with http

#

Yea, with http it works

desert verge
#

Because my dashbord is in https

sharp geyser
#

Can a sub command have sub commands in terms of slash commands?

deft wolf
#

I don't think so

#

Of course, if I understand the documentation correctly and what you want to do

stuck dawn
#

Anyone knows how to remove the effect that framer-motion (shakes when the animation finishes)

#

I know it's a default thing

wheat mesa
tulip ledge
#

command -> subgroup -> subcommand

wooden ember
#

i love how running "npm i ffmpeg-static" has now made literally every command of my bot not load anymore

lament rock
#

Because you're using require for esm modules. You MUST use import

wooden ember
#

why?

#

why does installing one module fuck my entire bot

lament rock
#

idfk. The whole CJS vs ESM thing is so dumb and some modules only support ESM because it's supposedly better, but actually divides the node ecosystem more

wooden ember
#

wait is this cuz npm updated the chalk package on my system

lament rock
#

Some npm modules only supports use of import

#

you can use the import statement in CJS

wooden ember
#

been battling that for years. I just copy paste an older version of chalk and use that

#

lemmy just revert it and see if that fixes it since everything in my bot uses it

#

yeah its chalk being useless

#

lets just delete it cba to use 20 mb of dependencies just to make my cli coloured

#

i can just use ANSI

#

cheers for the help tho

wooden ember
#

got this error

#

I ran npm i sodium

#

and then got this error

#

what does any of that mean

#

since its not understanding make Im guessing that there is a compiler missing somewhere

#

but thats about all i can make out

sharp geyser
neon spruce
#

I have a bot which when I enter the token and execute the code sends an error and when I try the token from another bot it works perfectly.

deft wolf
#

Then your token is invalid

neon spruce
#

and the strangest thing is that it is only with one code, when I put the token in a different code it works fine.

#

can discord block the connection directly to a specific code?

#

what happened to me is that precisely because of that code they sent me this message

#

"It appears your bot, has connected to Discord more than 1000 times within a short time period. Since this kind of behavior is usually a result of a bug we have gone ahead and reset your bot's token."

#

And as I said, only with that code it sends me an error when trying to connect with the bot, but with other codes the bot works perfectly.

deft wolf
#

It doesn't make much sense. Apparently in this code your token is not changed because the token has nothing to do with the bot code

#

It's just a string that tells discord what bot wants to access the api

#

They can't access your bot's code via a token, and they can't "ban" your bot code

#

If you could send the error, it would probably be easier to locate the problem

neon spruce
#

ooh ok

#
    at new Guild (/home/runner/whatai2/node_modules/eris/lib/structures/Guild.js:110:78)
    at Collection.add (/home/runner/whatai2/node_modules/eris/lib/util/Collection.js:41:19)
    at Shard.createGuild (/home/runner/whatai2/node_modules/eris/lib/gateway/Shard.js:1445:40)
    at Shard.wsEvent (/home/runner/whatai2/node_modules/eris/lib/gateway/Shard.js:650:38)
    at Shard.onWSMessage (/home/runner/whatai2/node_modules/eris/lib/gateway/Shard.js:1721:26)
    at ws.onmessage (/home/runner/whatai2/node_modules/eris/lib/gateway/Shard.js:1598:33)
    at WebSocket.onMessage (/home/runner/whatai2/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (node:events:513:28)
    at WebSocket.emit (node:domain:489:12)
Emitted 'error' event on Client instance at:
    at Shard.emit (/home/runner/whatai2/node_modules/eris/lib/gateway/Shard.js:1882:26)
    at ws.onmessage (/home/runner/whatai2/node_modules/eris/lib/gateway/Shard.js:1601:22)
    at WebSocket.onMessage (/home/runner/whatai2/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (node:events:513:28)
    at WebSocket.emit (node:domain:489:12)
    at Receiver.receiverOnMessage (/home/runner/whatai2/node_modules/ws/lib/websocket.js:720:20)
    at Receiver.emit (node:events:513:28)
    at Receiver.emit (node:domain:489:12)
    at Receiver.dataMessage (/home/runner/whatai2/node_modules/ws/lib/receiver.js:414:14)```
#

and exactly the same code only with the token of another bot

Ready!```
spark flint
#

if it has reconnected over 1,000 times in a short space of time, that means there is an issue in your code that is causing it to repeatedly restart iself

#

my bot had that when i used discord.js on a next.js site, it kept reconnecting and caused it to auto reset token

earnest phoenix
#

You can run sudo apt install make to install it if you're using a Linux distribution that uses the APT package manager (like Ubuntu or Debian), or install it with the package manager of the other Linux distributions

#

If you're using Ubuntu or Debian (or anything that's based on them) I'd recommend installing the build-essential package using the APT package manager, which will install everything needed for proper compilation and stuff

lyric mountain
#

it appears there's a bug when trying to cache a guild, where the cache itself is missing

#

did u modify anything related to cache?

grizzled raven
#

for those using contabo, is contabo steal still a problem or am i stuck in 2020

spark flint
#

i find their network slow

lament rock
#

My node was offline for 9 hours while engineers and the panel said everything is ok, yet another node in the same datacenter worked okay

lyric mountain
#

At least not for me

craggy pine
#

Does discord allow a slash command to autocomplete based on which option within the command you chose? Example:

    options: [
        {
            name: "category",
            description: "Get a list of commands within a category",
            type: 3,
            required: false,
            autocomplete: true
        },
        {
            name: "command",
            description: "The command you need additional help for | Max 25 show at once, type to filter",
            type: 3,
            required: false,
            autocomplete: true
        },
    ],

//missing code here to shorten the chat spam

    autoComplete: async (client, interaction) => {
        switch (interaction.options._hoistedOptions[0].name) {
          //._hoistedOptions[0] is the closest thing I can figure out but leads to weird issue if category is selected then command. Command shows the autocomplete of category.
    },
lament rock
#

There is an options Array, so it's up to you to return suggestions based off other options present

#

Ah. You're using a wrapper

#

You may want to consider using raw representations or alternatively, logging the interaction

#

But I'm sure wrappers find cheeky ways to obscure info from you with getters and the likes

craggy pine
#

Yeah, the code atleast the structure isn't mine but a slash template if you will. So compared to how others do their slash commands mine looks more like...

module.exports = {
    name: "ping",
    category: "General",
    description: "Replies with bot ping!",
    usage: [`/ping`],
    example: [`/ping`],
    type: 1,
    options: [],
    permissions: {
        DEFAULT_MEMBER_PERMISSIONS: "SendMessages"
    },
    run: async (client, interaction, config, db) => {
    //stuff    
};
sharp geyser
#

Are localizations in things like names and descriptions limited to only what discord supports or can you use stuff like i18n to determine this kind of things?

marsh lark
#

Only what discord supports in user settings > language

#

but thats already a lot of languages

sharp geyser
#

smh

#

Indeed, but discord still lacks support for a small number of them

#

I guess its enough for now

marsh lark
#

yeah true

#

i mean if it supported custom languages how would it know which one to show you

sharp geyser
#

Honestly discord should let localization be handled by the dev

lament rock
#

It kinda can

sharp geyser
lament rock
#

British english doesn't have to be British english in the code side

#

it can be lol catz

sharp geyser
#

lmao

marsh lark
#

I mean guild commands exists

#

but registering ones for each server it joins is kinda a hassle

sharp geyser
#

Loading commands for a specific guild each time is api spammy

marsh lark
#

yea

sharp geyser
#

which is why i18n should be left up to the developer to handle in some cases. If anything allow there to be an option where a dev could integrate their own system if they wanted. Which mind you is a very difficult thing understandably

tulip ledge
#

let focusedOption = payload.options.getFocused(true)

#

Then you can compare the focusedOption based on the option

#

If you want subcommands you do payload.options.getSubcommand()

#

If you want a specific option you can use payload.options.get(“option”).value

#

@craggy pine

covert ingot
lyric mountain
#

what's :root supposed to be?

#

also ur html structure is wrong

#

I suppose that's supposed to be for your bot's long description yeah?

covert ingot
#

no not for a bot, n wym my html structure wrong. :root is root ? when i uncomment bootstrap link style background goes back

lyric mountain
#

for a bot? a site u mean?

covert ingot
#

no

#

nothing to do with a bot

lyric mountain
#

ok, but is it for a site?

covert ingot
#

yh

lyric mountain
#

then your html is very wrong

#
<html>
  <head>
    ...
  </head>
  <body>
    ...
  </body>
</html>
#

this is the correct html structure

covert ingot
#

it is like that

#

oh

#

nvm let me delete /html

lyric mountain
#

what?

covert ingot
#

my html is right now, was structure the only thing that was wrong? if so i fixed it, thats just the base file, so i include that at the top of every file. its ejs

#

but still, bootstrap is overriding my css n i have no idea why

lyric mountain
#

maybe, idk how your actual html looks like

#

styles must always be inside head

#

elements inside body

#

and idk what :root is supposed to be

covert ingot
#

:root is root, im not sure what u mean

lyric mountain
#

ok but WHAT is root?

covert ingot
lyric mountain
#

in html there's no root

#

that sounds like ```css
html {
...
}

covert ingot
#

either way, it works the way it does. ive used it before n it works perfectly well for me that way im doing, but this is my first time using bootstrap

lyric mountain
#

bootstrap is usually used with html, not ejs

#

not sure if they work together as ejs has its own generator

#

why do you need boot?

#

for the styles?

covert ingot
#

yeah

desert verge
#

Someone know a bot which has an api for making addons ?

tulip ledge
#

explain what you mean by addons

desert verge
#

dev api to add functionalities to the bot

tulip ledge
#

so, you mean a bot where you can develop addons for?

#

that'd be a security risk I think

#

and I mean, discord uses an api to make bots??

#

isn't that what you want?

desert verge
#

To verify the user, just use discord oauth2

tulip ledge
deft wolf
#

So you mean something like shared hosting but using bot

tulip ledge
#

I think that if it exists, it would have very very limited access

desert verge
tulip ledge
#

because iirc theres a limit on how many slash commands a bot could have

desert verge
#

It will be a thing like that:

#

/addon [addon_name] [parameters]

#

It will just look like a command using message.content

tulip ledge
#

I don't think I'm getting what you want

deft wolf
#

Me too

desert verge
tulip ledge
#

so you want to develop a command for a bot that's not yours?

#

then you still need a function no?

tulip ledge
#

and in that function you can put an eval command

desert verge
#

If people want to add more functionalities to my bot

tulip ledge
#

that people can exploit?

#

and what do you mean with functionalities?

deft wolf
desert verge
#

pfff, yeah I'm trying to do without eval

tulip ledge
#

I mean what you could do is create your own addons and allow users to enable/disable them

#

if that's what you want

desert verge
#

No

tulip ledge
#

because if you give anyone the freedom to add anything to your bot, you will get people who can and will abuse it

desert verge
#

I want to let people create their own addons on my bot

tulip ledge
#

why do you think that you can't upload a bot to top.gg if your eval command is not admin locked?

deft wolf
#

Yea, they gonna abuse it

desert verge
#

I will not use eval

tulip ledge
#

but

#

people will be able to put eval in their code

#

when they create their own addons

#

that's what I'm trying to tell you

desert verge
#

I know!

#

I will parse

#

If it detects the eval it doesn't execute the code

tulip ledge
#

you know you don't need to type a function name to execute the function right?

desert verge
#

....

tulip ledge
#

All you need is []()!+

#

these characters

#

and you can do anything with js

desert verge
#

You don't know how it will look like

#

The addon will be hosted

#

The bot will retrieve the content of the file

#

Parse it

#

Use the special npm lib

deft wolf
#

So you are gonna make file for every addon?

tulip ledge
#

I'm trying to tell you that it's a huge security risk

desert verge
#

A file ?

#

No the file is hosted on their own server

#

In the db there will be the list of addon urls

desert verge
#

I'm thinking

tulip ledge
#

the reason I chose to develop on dc is so I don't have to worry about security risks

#

and now you're planning on introducing one yourself

deft wolf
#

It's a very strange concept

tulip ledge
#

yeah

desert verge
#

the npm lib, is just doing http request to my bot, so they won't have access to my client class

tulip ledge
#

so how are you planning on replying to interactions then?

#

what will people be able to do with it then?

#

if they can't access any data

desert verge
#

They will have access

tulip ledge
desert verge
#

To what they really need

tulip ledge
#

like what

desert verge
#

Well i don't know how to expain but I can show a demo code

#

to what will look like the addon

#
let Addon = require("brp-addon");
let addon = new Addon(api_key, "avatar");
addon.on("execute", async ({interaction, api, user, params})=> {
let chara = await interaction.awaitCharacter(user.id);
interaction.send(chara.avatar);
})
#

Finally, I think, the addon don't need to be hosted

#

Just need to register

tulip ledge
#

you're giving them access to the db

quartz kindle
#

you want to offer your bot users a way to script their commands?

#

or what

deft wolf
#

Okey so you can access interaction.client no?

desert verge
#

I put the methods I want

#

Dude....

#

Who want to put the true interaction class ?

desert verge
#

it is the wrapper api of the bot

quartz kindle
#

so you want to make a sub-api basically
you receive event, check registered addons, send event to addon, which resides in the users pc or host, the user runs logic and responds to you, and you respond to discord?

tulip ledge
#

why are you calling that db ;-;

quartz kindle
#

doable

#

but

#

you will be responsible for what the user responds

#

so for example if they send slurs and shit, you might be affected

tulip ledge
#

that's what I'm tyring to say

#

it's a high security risk

desert verge
quartz kindle
#

you dont need to give them access to yiur db

#

they can run their own db on their end

desert verge
#

They need access to that

quartz kindle
#

ah

desert verge
#

in my bio there is the link

quartz kindle
#

so yeah youll need a layer of abstraction for that

desert verge
#
let Addon = require("brp-addon");
let addon = new Addon(api_key, "avatar");
addon.on("execute", async ({interaction, api, user, params})=> {
let chara = await interaction.awaitCharacter(user.id);
interaction.send(chara.avatar);

// Use api like: 
let charas = await api.getCharas(user.id) // There is no confidential informations in a chara object.

// params
if(params[0]) {
let user_id = parseMention(params[0]);
// etc.
}
})
deft wolf
#

I would rather stick with the good old database and the /register-character command or something like that

desert verge
#

?

#

I didn't understand

#

My bot have /register to register a character

desert verge
#

how do I get the blue developer badge ?

spark flint
#

not possible anymore

desert verge
#

Yup I just googled it

sharp geyser
#
export abstract class Command {
    name: string;
    description: string;
    nameLocalizations: LocalizationMap | null;
    descriptionLocalizations: LocalizationMap | null;
    options: Array<ApplicationCommandOptions>;
    nsfw?: boolean;
    constructor(options: ICommandOptions) {
        this.name = options.name;
        this.description = options.description;
        this.nameLocalizations = options.name_localizations;
        this.descriptionLocalizations = options.description_localizations;
        this.options = options.options;
        this.nsfw = options.nsfw;
    }

    abstract run(interaction: Interaction): void;
}

Should I actually be making it abstract sense I don't want it to be instantiated by itself but rather extended but the run method, is it something they should be overriding themselves or nah?

wheat mesa
#

I do something pretty similar in my framework

#

You’re gonna need a run method, having it abstract is perfectly okay

sharp geyser
#

Ight bet

#

Also just realized options should be optional :^)

wheat mesa
#

Doesn’t necessarily HAVE to be optional, can just be an empty array

sharp geyser
#

true, but its typescript we are talking about here

#

so if I don't make it optional i'll likely get the "Hey, I am getting error it saying it required but I don't need options for this command"

#

rather just negate that

#

I think discord.js automatically puts in a empty array anyway if its not supplied

#

if not discord itself just allows it to be absent

tulip ledge
#

What does abstract class do again and what is it used for?

sharp geyser
tulip ledge
#

Ahh

#

Thank you

sharp geyser
#

so with that class above I would do

class SomeCommand extends Command {
  constructor(){
    super({
      name: 'basdas',
      description: 'asdasdads'
    })
  }

  run(interaction: Interaction) {
    interaction.reply('asdasd') //dk if this is how you do it anymore but ye examples
  }
}

So trying to do let cmd = new Command() would give an error

#

its a basic abstract class, there are some that get more complex im sure

wheat mesa
#

Seems inspired by detritus 😉

#

Mine is heavily inspired by detritus

sharp geyser
wheat mesa
sharp geyser
#

I'll never match detritus but I want to give people the same feeling

#

I dont even bother giving them the client

#

as discord.js naturally has the client attached to everything KEKW

wheat mesa
#

Heavily inspired by detritus

sharp geyser
#

you just straight up give them a subCommands field

#

I just leave it as options

#

:p

wheat mesa
#

I have that for SubCommandGroups only

#

It's options for normal commands

sharp geyser
#

All my code is subject to change

#

rn I don't have any idea in mind for sub commands

#

I might make different command classes like you and have one for CommandGroups

#

and another just for normal Commands which would be Command

sharp geyser
#

I assume it does and just sets the type to be a subcommand thingy

desert verge
#

Anyone tried to make a Discord.js api wrapper with Decorators like what does Nextjs ?

wheat mesa
#

that's the thing I didn't copy from detritus

#

the complicated and fancy magic generics

sharp geyser
#

lmao

wheat mesa
#

CommandGroup is super simple

sharp geyser
#

Also waffle how the fuck do I add the git repository to my shit

#

I forgor how to add an origin

wheat mesa
#

Most of the magic is handled by my command manager and startup script

wheat mesa
sharp geyser
#

💀

#

I haven't done it in over a year

wheat mesa
#

lol

#

But yeah the most "magic" I have is when loading slash commands atm ```ts
async function loadSlashCommands(client: PaperClient, options: { directory: string; excludeFiles: string[] }) {
try {
const files = fs
.readdirSync(path.resolve(__dirname, options.directory), { withFileTypes: true })
.filter(
file =>
(['js', 'ts'].some(e => file.name.endsWith(e)) && !file.name.endsWith('.d.ts')) ||
file.isDirectory(),
);
for (const file of files) {
console.log(file);
if (options.excludeFiles.some(f => f === file.name)) {
continue;
}

        if (file.isDirectory()) {
            loadSlashCommands(client, {
                directory: `${options.directory}/${file.name}`,
                excludeFiles: options.excludeFiles,
            });
        } else {
            const ret = (await import(`file:///${path.resolve(__dirname, `${options.directory}/${file.name}`)}`))
                .default;

            if (ret.default instanceof Command) {
                client.commandManager.addCommand(ret.default);
                console.log(`Loaded command ${ret.default.name}`);
            } else if (ret.default instanceof CommandGroup) {
                client.commandManager.addCommandGroup(ret.default.name, ret.default);
                console.log(`Loaded command group ${ret.default.name}`);
            }
        }
    }
} catch (e) {
    console.log(`Error occurred whilst loading commands: ${e}`);
}

}

#

This was still a work in progress when I originally worked on it, so I haven't handled comparing the differences between currently uploaded slash commands and what I have client side to avoid ratelimit issues

earnest phoenix
sharp geyser
#

finally remembered

sharp geyser
#

I have not programmed in months

#

so I dont understand that anymore

desert verge
sharp geyser
#

it uses the discord.js lib most likely

#

I doubt waffle made his own for this KEKW

#

Honestly I might go back to doing my own lib and just build a wrapper around it

#

we'll see how this goes

desert verge
#

there is nothing

sharp geyser
#

there is?

desert verge
#

it is empty

sharp geyser
#

no its not

#

💀

desert verge
sharp geyser
desert verge
#

i know

sharp geyser
#

Yea cause I haven't done any of that yet

desert verge
#

but the code

sharp geyser
#

:C

#

I been working on the command/event classes themselves rn

#

I aint even done with Event class yet but decided to push to github before I forgor and accidentally lose progress somehow

#

:)

wooden ember
grizzled raven
#

anyone use https://datalix.eu as their host? feels wrong to bother the same guy over and over

wheat mesa
#

I didn't feel like implementing gateway shit or caching, this was just written for a bot I was writing a while back

desert verge