#development

1 messages Β· Page 2019 of 1

sudden geyser
#

oh a dsl

lyric mountain
#

means the command requires the first argument to be a text

#

I can put any amount of tags, each will define what argument is expected at that position

#

I can also supply any amount of signatures, the parser will get the first valid one

slender wagon
#

What i plan on doing is make a script that creates work shifts for everyone

#

For a team in this case

#

And basically make it so when i want lets say monday morning off it will format the shifts that way so it wont bother the other workers

sudden geyser
#

bot maker

slender wagon
#

Visual Studio Code

lyric mountain
#

for example

sudden geyser
#

depends

#

do you want to write an actual program

lyric mountain
#

I could supply s!welcome clear and it'd pick the third signature

sudden geyser
#

or use some helper / blocks language

slender wagon
#

botghost

#

Jk

#

Ik the guy that made that

#

πŸ˜‚

#

Yeah its a joke if u wanna learn programming too chose visual studio code and watch a tutorial

lyric mountain
#

depends on the lang and platform

#

you wouldn't use vscode on mobile

#

oh damn

sudden geyser
slender wagon
#

I would suggest rust

lyric mountain
#

so @slender wagon, if u want I can help u with java or groovy (depends on whether u want to go full static or stay dynamic)

slender wagon
#

Or the best in your opinion

lyric mountain
#

java ofc, groovy is more like a java dlc

slender wagon
#

I will learn java ofc

#

πŸ’€

#

Is java ofc hard to learn

lyric mountain
#

not really

#

u said u have c# knowledge already, so you'll find it pretty familiar

slender wagon
#

Mhm

#

So basically my schedule is fucked

#

Thats why i am organizing the shifts and making an app for it

#

After that i will hit u up

wheat mesa
#

Java is really easy

lyric mountain
#

sure

wheat mesa
#

Java is the ultimate data structures lang

slender wagon
#

Which database goes the best with it

lyric mountain
#

since java has jpa, the answer is "any"

slender wagon
#

πŸ’€ πŸ’€

sudden geyser
#

you mean jdbc?

lyric mountain
#

no, I mean jpa

#

java persistence api

#

it's like the official java data access standard

wheat mesa
#

Bite the bullet and learn a language. Building a discord bot with blocks is going to make you hate development

lyric mountain
#

then there are its providers, like hibernate and spring

sudden geyser
#

hmm

slender wagon
#

πŸ’€

wheat mesa
#

Someone... suggested... THAT????

slender wagon
#

The smart init

lyric mountain
#

a simple ban command will look like picasso

wheat mesa
#

oh my god

lyric mountain
wheat mesa
#

A real language

slender wagon
#

πŸ˜‚ πŸ˜‚ πŸ˜‚

wheat mesa
#

Javascript, python, Java, literally anything but those shitty β€œbuild your own discord bot” websites

lyric mountain
#

js/py/j are pretty much the entry points of programming

slender wagon
#

I couldn't code either

wheat mesa
#

Yes you can, you just don’t want to put in the time it takes :p

lyric mountain
#

not with that atitude

slender wagon
#

How old is u

lyric mountain
#

everyone has to start somewhere

wheat mesa
#

Anyone can code, you just have to actually start with it

slender wagon
#

I started coding when i was 13 or 14

wheat mesa
#

Instead of telling yourself that you can’t do it

#

I started programming when I was 15

#

Now I’m 16 mmulu

lyric mountain
#

don't rely on youtube

slender wagon
#

Started it with the OG c#

#

Playing around at first

lyric mountain
#

use actual courses and doc

#

damn even stack will be better

wheat mesa
#

Don’t use block languages

#

Like scratch

#

Those don’t teach you anything

lyric mountain
#

scratch that idea

wheat mesa
#

It’s good for 11 year olds, but for a discord bot? Nope

#

Just by doing it

#

And asking for help

slender wagon
#

Doing i

#

??

lyric mountain
#

well, start with the bare minimum idea, go up as you learn

#

begin with a simple "Hello World" program (important step)

slender wagon
#

@earnest phoenix install nodejs install vsc and then google how to get started on making your own bot with discord.js

lyric mountain
#

look, the easier something is, the less freedom you'll have

slender wagon
#

Either that or python

#

I would suggest nodejs

lyric mountain
#

scratch is easy, but you're terribly capped in what u can do

slender wagon
#

Just google it

#

First thing

lyric mountain
#

are u on pc?

#

discord app or browser?

#

open the browser (blank page), press F12, click on console

#

play with it, that's a javascript console

#

no installation required

slender wagon
#

And insert this code.....

#

πŸ’€

slender wagon
lyric mountain
#

don't expect it to give u a finished code btw

slender wagon
#

Read abt js too

lyric mountain
#

you'll be writing the same JS as the one you'd use on the console

#

it's better to learn JS first before u start dealing with dependencies and whatnots

neat ingot
#

anyone genuinely interested in creating a bot maker type app that doesnt suck? hmu 😘

sick agate
#

no

lyric mountain
#

I mean, they suck because they use building-block methods, a bot maker without building blocks would be raw programming

neat ingot
#

there is a middleground

#

someone just has to make it

sick agate
#

i dont think there is

lyric mountain
#

building blocks, not building blocks and null

neat ingot
#

well. i know there is. im literally planning the design for it, have been for a few weeks πŸ˜„

#

it just depends on how you tackle the issue

sick agate
#

then show me the middle ground

neat ingot
#

i'd rather show someone who was genuinely interested in helping development πŸ˜›

lyric mountain
#

the schrodinger's middle ground

neat ingot
#

πŸ˜‚

lyric mountain
#

oh it also allows supplying a list of valid values

neat ingot
#

what is this?

#

some custom intellisense thing?

lyric mountain
#

my custom command signature dsl

sick agate
#

cool

lyric mountain
sick agate
#

i wouldnt be bothered enough for that honestly

lyric mountain
#

by those signatures, valid commands would be```
!command
!command limpar
!command clear
!command some big text

sick agate
#

oh b

lyric mountain
#

anything else would throw a syntax error

neat ingot
#

your not using slash commands now?

lyric mountain
#

nope bcuz they are quite limited regarding variable signatures

neat ingot
#

yea this is true

lyric mountain
#

like, a command can only have 1 signature, and u can't have mutually required arguments

#

like if A is supplied, B is required

neat ingot
#

yea, that annoys me occasionally too lol

wheat mesa
#

Just write your own discord client with a parser built into it KEKW

neat ingot
#

like, why cant i show b only when a == x

lyric mountain
#

also when they add such features, I can just use my parser to compile those signatures into slashes too

#

so it's two birds with a single rock

neat ingot
#

yea thats fair

lyric mountain
#

if the arguments match the first signature, B is required

neat ingot
#

yea, but i want it to be natively supported in slash commands πŸ˜„

lyric mountain
#

ik lul

#

one day maybe

neat ingot
#

hopefully

lyric mountain
#

ye, it works perfectly

raven holly
#

Does somebody now how to fix this ```import Event from './event-handler';
import Deps from '../../utils/deps';
import CommandService from '../commands/command.service';
import Guilds from '../../data/guilds';
import AutoMod from '../../modules/auto-mod/auto-mod';
import Leveling from '../../modules/xp/leveling';
import { Message } from 'discord.js';
import Logs from '../../data/logs';

