#development
1 messages Β· Page 2019 of 1
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
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
bot maker
Visual Studio Code
for example
I could supply s!welcome clear and it'd pick the third signature
or use some helper / blocks language
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
please don't suggest java
I would suggest rust
hava
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)
Which one is the most requested
Or the best in your opinion
java ofc, groovy is more like a java dlc
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
Java is really easy
sure
Java is the ultimate data structures lang
Which database goes the best with it
since java has jpa, the answer is "any"
π π
you mean jdbc?
no, I mean jpa
java persistence api
it's like the official java data access standard
Bite the bullet and learn a language. Building a discord bot with blocks is going to make you hate development
then there are its providers, like hibernate and spring
hmm
Not his fault someone suggested that
π
Someone... suggested... THAT????
The smart init
a simple ban command will look like picasso
oh my god
A real language
π π π
Javascript, python, Java, literally anything but those shitty βbuild your own discord botβ websites
js/py/j are pretty much the entry points of programming
I couldn't code either
Yes you can, you just donβt want to put in the time it takes :p
not with that atitude
How old is u
everyone has to start somewhere
Anyone can code, you just have to actually start with it
I started coding when i was 13 or 14
Instead of telling yourself that you canβt do it
I started programming when I was 15
Now Iβm 16 
don't rely on youtube
scratch that idea
Itβs good for 11 year olds, but for a discord bot? Nope
Just by doing it
And asking for help
well, start with the bare minimum idea, go up as you learn
begin with a simple "Hello World" program (important step)
@earnest phoenix install nodejs install vsc and then google how to get started on making your own bot with discord.js
look, the easier something is, the less freedom you'll have
scratch is easy, but you're terribly capped in what u can do
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
I see what u did there lmao
Read abt js too
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
anyone genuinely interested in creating a bot maker type app that doesnt suck? hmu π
no
I mean, they suck because they use building-block methods, a bot maker without building blocks would be raw programming
i dont think there is
building blocks, not building blocks and null
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
then show me the middle ground
i'd rather show someone who was genuinely interested in helping development π
the schrodinger's middle ground
π
oh it also allows supplying a list of valid values
my custom command signature dsl
cool
ah that's bcuz I wrote my own syntax checker for it
i wouldnt be bothered enough for that honestly
by those signatures, valid commands would be```
!command
!command limpar
!command clear
!command some big text
oh b
anything else would throw a syntax error
your not using slash commands now?
nope bcuz they are quite limited regarding variable signatures
yea this is true
like, a command can only have 1 signature, and u can't have mutually required arguments
like if A is supplied, B is required
yea, that annoys me occasionally too lol
Just write your own discord client with a parser built into it 
like, why cant i show b only when a == x
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
yea thats fair
that'd be possible with my parser
{
"<argA:any>[x] <argB:any:r> <argC:any:r>",
"<argA:any> <argC:any:r>"
}
if the arguments match the first signature, B is required
yea, but i want it to be natively supported in slash commands π
hopefully
ye, it works perfectly
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});
~~~~~~~
nono
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}`));
}
where is that?
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}`);
}
}```
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
but here you don't use validation
for example here i need validation
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;
}```
try {
await something
} catch (error) {
fallback
}
is the same as ```
something.catch(error => fallback)
ou okay
is it possible says user or bot with just user id ? (my eng not good sorry) (discordjs lib)
no, you have to fetch
Wait... π So I was your inspiration? 
lol yep. I seen your rpc activity one day and wanted to have my very own π

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 π
activity_string = '{} servers'.format(len(client.guilds))
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=activity_string))
How to make a whois command? using py
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
prob his bot have an api for stats and then in the RPC, make an interval request to that api
If you wanna remove a member who has left the guild then enable the member intent and listen to the guildMemberRemove event to the client ID you can also remove from your collection
The invalidated event will only fire for your connected client, your bot, not for other clients
but all my clients are connected and i get all events on every client, just not the invalidated event
Try to listen to the debug event and log what happens when you gonna change a token
why is there a increasing number of users doing this exact same thing
is this something that's going viral on youtube or something
I have an internal API I just pull from.
But my rpc process also does daily local db backups so I don't have any reason to use anything else tbh
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
how can i ping a user sending a message having the allowedMentions: { repliedUser: false } in the client? (in djs)
You can override the client settings for this in your message options
https://discord.js.org/#/docs/discord.js/stable/typedef/BaseMessageOptions
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 ?
There are resources in the pinned messages which can help you build a website. A bot dash is basically a site that's linked to the same database as your bot so users can change their settings etc in their browser.
Yes but i don't understand that hahahaja
For example https://github.com/SimonLeclere/discord-easy-dashboard/tree/ec8bf159e3d00d45e9a3832661408981367f275a
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
They seem to have their own documentation explaining that https://github.com/SimonLeclere/discord-easy-dashboard/blob/ec8bf159e3d00d45e9a3832661408981367f275a/docs/STORING_COOKIES.md
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
Yes but i dont understand cookie part that they give at docs
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.
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
So I don't understand your question. Do you mean you don't know what cookies are for?
Don't know how to implement ot
That really depends on how you build your site, what language you use etc.
Well I'm heading to work now but maybe someone else might be able to help!
Ou okay
Besides, I do all my web stuff in PHP so I doubt I'd be of much help 
Have you used PHP before?
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.
Ou okay hahaha
Basically instead of sending the data from the form to an email address you'll be saving it to your database instead.
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
@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
how to switch from quickdb to mongodb for economy system ?
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
i have problem
i have music bot and it has conifg.json with youtube cookie but when i run i get this https://uploadi.ng/88oggwBg
and it is inside "yt_cookie"
you mean youtube token ?
I have music feature either and it required youtube token for it to work
How can I have spaces in slash commands name?
Using subcommands
lol yea thats fair. doubling for db backups is also a nice touch. Tbh the only reason i kept making my app after i found out other apps like rpc maker existed, was so I could add the api polling and junk to it. π
Yeah that's a good idea 
youtube login cookie
strings are just char arrays
just convert the char to byte and hash the array
the last time I had to convert things to chars... #memories...
10 points if you can guess what it does π
could I do this by changing require('quick.db') to ('../../database) since the database already linked to mongodb
quick.db is sql-based, mongo is nosql-based
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
because the bot I worked on is using heroku as host
heroku is good, but not for anything your wanting to run 24/7 imo
no idea
unless your prepared to pay them through the butt
I've been told that quick.db is reliable if you already have your own vps to host the bot.
its part of my input system for rpg maker ace. it lets you add cheat codes to your game. that is an example cheat that opens iirc pxxnhub.com and pxxn.com π (not x's obviously)
also had that one for lolz
I already host the other bot on that and so far works pretty well, but now I'm working on other one.
any database (except mysql) is reliable if you have a vps
is it including quick.db ?
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
i was looking into sqlite, but paired with sequelize. not sure though, never tried either
not necessarily economy, but postgres
the db you use does not matter. any decent db could be used to store any kind of data ~ within reasonable file sizes
i have economy bot and i am using MongoDB
you see, you don't use a database "for X", you use it as a general storage mean
i also use mongodb, but i think most bots use do use sqlite?
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
fetching the data using mongoose ?
No i am not using mongoose
i am π
I'll look into it
interesting. most of the open source bot code i've seen, and a lot that folks ahve shared here used sqlite.
it's the same case as "the most spoken language in the world is mandarin"
not because it's a popular or good language
but because china has the biggest population in the world
lmao yea i guess thats fair π
most of the bot devs are anonymous small devs that follow some kind of tutorial that suggest either quick.db or mongo
because too many people use quick.db and recommend it to others, increasing SQLite usage (and easy)
yea this is very likely the case
and most use heroku or some other service that doesn't allow file-based storage
if I use quickdb and pull a build on the vps, would it rewrote it or not, because heroku did
so they go for mongo unless using a vps
sorry if I'm kinda confusing with the question
"pull a build"?
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! β€οΈ
it is
imo, no point in using heroku when you can just buy 4core8gb for 5 euro a month
I mean like you fixed some code, and want to replace the old code with the new one
heroku is great for on-demand apis
well, you wouldn't commit the database file
i am renting r9 5950x cpu and 8gb ram for 8 dollars, and their server is nice https://clients.advinservers.com/store/ryzen-vps
yea, things like heroku and didgital ocean are great for whipping up a quick test
hhmmm @ will look into that β€οΈ
crap, i gotta run.. have fun folks π
cya
a vps is just a remote pc
whatever you'd do on your pc you'd do on a vps
Pulseheberg 
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");
cryptographic hash or regular hash? how worried are you about collisions?
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
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
Field titles cant have emojis as long as i remember
what part of embed could have emojis
Uh... they can
π€
can you log the string?
what
and are you sure the bot has perms to UseExternalEmojis?
does that include if bot has administrator ?
yes admin has that
I'm pretty sure the bot has administrator.
hmm try logging the string
how, I'm still new on developing
console.log
very
like no collision acceptable
or well as many combinations as a 64bit int can have
nvm it worked, I put the wrong ID and just find the ID doing \ :emojiname:
u really working on messages while using djs13?
your bot probably doesnt have timeout perms
then you will need something like md5 or sha
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
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.
I see the infamous colors lib
https://snyk.io/blog/open-source-npm-packages-colors-faker/
but it's in history
like even if node-ipc gets fixed will russians ever use it ?
i highly doubt
pretty sure it was already fixed
it is kinda
can I detect in a server, which page the request came from?
?????
A lot of browsers provide the HTTP REFERER and a lot of browsers donβt send it for privacy reasons
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
ok thx
I'm intrigued about the browsers not sending the referrer header due to privacy reasons. Could you cite some references for the same?
If you'd like to verify a request came from your website you can use something called CSRF.
yeah
i have this error
nice error π
client.statusHook = new Discord.WebhookClient("960547863996285018", "jCnqrrHs3G5cEy39NySw2sGYjvjeG5y3pw4ifC1Pj3fInOHSE5Bq_x60VM6vGIs1CxYb")
this is line
yes, and that's a webhook leak
I would like to remind you to not leak your webhook token, even if replaced, it's still on the screenshot
I'm deleting it anyway now
and thx for help
browsers like tor or brave tend to not send the referer (if possible) at least if it doesn't break known websites functionality
β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
So edge cases?
And/or simply edit the default policy yourself or addons (usually) do this job for users
Because all decent and well known browsers, by default, will send the referrer header unless disallowed by policy or attributes.
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)
/* 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
Well we can call it edge cases, yeah
If you read the documentation, the first parameter takes an object with either the ID, URL or token
But you simply can not rely on an accurate referrer, never
new WebhookClient({ token: /* Your webhook token */ });
No matter it's been send with or not
Yep. Can easily be forged and bob's your uncle
Could use CSRF tokens but I don't consider them very secure either
no channel id?
The channel ID isn't required since webhook tokens are only bound to a specific channel
webhooks can be called even if ur not in the guild
that's the danger of exposing them
in v13 you can use like WebhookClient({ id:.., token: ... }) //or url
client.rocoShard = new WebhookClient({ id:962045626135216249, token:74oxOHF6RTJxS4bb7UoGaX_1Ng9LmtzgnHZIlzanIi9XS87GZIitjmIrPGposGMRipJ- })
Leaked your token, you should change that
pass them as strings...
Yes
You need to pass them as strings
The program doesnβt know how to parse your token without it being a string
Ikr
π
Imagine if js allowed strings without quotes somehow
the poor fellow who needs to write the parser for it
I would pity him
I'm sure Tim has some time left, to do the job
Tim scans through every js program ever run, thatβs why heβs so busy all the time
And he benchmarks each app, don't forget about that
Not gonna pay attention
using phone is school
π«
Also I was on lunch break Iβm about to walk back into school
Not using my phone at school
Yet π