export default class MessageHandler implements Event {
on = 'message';

constructor(
private autoMod = Deps.get<AutoMod>(AutoMod),
private commands = Deps.get<CommandService>(CommandService),
private guilds = Deps.get<Guilds>(Guilds),
private leveling = Deps.get<Leveling>(Leveling),
private logs = Deps.get<Logs>(Logs)) {}

async invoke(msg: Message) {
if (!msg.member || msg.author.bot) return;

const savedGuild = await this.guilds.get(msg.guild);

const isCommand = msg.content.startsWith(savedGuild.general.prefix);
if (isCommand) {
  const command = await this.commands.handle(msg, savedGuild);
  if (!command) return;
  
  return await this.logs.logCommand(msg, command);
} 

if (savedGuild.autoMod.enabled) {
  try {
    await this.autoMod.validate(msg, savedGuild);
  } catch (validation) {
    await msg.channel.send(`> ${validation.message}`);
  }
}
if (savedGuild.leveling.enabled)
  try {
    await this.leveling.validateXPMsg(msg, savedGuild);
  } catch {}

}
}
error TS2339: Property 'message' does not exist on type 'unknown'.

37 await msg.channel.send(> ${validation.message});
~~~~~~~

lyric mountain
#

private?

#

in js?

raven holly
#

this is type script

#

but myb you know

lyric mountain
#

oh ok

#

validation is undefined

raven holly
#

hm

#

where should i define them

lyric mountain
#

since validate is a promise, just use .catch(err => ...)

#

no need for try-catch

raven holly
#

so this

lyric mountain
#

nono

raven holly
#

then how xD

lyric mountain
#
FROM
-----------------------------
if (savedGuild.autoMod.enabled) {
  try {
    await this.autoMod.validate(msg, savedGuild);
  } catch (validation) {
    await msg.channel.send(`> ${validation.message}`);
  }
}

TO
-----------------------------
if (savedGuild.autoMod.enabled) {
  await this.autoMod.validate(msg, savedGuild).catch(err => await msg.channel.send(`> ${err.message}`));
}
raven holly
#

ou okay

#

but what about this

lyric mountain
#

where is that?

raven holly
#

sec

#
import { Message,  TextChannel } from 'discord.js';
import { Command, CommandContext } from '../../commands/command';
import Log from '../../utils/log';
import Deps from '../../utils/deps';
import { GuildDocument } from '../../data/models/guild';
import Validators from './validators';
import { promisify } from 'util';
import Emit from '../emit';

const readdir = promisify(fs.readdir);

export default class CommandService {
  public readonly commands = new Map<string, Command>();

  constructor(
    private emit = Deps.get<Emit>(Emit),
    private validators = Deps.get<Validators>(Validators)
  ) {}

  public async init() {
    const files = await readdir('./src/commands');
    
    for (const fileName of files) {
      const cleanName = fileName.replace(/(\..*)/, '');
      
      const { default: Command } = await import(`../../commands/${cleanName}`);
      if (!Command) continue;
      
      const command = new Command();
      this.commands.set(command.name, command);
    }
    Log.info(`Loaded: ${this.commands.size} commands`, `cmds`);
  }

  public async handle(msg: Message, savedGuild: GuildDocument) {
    try {
      const prefix = savedGuild.general.prefix;
      const slicedContent = msg.content.slice(prefix.length);

      const command = this.findCommand(slicedContent, savedGuild);
      const customCommand = this.findCustomCommand(slicedContent, savedGuild);
      if (!command && !customCommand) return;
      
      this.validators.checkChannel(msg.channel as TextChannel, savedGuild, customCommand);        
      this.validators.checkCommand(command, savedGuild, msg);
      this.validators.checkPreconditions(command, msg.member);

      const ctx = new CommandContext(msg, savedGuild, command);
      await command.execute(ctx, ...this.getCommandArgs(slicedContent, savedGuild));
      
      this.emit.commandExecuted(ctx);
      return command;
    } catch (error) {
      const content = error?.message ?? 'Un unknown error occurred.';      
      await msg.channel.send(`> :warning: ${content}`);
    }
  }

  private findCommand(slicedContent: string, savedGuild: GuildDocument) {
    const name = this.getCommandName(slicedContent);
    return this.commands.get(name)
      ?? this.findByAlias(name)
      ?? this.commands.get(
        this.findCustomCommand(name, savedGuild)?.command
      );
  }
  private findByAlias(name: string) {   
    return Array
      .from(this.commands.values())
      .find(c => c.aliases?.some(a => a === name));
  }
  private findCustomCommand(slicedContent: string, savedGuild: GuildDocument) {
    const name = this.getCommandName(slicedContent);
    return savedGuild.commands.custom
      ?.find(c => c.alias === name);    
  }

  private getCommandArgs(slicedContent: string, savedGuild: GuildDocument) {
    const customCommand = this.findCustomCommand(slicedContent, savedGuild)?.command;
    return (customCommand ?? slicedContent)
      .split(' ')
      .slice(1);
  }
  private getCommandName(slicedContent: string) {
    return slicedContent
      ?.toLowerCase()
      .split(' ')[0];
  }
}
#

this is part

#
      const content = error?.message ?? 'Un unknown error occurred.';      
      await msg.channel.send(`> :warning: ${content}`);
    }
  }```
lyric mountain
#

that error comes because no valid error object is thrown

#

so you can't grab a message from it

#

you need to use async .catch like I did above

raven holly
#

for example here i need validation

lyric mountain
#

validation is err in that case

#

just changed the name to make more sense

raven holly
#

ou hahaha

#

idk i downalod dashboard that some people use

#

is 2pg

#

but how to convert all of this to one line like you ```catch (validation) {
if (guild.autoMod.autoDeleteMessages)
await msg.delete({ reason: validation.message });

    if (guild.autoMod.autoWarnUsers && msg.member)
      await this.warn(msg.member, {
        instigator: msg.client.user,
        reason: validation.message
      });
    throw validation;
  }```
lyric mountain
#
try {
  await something
} catch (error) {
  fallback
}

is the same as ```
something.catch(error => fallback)

raven holly
#

ou okay

quartz hill
#

is it possible says user or bot with just user id ? (my eng not good sorry) (discordjs lib)

quartz kindle
#

no, you have to fetch

rose warren
#

Wait... πŸ‘€ So I was your inspiration? ummokkk

neat ingot
rose warren
neat ingot
#

im curious, how do you get your server count?

#

if you have to do it manually (which i doubt) my app could handle that for you if you have some endpoint setup to poll πŸ˜‚

old sigil
#

How to make a whois command? using py

flat ridge
#

I have a little custom bot script for my private server, where i can assign 1 bot per channels, but i can't get the invalidated event and i dont know when a bot token has changed, here is my code

Index main.js

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

client.bots = new Collection()

Command login.js

client.bots.set(message.channel.id, new Client());

const bot = client.bots.get(message.channel.id);

bot.login(args[0]);

bot.on('ready', () => {
message.channel.send('Bot connected')
});

So here everything is fine, i can receive all events (messageCreate, guildCreate) ect..

But when i add

bot.on('invalidated', () => {
console.log('A token has been changed')
});

When i change the token of the bot, the event is not emitted, and in the collection everything still available, i can do bot.guilds.cache.size after changing the token, all i want is check when the client disconnect so i can delete the client in the collection.

If someone can help me it would be great

pearl trail
boreal iron
#

The invalidated event will only fire for your connected client, your bot, not for other clients

flat ridge
boreal iron
#

Try to listen to the debug event and log what happens when you gonna change a token

slender wagon
#

is this something that's going viral on youtube or something

rose warren
#

But my rpc process also does daily local db backups so I don't have any reason to use anything else tbh

vagrant prairie
#

const express = require('express')
const Topgg = require('@top-gg/sdk')
const fetch = require('node-fetch')
const app = express()
const webhook = new Topgg.Webhook('h')
app.post('/vote', webhook.listener(async(vote) => { 
    var amnt = (Math.floor(Math.random() * 100000) + 10000);
    console.log("User with id - " + vote.user + " Voted!")
    let value = JSON.stringify({
        embeds: [
            {
                title: "Voted!",
                description: `<@${vote.user}> (${vote.user}) Just Voted For \`Disminer!\`!\nPrize : ${amnt} Money`,
                color: "8388736"
            }
        ]
    })
    fetch("webhook url", { 
        method: 'POST',
        headers: {
            'Content-type': 'application/json',
        },
        body: value
    }).catch(e => console.log('Error occured while posting webhook : ' + e))
    const economyy = require('./economy.js')
    await economyy.addCoins(vote.user, amnt)
}))
app.listen(19448)``` it used to work, now it doesnt, why? ii changed the ip before and it stopped working, i updated it tho
jovial nexus
#

how can i ping a user sending a message having the allowedMentions: { repliedUser: false } in the client? (in djs)

rose warren
# jovial nexus how can i ping a user sending a message having the `allowedMentions: { repliedUs...

You can override the client settings for this in your message options
https://discord.js.org/#/docs/discord.js/stable/typedef/BaseMessageOptions

raven holly
#

Idk is this right place to aks,but I'm making discord bot,i finished it but i want to make dashboard for that.So can someone help me ?

rose warren
raven holly
#

This is npm and is good but I don't get it about cookies and that that's why I ask for someone help hahahaj

rose warren
raven holly
#

Yes but i don't get it

#

@rose warren can you help me about dashboard part

rose warren
#

If there's a specific piece of code you're having an issue with you can post it here and explain your problem and someone might be able to help you

raven holly
#

Yes but i dont understand cookie part that they give at docs

rose warren
#

That's why I'd usually suggest coding your own site instead of cloning a GitHub repo because you'll learn a lot more by making it yourself and you'll also have a much better understanding of how it works.

raven holly
#

But I'm gonna go from scratch hqhahaja

#

I,m not gonna download his dashboard

#

I,m just gonna use his npm

#

But i,m gonna try something and let you know

rose warren
#

So I don't understand your question. Do you mean you don't know what cookies are for?

rose warren
#

That really depends on how you build your site, what language you use etc.

raven holly
#

Ou okay

#

I'm gonna try something and let you know if I need help

rose warren
#

Well I'm heading to work now but maybe someone else might be able to help!

raven holly
#

Ou okay

rose warren
#

Besides, I do all my web stuff in PHP so I doubt I'd be of much help darkAYA

raven holly
#

Ou hahhaa

#

Butwhats best way for dashboaqrd

#

With php

rose warren
#

Have you used PHP before?

raven holly
#

Yep but not too much

#

I tried to make contact form

rose warren
#

Well that's pretty much the basics of a dashboard. All you need to learn is how to do a login system with Discord and you'll have the absolute basics. I'm pretty sure you could find some examples for PHP Discord login online.

raven holly
#

Ou okay hahaha

rose warren
#

Basically instead of sending the data from the form to an email address you'll be saving it to your database instead.

stiff lynx
#

I've just seen a bot with spaces between words in slash commands names, how is this possible?

#

If I try to do it I get errors

split hazel
#

@quartz kindle do you know any good hashing algorithms for turning a string into a number?

#

because i want to convert the column names into a hash since they're much faster to process than a sequence of characters

fickle arch
#

how to switch from quickdb to mongodb for economy system ?

old cliff
#

I deleted the ping wait xwass

#

The catch block returns undefined... the collector code is getting executed even if the catch is called

#

And you are returning undefined in the catch block

#

So dm is undefined

#

And you are accessing property channel of dm

#

Try using try catch and not using catch on the promise while sending the dm or create the collecter after the dm is successfully sent using then

earnest phoenix
#

i have problem

#

and it is inside "yt_cookie"

fickle arch
#

I have music feature either and it required youtube token for it to work

stiff lynx
#

How can I have spaces in slash commands name?

neat ingot
rose warren
#

Yeah that's a good idea darkLike

earnest phoenix
lyric mountain
#

just convert the char to byte and hash the array

neat ingot
#

the last time I had to convert things to chars... #memories...

#

10 points if you can guess what it does πŸ˜„

fickle arch
lyric mountain
#

no, the change won't be as simple as "changing the require"

#

also why change?

#

quick.db IS bad, but it's more appropriate for relational data than mongo

fickle arch
neat ingot
#

heroku is good, but not for anything your wanting to run 24/7 imo

lyric mountain
neat ingot
#

unless your prepared to pay them through the butt

fickle arch
#

I've been told that quick.db is reliable if you already have your own vps to host the bot.

neat ingot
#

also had that one for lolz

fickle arch
#

I already host the other bot on that and so far works pretty well, but now I'm working on other one.

lyric mountain
#

any database (except mysql) is reliable if you have a vps

fickle arch
#

is it including quick.db ?

lyric mountain
#

quick.db isn't a db

#

quick.db is a library for sqlite

#

and it's terrible at that since it stores everything in a json column instead of using proper table structure

neat ingot
#

i was looking into sqlite, but paired with sequelize. not sure though, never tried either

fickle arch
#

what db economy system usually use ?

#

I'm still new on developing

lyric mountain
#

not necessarily economy, but postgres

neat ingot
#

the db you use does not matter. any decent db could be used to store any kind of data ~ within reasonable file sizes

earnest phoenix
#

i have economy bot and i am using MongoDB

lyric mountain
#

you see, you don't use a database "for X", you use it as a general storage mean

neat ingot
#

i also use mongodb, but i think most bots use do use sqlite?

lyric mountain
#

mostly use mongo probably, since it's the most appealing at start

#

and the bot market is saturated by people who choose the easy path

fickle arch
earnest phoenix
#

No i am not using mongoose

neat ingot
#

i am πŸ˜›

earnest phoenix
#
fickle arch
#

I'll look into it

neat ingot
lyric mountain
#

not because it's a popular or good language

#

but because china has the biggest population in the world

neat ingot
#

lmao yea i guess thats fair πŸ˜„

lyric mountain
#

most of the bot devs are anonymous small devs that follow some kind of tutorial that suggest either quick.db or mongo

earnest phoenix
lyric mountain
#

and most use heroku or some other service that doesn't allow file-based storage

fickle arch
#

if I use quickdb and pull a build on the vps, would it rewrote it or not, because heroku did

lyric mountain
#

so they go for mongo unless using a vps

fickle arch
#

sorry if I'm kinda confusing with the question

neat ingot
#

best host i've found so far is contabo. 5 euro a month for 4 core and 8gb ram. and the server i have at least is stable af! ❀️

lyric mountain
#

it is

neat ingot
#

imo, no point in using heroku when you can just buy 4core8gb for 5 euro a month

fickle arch
lyric mountain
#

heroku is great for on-demand apis

lyric mountain
earnest phoenix
neat ingot
#

yea, things like heroku and didgital ocean are great for whipping up a quick test

neat ingot
#

crap, i gotta run.. have fun folks 😘

lyric mountain
#

cya

lyric mountain
#

whatever you'd do on your pc you'd do on a vps

inner sapphire
#

Simple logger in javascript.

const colors = require("colors");

module.exports = function(logMessage, type = "info") {

    let logFormat;
    let logString;

    switch (type) {
        case "system":
            logFormat = colors.bgBlue(colors.white(colors.bold("[SYSTEM]")));
            logString = colors.white(logMsg);
    }
    console.log(logFormat, logString);
}

How to use if you're lazy like me
<client>.logger = require("logger.js");

In Cmd & Event Files
<client>.logger("something", "system");

quartz kindle
#

djb2 is one of the simplest and fastest ones out there

#

converts a string to int32

#

fnv1a is similar to djb2 but better and can be configured for different output bit length

fickle arch
#

how do I make bot send emoji from a server ?

#

this is my code and it came like this

    { name: "<"a:server:961990824902660156"> Servers:", value: `\`\`\`${servers_count}\`\`\``, inline: true },```
#

ignore the " between a to > because that's the server emoji ID

old cliff
#

Field titles cant have emojis as long as i remember

fickle arch
#

what part of embed could have emojis

old cliff
#

Uh... they can

fickle arch
#

πŸ€”

old cliff
#

can you log the string?

fickle arch
#

what

old cliff
#

and are you sure the bot has perms to UseExternalEmojis?

fickle arch
#

does that include if bot has administrator ?

old cliff
#

yes admin has that

fickle arch
#

I'm pretty sure the bot has administrator.

old cliff
#

hmm try logging the string

fickle arch
#

how, I'm still new on developing

old cliff
#

console.log

fickle arch
#

something like this ?

#

putted this console.log("stats is working")

split hazel
#

like no collision acceptable

#

or well as many combinations as a 64bit int can have

fickle arch
old cliff
#

u really working on messages while using djs13?

#

your bot probably doesnt have timeout perms

quartz kindle
#

anything 128bit+

#

if you think 64 bit is enough, fnv1a does have that option, but is not 100% collision-free

#

murmurhash is also a good option, or xxhash

#

or just use snowflakes lol

#

snowflakes are 100% colision-free

#

just not random

#

although they are not really a hash

pale oasis
#

Pulling a random post from reddit is always a pain.
const data = await axios.get(url).then(res => res.data.data.children[Math.floor(Math.random() * res.data.data.children.length)].data);

#

The amount of times I wrote data is going to give me an aneurysm.

inner sapphire
#

this was fixed

#

even github dependabot had alerted and fixed it

near stratus
#

but it's in history
like even if node-ipc gets fixed will russians ever use it ?

sick agate
#

i highly doubt

quartz kindle
#

pretty sure it was already fixed

sick agate
#

it is kinda

rocky hearth
#

can I detect in a server, which page the request came from?

sick agate
#

?????

boreal iron
#

It’s never guaranteed that you can get it or it’s accurate

#

You will also need to make sure the REFERER doesn’t contain your current domain name as jumping from one to another site will define the REFERER as your previous site if it’s been provided anyways

rocky hearth
#

ok thx

atomic kindle
atomic kindle
sick agate
#

yeah

raw sigil
#

i have this error

lyric mountain
#

nice error πŸ‘

raw sigil
#

client.statusHook = new Discord.WebhookClient("960547863996285018", "jCnqrrHs3G5cEy39NySw2sGYjvjeG5y3pw4ifC1Pj3fInOHSE5Bq_x60VM6vGIs1CxYb")

#

this is line

lyric mountain
#

yes, and that's a webhook leak

earnest phoenix
raw sigil
#

and thx for help

boreal iron
#

β€œ2. Referrer Policy Changes

Last but not least, [...] has changed how it handles the referrer, or β€œreferer” (sic),[5] policy. Our previous approach frequently broke websites, requiring users to turn off Shields to use a site, and so lose all privacy protections. Our new approach greatly reduces the number of broken sites, while still aggressively protecting your privacy.”

#

You can go and read that in the privacy informations of your browser

atomic kindle
#

So edge cases?

boreal iron
#

And/or simply edit the default policy yourself or addons (usually) do this job for users

atomic kindle
#

Because all decent and well known browsers, by default, will send the referrer header unless disallowed by policy or attributes.

boreal iron
#

As well as sending a request to the client, to not put your current location into the referer (if the browsers wants to follow this request)

raw sigil
# earnest phoenix https://discord.js.org/#/docs/discord.js/stable/class/WebhookClient
/* SHARDS */
client.rocoShard = new Discord.WebhookClient("channelid",  "webhook token")

client.on("shardReady", async shard => {
    client.rocoShard.send(`Shard **#${shard}** ready on **${client.guilds.cache.size}** servers and **${client.users.cache.size}** users.`)
})