I remember the time when phones didn't even were a thing
A time when we beat up other students just to pass the time
@_@

I donβt remember such a time because I was not alive
A time you still was some sort of fluid swimming around
You will learn more about that in school
When NOT using your phone
i have bringed my phone to school like 10 days at least
Don't wanna spoiler anything here
and i get caught by the same guy twice
I use my phone all the time
lol
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)
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
does join not add /
it does
Paths are so scuffed
well nvm then
mkdir is not recursive by default, you need to add recursive: true
Yep, also you don't need to await the mkdirSync() method since it's synchronous
^ an example of a function to copy a file from one dir to another, while recursively creating required directories. uses fs.promises
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?
Just create a bootable USB, plug it into ur PC and boot it
you don't have to do anything else
Are files on my SSD and HDD at risk when doing so?
Like opening a file via my ubuntu operating system?
no
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?
you can access all the drives without an issue
Sweet.
When I boot from the USB, does it work like windows, I have to setup an account, etc?
yeah if i understand correctly
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)
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
16GB is more than enough most of the time. Depends on the OS
Rufus has finished.
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
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
live boot is meant just to test if the OS is compatible with your hardware and if drivers and everything is set up correctly
or to unbrick ur os
Checking disks
Oh.. I could've done that on Rufus.
Aha.
so it doesnt break mid installation due to a corrupted file
nah dont worry it wont touch your files i've done it many times
π
just make sure you distinguish your drives apart
What?
such as when doing things that require modifying the drive make sure you choose the correct drive
"No errors found" thats great.
Which one. ._.
Kind of trying and not demolishing my SSD.
Try
what are you trying to do again
Installing clears your entire SSD
HELL NO.
Make sure to make a backup of ur SSD if you're so worried you'll fuck something up
Well that finished quick.
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
Terminal?
eh I'd use a different distro for a personal computer
gnome π
Yup, I installed it for that. π
Mr. Terminal, have respect
ubuntu's a little bloated
just a little
Why'd you do that?
I'm just checking if I corrupted or lost anything while booting from the USB.
Forgive him lord terminal, for he doesn't know what he says.
For my safety, honestly.
Nah, I won't forget the terminal, the entire purpose was to checkout the terminal, honestly. π
I aint ready to move to Linux either
Checking Linux next.
OH, it's part of Linux. (my bad)
nono, it IS linux
My Discord is bugged.
linux { ubuntu, fedora, redhat, gnome, arch, etc }
Ohh, misunderstanding, I suppose.
I like this Tomorrow at <date> feature.
I really want to switch to Manjaro
wait wtf
Aha?
i have role identified as ```js
const {role} = client.db
.updateGuild(interaction.guild.id)
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
JS, right?
Wouldnβt it be const { logdownRole } or is role an array of roles?
Iβve literally no clue about mongo 
What does client.db.updateGuild(interaction.guild.id) return?
imb4 a promise
i don't have it logged hold on
We can do this the old fashioned way by requiring the model, applying the findOne method, filter, and then function.
I thought his screenshot is the database result log
That's a document.
nope it's my mongO
And the result isnβt just an object representing the document, too?
this is what it returns
Yeah just an object
but like when i do it to see if the feature is enabled it works so idk why it doesn't for the role
okeY
<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.
not gonna lie i've been trying to figure this out for the past 2 days lol

Trying to get the value of lockdownRole?
yep
That's the way above. :)
If you donβt need the entire object just do it as I mentioned
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.
i just need to get the role so it can update the sendMessages permission
Yeah then do what I wrote
Thatβs your solution
pogggg
If you successfully changed my typo ofc
const data = await <Model>.findOne({ id: '954866030327500871' });
console.log(data.lockdownRole);
Fine
This is the most simplest way.
ty for the help qt's
Nope
... for now.
Hopefully you know what to do with <Model>.
Nope you need to respect the context
Replace it with the variable that has a value that leads to the model.
I answered him, though.
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
Ohh.. although, what did he log? role?
role doesnβt exist in his document result but lockdownRole does
Fixed but not in an efficient way. :/
That was his issue
I'm trying to understand what he logged and what returned from the log.
He logged the result of the updating request
*update query
He basically logged await client.db......
What did it return?
In the SS, I see it logged the object with an error down so it's unclear.
Itβs the similar to editing a message in djs which will return the edited message object
Anyways gotta do some work now
the first thing before the error is what it logged
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.
Great, do what I said above. 
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);
His screenshot shows the result of db.updateGuild(β¦) which is the new document
what are good antiraid things?
Dude
Yup, he can now do the above.
Honestly, I've been waiting for my answer in above, so I didn't pay attention. 
My bad on that.
You simply ignored my answers 
evil boy

Alright Iβm out 
Huh Iβm calm just wanted to make sure he reads it this time 
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
Epic embed fail

Itβs a mobile upload
I guess with an unsupported format for the discord client
Therefore no embed?!
Which means:
Epic Voltrex fail
mov formats are supported, something else is wrong with it causing it to not embed
Quiet!
Epic Voltrex fail
Lemme try again
Nope
Funny that Iβm actually uploading a mp4
@earnest phoenix Now explain this, please

There's nothing to explain, it's just client stupidness as it seems
Guys, how can I enable "overflow" by doing "position: flex"?
I'm gonna prove that your car is feature rich yet bug prone to the atomic bombs attached to it
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?
Better a big explosion than this dude
Worst conditions of the entire winter
remove git from the directory or hide it?
search git.decorations.enabled in vscode, and set to false
or disable git entirely with git.enabled
or push your updates π
ye lol
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 ?
thanks
add form method to be POST
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 π
ff
idk, mongoose auto converts my data strcuture names to lower case and such
lmao nice find π
question
alrigh
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 π
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 π
isnt she just... beautiful? β€οΈ
The orange personally isn't me
grey?
looks great imo
a neutral color is better than an opinionated one
or have custom color support
woagh
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
let people generate their own tokens
wouldnt they both send it still if they were in same guild
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
Why would you even be in that situation in the first place??
You can't do this easily
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
The person who is hosting an instance of your bot won't have the same IP as you...
yes so they wont be limited by the requests of bot on my server and can request still
thats why i asked it
So let me get u straight you want to use multiple instances of your bot just to avoid being rate-limited
yes
Then just ask that?? Your original question is so much different
All of the instances need to be able to communicate with each other
use trusted proxies then
IP rotation
Β―_(γ)_/Β―
or just don't do anything cause it's not worth it
ye
Shady. You should just follow the rate-limit and maybe re-think how you're using the data.
yeah i can agree on that
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
probs tls issue
try without tls
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))))```
looks great
whats difference bw a modal and dialog?
no
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
thx. Now it makes sense.
@hybrid cargo ads
@chilly pivot no ads pls, thanks
It's Rick roll
It is a bot invite link which upon inviting the bot redirects to a rickroll on youtube.
Ya
I'm seen some react code like this
<Button>
{(selected) => (
selected ? <span></span> : <span></span>
)}
</Button>
What this method is called
conditional operator
No no, I mean, there is a function as children in Button
how do a function is passed as children, to Button?
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?
thats randomness
yeah, it's generating a random number and checks if it's lower than 10%
sometimes you get lucky sometimes you dont
it is making sense in my head, but it may not be correct
its just how it is
yeah, but it literally always somehow manages to spawn
you could lower the percentage but some users may get very unlucky
Random Numbers in C# - To generate random numbers in C#, use the Next(minValue, MaxValue) method. The parameters are used to set the minimum and maximum values. ...
you know this isprecisely what I'm doing right
doesn't look like it... Random.value?
how to make vote log?
Listen to the webhooks topgg can send you to your endpoint, then use the provided information to go on
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
hello
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
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
Have you seen the senior JS one? 
It's pretty good too.
JJQuery 
I think I enjoyed them all. Fun perspective.
What's the best way to get rid of stack traces in errors
just log the message and not the error? π
but I'm throwing the error
but why would you want that?
The stack's useless for my case
then wrap your call in a try catch?
but obviously you dont need to return the error if you have no need
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
π almost every program i have eats exceptions
bad idea
you kinda have to for discord bot development or you bot stops
Oh hey are we talking about breakfast? π
just make it in a safe way obviously!
run multiple instances of your app and restart when you have uncaught exceptions
otherwise your app is stuck in a bad state
uhhh
I'm making the error myself, I guess I could
console.error(msg);
process.exit(1);
yeah
you wouldn't be able to catch that though, is it always fatal?
You're not supposed to be able to catch the error so that's not a problem
oh okay
i cant help but think of cheese now when i look at your name π
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
you can add something like that that will scream 'im shutting down' whenever that happens
Hello, does anyone know how to check if a user is in a discord server via their ID? (discordjs v13)
nah I just mean by reading the code
return throwError("...") doesn't look as nice as throw new Error(...)
capitalize it so it at least shouts? π
return THROWERROR("...");
i guess 'capitalize' would be the first letter, obviously i mean make all upper case
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
why you exiting the process on error anyway?
cuz it's a fatal error
what is it your working on?
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
ahh ok, i was thinking it was some bot command, and im like ~ why you letting your bot die when a user fks up?! π
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
Okay well doing delete err.stack removes the stack trace
umm
how is message.author.id in slash commands with interaction?
interaction.author.id?
<Interaction>.user.id
ok
ty
When I set this.stack to "" the error message gets wrapped in square brackets π©
If I were to try that on an array of users (to filter the array of members not in a server) would it be the most efficient way?
Yeah
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>.
Make sure roles are enabled in your allowed mentions
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
that has nothing to do with your problem
you didnt define Intents
Intents.FLAGS.GUILD_MEMBERS
^ undefined
For the intent?
Oh wait the permission sorry.
It is. The bot has all permissions.
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
indeed, but i only attempt to safely shutdown when i shutdown the bot. In practice i've never run into the app stopping from some other signal. And yes, the function is created for each signal event, but its really not a huge issue imo π
SIGKILL is sometimes necessary if the other kill signals aren't working
also, you HAVE to handle possible errors from your safety shutdown code or else your app will stay open forever
Yo anyone got a terms of service template or generator for discord bots
yea that seems reasonable π
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?
which one looks nicer?
filenameParts.at(-1)
I think it was standardized last year?
why not just .pop() the extension type off?
14 doesn't support it. Use 16
If you already have an array and don't want to mutate it, .at can be useful
yea thats fair. seems in this case at least though the array is only created to get the extension
maybe nodejs is the current version
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 π
aws cloidformation uses docker too
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"
}
]
[].some(element => element.enabled)
thanks, I'll try that
=> boolean
π <3
find would return the element, some would return boolean if element exists
google cloud is always an option 
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
vercel only supports version 14 of nodejs too
i've been looking through the cloudflare docs and they dont tell what versions they support
https://developers.cloudflare.com/workers/platform/environments/
no serverless wants to support nodejs 16
i found this from aws. it's coming soon...
https://github.com/aws/aws-lambda-base-images/issues/14
π π π π https://nodejs.medium.com/node-js-16-available-now-7f5099a97e70 PLEASE don't wait a year to implement this in a new base image!
lol
can't you just install it manually or something
yeah, you can attach a layer to the lambda to support any version
so you load nodejs twice
Is it possible to fetch the 4th last deleted message in a server?