client.on("shardDisconnect", async shard => {
    client.rocoShard.send(`Shard **#${shard}** disconnected from its servers and users temporarily...`)
})

client.on("shardReconnecting", async shard => {
    client.rocoShard.send(`Shard **#${shard}** reconnection in progress on the servers containing this shard...`)
})

client.on("shardResume", async shard => {
    client.rocoShard.send(`Shard **#${shard}** successfully reconnected to **${client.guilds.cache.size}** servers and **${client.users.cache.size}** users.`)
})

/* SHARDS */```
#

where is error?

#

From what I see, there's nothing wrong with that

boreal iron
earnest phoenix
boreal iron
#

But you simply can not rely on an accurate referrer, never

earnest phoenix
#
new WebhookClient({ token: /* Your webhook token */ });
boreal iron
#

No matter it's been send with or not

atomic kindle
#

Yep. Can easily be forged and bob's your uncle

#

Could use CSRF tokens but I don't consider them very secure either

earnest phoenix
lyric mountain
#

webhooks can be called even if ur not in the guild

#

that's the danger of exposing them

earnest phoenix
raw sigil
wheat mesa
#

Leaked your token, you should change that

boreal iron
#

pass them as strings...

raw sigil
#

?

#

i have error on token

wheat mesa
#

Yes

#

You need to pass them as strings

#

The program doesn’t know how to parse your token without it being a string

boreal iron
#

stupid program doesn't know what I want to do

wheat mesa
#

Ikr

wheat mesa
#

Imagine if js allowed strings without quotes somehow

boreal iron
#

the poor fellow who needs to write the parser for it

wheat mesa
#

I would pity him

boreal iron
#

I'm sure Tim has some time left, to do the job

wheat mesa
#

Tim doesn’t need a parser

#

He IS the parser

boreal iron
#

As JS founder he should be interested in enveloping it

#

lmao

#

I forgot

wheat mesa
#

Tim scans through every js program ever run, that’s why he’s so busy all the time

boreal iron
#

And he benchmarks each app, don't forget about that

wheat mesa
#

Lol

#

Alright gotta go back to class πŸ˜”

boreal iron
#

oof

#

again...

wheat mesa
#

Not gonna pay attention

boreal iron
#

using phone is school

wheat mesa
#

We’re watching a Will Smith movie

#

In my next class

#

Lmao

boreal iron
#

pepowot πŸ”«

wheat mesa
#

Also I was on lunch break I’m about to walk back into school

#

Not using my phone at school

#

Yet πŸ˜‰

sick agate
boreal iron
#

I remember the time when phones didn't even were a thing

wheat mesa
#

Turns out fake is my comp sci teacher

#

Actually nvm, my comp sci teacher uses Java

boreal iron
#

A time when we beat up other students just to pass the time

quartz kindle
#

@_@

boreal iron
wheat mesa
#

I don’t remember such a time because I was not alive

boreal iron
#

A time you still was some sort of fluid swimming around

#

You will learn more about that in school

#

When NOT using your phone

sick agate
#

i have bringed my phone to school like 10 days at least

boreal iron
#

Don't wanna spoiler anything here

sick agate
#

and i get caught by the same guy twice

wheat mesa
#

I use my phone all the time

sick agate
#

lol

wheat mesa
#

School is easy

#

I’d only worry about it if I were doing badly

simple stump
#

In express I'm trying to create a local file/folder. But since it's all handled server side, the folder doesn't exist. How can I solve this?

let title = someString.title.replace(/[^a-z0-9]/gi, '_').toLowerCase();
if (!fs.existsSync(join(__dirname, "../../web_server/myFolder/" + title))) {
  console.log("Creating folder...");
  await fs.mkdirSync(join(__dirname, "../../web_server/myFolder/" + title));
  console.log("Created folder " + title + ".");
}

Error:

Error: ENOENT: no such file or directory, mkdir '/myFolder/folder_title'
    at Object.mkdirSync (node:fs:1336:3)
    at C:\Users\path\myFile.js:202:38
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
boreal iron
#

errr just to say __dirname has no ending slash (or backslash on winstupid)

#

__dirname + "../../my/path" will end up being /home/this/dir../../my/path which isn't a valid path

solemn latch
#

does join not add /

cinder patio
#

it does

wheat mesa
#

Paths are so scuffed

boreal iron
quartz kindle
#

mkdir is not recursive by default, you need to add recursive: true

earnest phoenix
#

Yep, also you don't need to await the mkdirSync() method since it's synchronous

neat ingot
#

^ an example of a function to copy a file from one dir to another, while recursively creating required directories. uses fs.promises

feral aspen
#

Is it possible to install an Ubuntu operating system on a USB and boot from there? If so, what are the precautions when doing so, do I like disconnect such SSDs and HDDs when I do so or?

cinder patio
#

Just create a bootable USB, plug it into ur PC and boot it

#

you don't have to do anything else

feral aspen
#

Are files on my SSD and HDD at risk when doing so?

#

Like opening a file via my ubuntu operating system?

quartz kindle
#

no

feral aspen
#

16GB is enough? I don't have 32GB. :/

#

Quick question, I have files on my desktop (ssd), when I boot from my USB (ubuntu), I can still access the files but not from the Ubuntu Desktop, true?

split hazel
feral aspen
#

Sweet.

split hazel
#

i've done this before (an ssd on the go)

#

works nicely

feral aspen
#

When I boot from the USB, does it work like windows, I have to setup an account, etc?

split hazel
#

if you want persistance you need to launch an installer on another usb device and install it on the usb you want to boot from

#

do note that will wear out flash drives quickly (especially cheap ones)

feral aspen
#

Pardon?

#

What do you mean "wear out"?

split hazel
#

flash drives have a limited life cycle, they can only read and write so many times before they stop holding their charge and die

#

the length depends on the manufacturer

cinder patio
feral aspen
#

Rufus has finished.

quartz kindle
#

do you want a full mobile ubuntu installation?

#

because the ubuntu installer already has a "live disk" functionality, that you can run ubuntu from the disk without installing it

split hazel
#

yeah - i was talking in case they wanted persistance which would make things different

#

i tried some of the live boot persistence but it usually just crashes for me

cinder patio
#

live boot is meant just to test if the OS is compatible with your hardware and if drivers and everything is set up correctly

lyric mountain
#

or to unbrick ur os

feral aspen
#

What is it doing?

lyric mountain
#

something

#

probably

cinder patio
#

Checking disks

feral aspen
#

The USB?

#

.. or my SSD?

#

I'm booting from USB.

split hazel
#

ah

#

its doing a checksum

#

to check if all files on the usb are intact

feral aspen
#

Oh.. I could've done that on Rufus.

split hazel
#

it will do it regardless

#

its a safety measure

feral aspen
#

Aha.

split hazel
#

so it doesnt break mid installation due to a corrupted file

feral aspen
#

I'm just worried that I may lose my files.

#

Which it won't.

split hazel
#

nah dont worry it wont touch your files i've done it many times

feral aspen
#

πŸ‘

split hazel
#

just make sure you distinguish your drives apart

feral aspen
#

What?

split hazel
#

such as when doing things that require modifying the drive make sure you choose the correct drive

feral aspen
#

"No errors found" thats great.

#

Which one. ._.

#

Kind of trying and not demolishing my SSD.

cinder patio
#

Try

split hazel
#

what are you trying to do again

cinder patio
#

Installing clears your entire SSD

feral aspen
#

HELL NO.

cinder patio
#

Make sure to make a backup of ur SSD if you're so worried you'll fuck something up

feral aspen
#

Well that finished quick.

split hazel
#

does it make you feel better that ssds are very difficult to deep wipe because of volatile caching

#

not like that would stop you from losing everything tho

feral aspen
#

Works great.

lyric mountain
#

that window, that little window

#

is the best thing you'll use, ever

feral aspen
#

Terminal?

cinder patio
#

eh I'd use a different distro for a personal computer

split hazel
#

gnome πŸ’€

feral aspen
#

Yup, I installed it for that. πŸ˜‚

lyric mountain
#

Mr. Terminal, have respect

cinder patio
#

ubuntu's a little bloated

split hazel
#

just a little

feral aspen
#

Alright, enough. Back to windows.

#

My files are alive in windows.

cinder patio
#

Why'd you do that?

feral aspen
#

I'm just checking if I corrupted or lost anything while booting from the USB.

lyric mountain
feral aspen
#

For my safety, honestly.

feral aspen
cinder patio
#

I aint ready to move to Linux either

feral aspen
#

Checking Linux next.

lyric mountain
#

...

#

you already did

feral aspen
#

OH, it's part of Linux. (my bad)

lyric mountain
#

nono, it IS linux

feral aspen
#

My Discord is bugged.

lyric mountain
#

linux { ubuntu, fedora, redhat, gnome, arch, etc }

feral aspen
#

Ohh, misunderstanding, I suppose.

feral aspen
cinder patio
#

I really want to switch to Manjaro

plucky imp
#

wait wtf

feral aspen
#

Aha?

boreal iron
#

Discord is a bug

#

That’s the right sentence

plucky imp
#

i think

#

idk

#

this is what i'm trying to get from the guild id but

#

it says role or user is unndefined

#

wait

#

i think i'm slow

#

hold on

feral aspen
#

JS, right?

plucky imp
#

nope still doesn't work kek

#

yeah

#

i can show code if you need me to

boreal iron
#

Wouldn’t it be const { logdownRole } or is role an array of roles?

#

I’ve literally no clue about mongo KEKW

feral aspen
#

What does client.db.updateGuild(interaction.guild.id) return?

cinder patio
#

imb4 a promise

plucky imp
#

i don't have it logged hold on

feral aspen
#

We can do this the old fashioned way by requiring the model, applying the findOne method, filter, and then function.

boreal iron
#

I thought his screenshot is the database result log

feral aspen
plucky imp
boreal iron
#

And the result isn’t just an object representing the document, too?

plucky imp
#

this is what it returns

boreal iron
#

Yeah just an object

plucky imp
#

but like when i do it to see if the feature is enabled it works so idk why it doesn't for the role

boreal iron
#

Then see this

#

Err yeah correct my typo in there

plucky imp
#

okeY

feral aspen
#
<Model>.findOne({
    id: '954866030327500871'
}, async (error, data) => {
    if (error) console.log(error);
    if (!data) return; // You can also do whatever you want here.

    console.log(data); // This will return the document above.
    console.log(data.lockdownRole); // It will return the string value of `lockdownRole`.
})
#

You can do this.

plucky imp
#

not gonna lie i've been trying to figure this out for the past 2 days lol

boreal iron
feral aspen
#

Trying to get the value of lockdownRole?

plucky imp
#

yep

feral aspen
#

That's the way above. :)

boreal iron
#

If you don’t need the entire object just do it as I mentioned

feral aspen
#

We can also simplify all the above shorter but that depends what you want to do with the data.

#

If you want to configure the data, you can use the way above although if you want to just bring values, we can use this other way.

plucky imp
#

i just need to get the role so it can update the sendMessages permission

boreal iron
#

That’s your solution

plucky imp
#

pogggg

boreal iron
#

If you successfully changed my typo ofc

plucky imp
#

it works noW

#

i can finally move on

#

jesus

feral aspen
boreal iron
#

Fine

feral aspen
#

This is the most simplest way.

plucky imp
#

ty for the help qt's

boreal iron
#

Nope

feral aspen
feral aspen
boreal iron
feral aspen
#

Replace it with the variable that has a value that leads to the model.

boreal iron
feral aspen
boreal iron
#

He updated the document and wants to get the role of the result

#

A second request doesn’t make any sense

#

Means his way is absolutely okay

#

Your would cause another request even if the document data already exists

feral aspen
#

Ohh.. although, what did he log? role?

plucky imp
#

I-

#

it's already fixed CB_bully

boreal iron
feral aspen
#

Fixed but not in an efficient way. :/

boreal iron
#

That was his issue

feral aspen
plucky imp
#

yeah i changed it to lockdownRole

#

i'm sitll used to djsv12 docs lol

#

still*

boreal iron
#

*update query

feral aspen
#

What did it return?

#

In the SS, I see it logged the object with an error down so it's unclear.

boreal iron
#

It’s the similar to editing a message in djs which will return the edited message object

#

Anyways gotta do some work now

plucky imp
feral aspen
#

Oh, if so, he can use the destructuring assignment on the object and pull-up the value of the property by inputting the property name within the paranthesis.

feral aspen
#

God, hold on. await client.db.updateGuild(interaction.guild.id); returned the object, right? You can now do this. const { lockdownRole } = await client.db.updateGuild(interaction.guild.id);

#

If you want to rename the variable of lockdownRole to role, do const { lockdownRole: role } = await client.db.updateGuild(interaction.guild.id);

boreal iron
plucky imp
#

what are good antiraid things?

boreal iron
#

That’s what he ALREADY did

#

Which I stated 10 mins ago

plucky imp
#

lol

#

calm down PinkPet

#

it's already fixed lol

feral aspen
#

Honestly, I've been waiting for my answer in above, so I didn't pay attention. shruganimated

#

My bad on that.

boreal iron
#

The 3rd time I send this

#

Ignore my typo in there

#

lockdown not logdown ofc

boreal iron
#

evil boy

feral aspen
boreal iron
#

Alright I’m out smirk

feral aspen
boreal iron
boreal iron
#

Catched a new Discord bug on iOS

#

By clicking on Magical Cat used /dumpy

#

Which always happens when I press on a slash command reply

#

Which should actually open the modal showing me the entire command the user used

#

if somebody wants to report it

earnest phoenix
boreal iron
#

It’s a mobile upload

#

I guess with an unsupported format for the discord client

#

Therefore no embed?!

#

Which means:

#

Epic Voltrex fail

earnest phoenix
#

mov formats are supported, something else is wrong with it causing it to not embed

boreal iron
#

Quiet!

#

Epic Voltrex fail

#

Lemme try again

#

Nope

#

Funny that I’m actually uploading a mp4

#

@earnest phoenix Now explain this, please

earnest phoenix
boreal iron
#

Proves that discord is feature rich

#

_not to say bug _

toxic jolt
#

Guys, how can I enable "overflow" by doing "position: flex"?

earnest phoenix
cosmic forum
#

Hello, so I am trying to make a leaderboard command specific to the server the command is run in, however I have found that it is very inefficient and takes a very long time.

Here is my code below:

let m = await msg.channel.send("Loading... :loading:");
let top = Object.entries(lb).sort((a, b) => a[1] - b[1]).reverse();
let count = 0, topu = 0, tope = [];
while (count < 3) {
    if (topu > (top.length - 1)) {
        while (count < 3) {
            tope.push("No user found");
            count++;
        };
        break;
    };
    try {
        await msg.guild.members.fetch(top[topu][0]);
    } catch {
        topu++;
        continue;
    };
    tope.push(`<@${top[topu][0]}> - ${top[topu][1]} points`);
    count++;
    topu++;
};
let e = new Discord.MessageEmbed().setDescription(`πŸ₯‡ ${tope[0]}\n\nπŸ₯ˆ ${tope[1]}\n\nπŸ₯‰ ${tope[2]}`);
m.edit({ content: `Top 3 players in **${msg.guild.name}**`, embeds: [e] });

Does anyone happen to know a better algorithm to do something like this?

boreal iron
#

Worst conditions of the entire winter

quaint wasp
#

hey umm

#

how do u get rid of this

#

the source code control thing

austere surge
#

remove git from the directory or hide it?

rocky hearth
# quaint wasp

search git.decorations.enabled in vscode, and set to false

#

or disable git entirely with git.enabled

neat ingot
#

or push your updates πŸ˜„

austere surge
#

ye lol

whole glen
#

is there away to use html forms but not have the name of the form in the sites name? My code:html <p style="text-align:center;"><form action="/pages/" target="_blank"><input id="Searchbar" name="Searchbar" type="text" placeholder="Search comming soon"/><input type="submit" value="Submit"></form></p> product exmp: github.io/pages/?Searchbar=discord what i want it to say github.io/pages/discord Basically not haveing the name, the = sign and ?

neat ingot
#

idk what lib you are using, but are you sure findOne is async? some mongo libs it is not and expects a callback instead

#

no. the actual findOne function in the mongo library needs to be defined as async in order to await it

#

else it'd be something like:

xxxcollection.findOne({query:1}, function(error, data) {
  if (error) // blah blah blah
  data.thing.do();
})

^ again depending on what mongo lib youa re using

#

what node module* sorry

#

like, what node module are you using to connect to mongodb

#

ahh ok

#

hmm, apparently the findOne function for that lib is async

#

i normally use mongoose which adds additional features

#

so im not too familiar with normal mongodb module πŸ˜„

#

are you allowed database names with spaces in mongo? i always hypen them πŸ˜„

austere surge
#

ff

neat ingot
#

idk, mongoose auto converts my data strcuture names to lower case and such

#

lmao nice find πŸ˜‚

#

question

austere surge
#

alrigh

neat ingot
#

why are you storing a 'json' object in mongodb?

#

you realize it stores json/bson as it is?

#

like, the entire dataset that is returned to you on a successful query is a json like object, no?

#

^ one reason i like mongoose. i tell it how it stores its data.

#

pretty sure thats just mongodb tbh tho πŸ˜„

#

lol, in mongodb you can basically just add properties to your object as you see fit

#

so it just depends on how you s ave/define your obejcts

#

which raw json? where are you fetching this json from?

#

soo, you creating json data? why not just an object? why bother converting it to json?

#

from where?

#

oh, well thats not json πŸ˜„

#

its an object

#

json structure is similar, but has more quirks, and less capability

#
const objkt = Object.create(Object);
objkt.guildid = interaction.guild.id;
objkt.config = {
    enabled: true, 
    channelid: cat.id
}
xxx.insertOne(objkt)```
#

that'd do the same thing

#

and config is also just an object

#

lol, good lux πŸ˜—

neat ingot
#
await coll.updateOne(
  { title: 'Amadeus' },
  { $set: { 'imdb.rating': 9.5 } }
);```
#

^ would update the collection with the title: Amadeus, and set its imbd.rating to 9.5

#

the collection πŸ˜„

#
const coll = client.db.collection("Channel Storage");
await coll.updateOne(
    { guildid: interaction.guild.id },
    { $set: {'config.channelid': 123}}
);```
#

i think is what you are trying to do

#

its not a string, but you have to set it as such, because it is a property of an object

#

like, config doesnt return the value, it returns an object with properties that return values.

#

where channelid is a property you have defined on the config object

#

good lucks!

#

im working on saving/loading custom theme css from local storage for lolz

#

congrats πŸ™‚

neat ingot
#

isnt she just... beautiful? ❀️

lament rock
#

The orange personally isn't me

neat ingot
#

oh 😭

#

whats your color?

lament rock
#

0x585858

#

or is it 858585

#

I forgor

neat ingot
#

grey?

lament rock
#

yeah grey

#

58*

neat ingot
#

better?

lament rock
#

looks great imo

#

a neutral color is better than an opinionated one

#

or have custom color support

neat ingot
#

theme customizer doesnt look the best, but its functional πŸ˜›

austere surge
#

woagh

astral halo
#

how can i make my bot such that anyone can clone the repo and run it and it would work without behaving like multiple instances, e.g sending a message 2 times when someone other than me also runs the bot

cinder patio
#

let people generate their own tokens

astral halo
#

wouldnt they both send it still if they were in same guild

cinder patio
#

no? Their copy of the bot would be an entirely different application

#

but if both are in the same guild then yes both would send

#

because they're running the exact same code

astral halo
#

yes and i want to prevent that

#

whether it's the same token or not

cinder patio
#

Why would you even be in that situation in the first place??

#

You can't do this easily

astral halo
#

well my bot uses an api frequently for live update reasons and the api has a request/time limit for each ip

#

there maybe other solutions that i couldnt think of

cinder patio
#

The person who is hosting an instance of your bot won't have the same IP as you...

astral halo
#

yes so they wont be limited by the requests of bot on my server and can request still

#

thats why i asked it

cinder patio
#

So let me get u straight you want to use multiple instances of your bot just to avoid being rate-limited

astral halo
#

yes

cinder patio
#

Then just ask that?? Your original question is so much different

#

All of the instances need to be able to communicate with each other

sick agate
#

use trusted proxies then

cinder patio
#

IP rotation

sick agate
#

Β―_(ツ)_/Β―

cinder patio
#

or just don't do anything cause it's not worth it

sick agate
#

ye

rose warren
#

Shady. You should just follow the rate-limit and maybe re-think how you're using the data.

sick agate
#

yeah i can agree on that

proven lantern
#

is AWS blocked from doing GET calls to Discord's CDN? media.discordapp.net and cdn.discordapp.com
I have some code that works locally, but fails on aws lambda. the error from the lambda is Client network socket disconnected before secure TLS connection was established

sick agate
#

probs tls issue

proven lantern
sick agate
#

try without tls

proven lantern
#

it redirects to https

#

and it works on my computer

#
await new Promise((resolve) => https.get(proxy_url, response => response.on('data', d => resolve(d))))```
sick agate
#

tls issues then

crystal plover
rocky hearth
#

whats difference bw a modal and dialog?

high star
#

no

earnest phoenix
# rocky hearth whats difference bw a modal and dialog?

Dialogs are mostly messages that pop up that you just have to read and continue on with your life, or may require you to click certain things such as an option to ignore the dialog or save it somewhere and similar, modals are pop ups that ask for input from the user and similar things to do whatever

earnest phoenix
#

@hybrid cargo ads

hybrid cargo
#

@chilly pivot no ads pls, thanks

chilly pivot
hybrid cargo
chilly pivot
#

Ya

rocky hearth
#

I'm seen some react code like this

<Button>
  {(selected) => (
    selected ? <span></span> : <span></span>
  )}
</Button>

What this method is called

pearl trail
#

conditional operator

rocky hearth
#

No no, I mean, there is a function as children in Button

#

how do a function is passed as children, to Button?

ancient nova
#

does anyone know how to spawn an object with, say 10% chance?
tried doing both

if(Random.value <= 0.1) {
//code
}

And

if (Random.Range(0, 10) < 1) {
//code
}
``` but it seems to always be spawning
#

should I make it be like 0.0001?

dry imp
#

thats randomness

ancient nova
#

yeah, it's generating a random number and checks if it's lower than 10%

dry imp
#

sometimes you get lucky sometimes you dont

ancient nova
#

it is making sense in my head, but it may not be correct

dry imp
#

its just how it is

ancient nova
#

yeah, but it literally always somehow manages to spawn

dry imp
#

you could lower the percentage but some users may get very unlucky

ancient nova
cinder patio
ancient nova
cinder patio
#

doesn't look like it... Random.value?

ancient nova
#

it gets random double value between 0 and 1

#

it's an unity only function

raw sigil
#

how to make vote log?

boreal iron
earnest phoenix
drowsy flume
#

hello

earnest phoenix
#

is the makeCache required?

#

i'm moving to v13 so i'm reading the v12 to v13 doc

#

ok

#

so it works normally without it?

#

ok

woeful pike
#

https://www.youtube.com/watch?v=BgxklT94W0I lmfao this is the only good vid in this series

Python programming language
https://imgur.com/a/PnaZq1F
Interview with a Senior Python developer in 2022 with Dr. Harris Dlacc - aired on Β© 2022 The Python.

Programmer humor
Python humor
Programming jokes
Programming memes
Python 2022
Python memes
python jokes
uwsgi
conda
pip
pip install
venv
easy_install
django

#programming #jokes #python

β–Ά Play video
atomic kindle
#

It's pretty good too.

#

JJQuery KEKW

woeful pike
#

the js one was kinda boring tbh

#

this one was good tho

atomic kindle
#

I think I enjoyed them all. Fun perspective.

cinder patio
#

What's the best way to get rid of stack traces in errors

neat ingot
#

just log the message and not the error? πŸ˜›

cinder patio
#

but I'm throwing the error

neat ingot
#

but why would you want that?

cinder patio
#

The stack's useless for my case

neat ingot
#

then wrap your call in a try catch?

#

but obviously you dont need to return the error if you have no need

woeful pike
#

uhhhh you can do an uncaughtException handler and just log the message that way but that's a terrible idea

#

you should be exiting your program when you have uncaught exceptions

neat ingot
#

πŸ˜‚ almost every program i have eats exceptions

woeful pike
#

bad idea

neat ingot
#

you kinda have to for discord bot development or you bot stops

rose warren
wheat mesa
#

just make it in a safe way obviously!

woeful pike
#

run multiple instances of your app and restart when you have uncaught exceptions

#

otherwise your app is stuck in a bad state

neat ingot
#

uhhh

cinder patio
#

I'm making the error myself, I guess I could

console.error(msg);
process.exit(1);
woeful pike
#

yeah

wheat mesa
#

you wouldn't be able to catch that though, is it always fatal?

cinder patio
#

You're not supposed to be able to catch the error so that's not a problem

wheat mesa
#

oh okay

neat ingot
cinder patio
#

Only problem with this is that when I wrap it in a function it doesn't scream this is going to stop the process and that bugs me

neat ingot
#

you can add something like that that will scream 'im shutting down' whenever that happens

cosmic forum
#

Hello, does anyone know how to check if a user is in a discord server via their ID? (discordjs v13)

cinder patio
#

return throwError("...") doesn't look as nice as throw new Error(...)

neat ingot
#

capitalize it so it at least shouts? πŸ˜„

#

return THROWERROR("...");

#

i guess 'capitalize' would be the first letter, obviously i mean make all upper case

cinder patio
#

I guess I could still do
throw throwError(...), Nothing's gonna get thrown because the process exits before that

#

return throwError(...) also messes typescript up

neat ingot
#

why you exiting the process on error anyway?

cinder patio
#

cuz it's a fatal error

neat ingot
#

what is it your working on?

cinder patio
#

it's for a typescript plugin - you can't catch it (I guess unless you use the compiler API programmatically but you shouldn't either way), lets the user know

neat ingot
#

ahh ok, i was thinking it was some bot command, and im like ~ why you letting your bot die when a user fks up?! πŸ˜„

earnest phoenix
# cosmic forum Hello, does anyone know how to check if a user is in a discord server via their ...

Get the guild from the cache by it's ID using the client.guilds.cache.get() method and check if that user exists as a member in that guild by it's ID using the <Guild>.members.cache.has() method, remember that not all members are cached, so this could be false positive, it's a better idea to fetch the member instead since it also checks the cache before fetching unless forced to fetch, you can fetch the member using the <Guild>.members.fetch() method to check that, remember to handle it's error as well since it throws if the user doesn't exist as a member in that guild, you can handle it using either a try-catch statement or by using the <Promise>.catch() method

cinder patio
#

Okay well doing delete err.stack removes the stack trace

earnest phoenix
#

umm

#

interaction.author.id?

#

<Interaction>.user.id

#

ok

#

ty

cinder patio
#

When I set this.stack to "" the error message gets wrapped in square brackets 😩

cosmic forum
simple stump
#

Why does my bot not ping the actual role? It has full permissions and normal users can ping a role perfectly fine, but the bot isn't able to for some reason.

interaction.channel.send("<@&" + roles.queuePing + ">");
#

Not just be using @ and then selecting the Queue Ping option, rather using <@&883791592073330758>.

woven wren
earnest phoenix
#

umm

#
C:\Users\ADMINISTRADOR\Downloads\Clash-Chest\index.js:7
const client = new discord.Client({ allowedMentions: { parse: ['users', 'roles'], repliedUser: true}, Intents: [Intents.FLAGS.GUILD_MEMBERS] });
                                                                                                                ^

ReferenceError: Intents is not defined
    at Object.<anonymous> (C:\Users\ADMINISTRADOR\Downloads\Clash-Chest\index.js:7:113)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47
#

I only have the guild members intent active (maybe)

#

this one

quartz kindle
#

you didnt define Intents

#

Intents.FLAGS.GUILD_MEMBERS
^ undefined

simple stump
#

Oh wait the permission sorry.

#

It is. The bot has all permissions.

lament rock
# neat ingot

There are so many more kill signals than just interrupt and terminate you'd have to listen to to "safely" exit

#

also, they way you're doing it makes it so that the callback function gets duplicated in memory

neat ingot
lament rock
#

also, you HAVE to handle possible errors from your safety shutdown code or else your app will stay open forever

cosmic forum
#

Yo anyone got a terms of service template or generator for discord bots

neat ingot
sudden geyser
#

I'm working with a CLI that lets users specify values inside the flag name. For example, the -T option can be written as -Talias with alias representing the argument from the user. Is there a specific name for this style?

proven lantern
#

which one looks nicer?

woeful pike
#

filenameParts.at(-1)

proven lantern
#

ohh

#

that's fancy

#

when was this fancy at added

woeful pike
#

I think it was standardized last year?

proven lantern
#

i will test it in nodejs 14

#

pray for me

neat ingot
#

why not just .pop() the extension type off?

woeful pike
#

14 doesn't support it. Use 16

proven lantern
sudden geyser
neat ingot
#

yea thats fair. seems in this case at least though the array is only created to get the extension

sudden geyser
#

yeah

#

both would work

proven lantern
#

why doesn't aws support current version of node

#

same with google cloud

neat ingot
#

πŸ˜‚

#

thats pretty funny tbh

proven lantern
#

maybe nodejs is the current version

neat ingot
#

could be yea, that'd make sense~ latest stable

#

i like docker cause it lets my apps use whatever node version they need. its pretty handy πŸ™‚

proven lantern
#

aws cloidformation uses docker too

raw nest
#

Is there an easy JavaScript function to check if a key in an object which is in an array has a specific value?
F.e. I want to check if somewhere enabled is true. In something like this:

[
  {
    "name": "Test1",
    "enabled": "false"
  },
  {
    "name": "Test2",
    "enabled": "true"
  }
]
neat ingot
#

[].some(element => element.enabled)

raw nest
#

thanks, I'll try that

neat ingot
#

=> boolean

proven lantern
raw nest
#

πŸ‘ <3

neat ingot
#

find would return the element, some would return boolean if element exists

woeful pike
#

still can't believe python doesn't have a find function

#

actual madness

proven lantern
#

sad times

#

aws lies to us

sudden geyser
#

google cloud is always an option KyoukoLaugh

proven lantern
#

don't worry, they still support nodejs4.3

#

cloudflare workers maybe

#

i still haven't tried them

#

maybe cloud providers are scared to support the latest versions because they might not be secure

proven lantern
#

vercel only supports version 14 of nodejs too

#

no serverless wants to support nodejs 16

quartz kindle
#

i think they're just lazy to upgrade

#

its probably very expensive for them

proven lantern
sudden geyser
#

can't you just install it manually or something

proven lantern
#

so you load nodejs twice

feral aspen
#

Is it possible to fetch the 4th last deleted message in a server?