#development
1 messages · Page 1180 of 1
Guys who run music bots, how do you deal with the quota limit of the YouTube API?
If you go to the settings of the heroku project, you'll see a button saying Reveal Config Args
click that and add a new arg called token
Okay
I think that's it
hey guys is there a way to get attachment from deleted message?¿
Nah
Im trying to do the dog command but i have this error saying TypeError: Cannot read property 'send' of undefined?
Discord doesn't allow people to view deleted images
Even if you try to go to the link on your regular web browser, you'll get an error
message.content.slice(prefix.length)
// hello foo bar lmao
// gets rid of the prefix
.trim()
// hello foo bar lmao
// removes any whitespace at the start and end
.split(/ +/);
// ["hello", "foo", "bar", "lmao" ]
// splits the string at each space```
@opaque eagle so args[1] should do the job
Yeah
Yeah i see
const fetch = require("node-fetch");
const Discord = require("discord.js");
module.exports = {
name: 'dog',
description: 'This is a random command',
async execute(client, message, args) {
fetch("https://dog.ceo/api/breeds/image/random")
.then(res => res.json())
.then(json => {
let embed = new Discord.MessageEmbed()
.setTitle(`Here is a dog`)
.setImage(json.message)
.setFooter(`Awwww`);
message.channel.send(embed);
console.log(json.message)
console.log(json)
console.log(embed)
})
}
}
Done
Guys who run music bots, how do you deal with the quota limit of the YouTube API?
@mystic tundra I'm breaking my head with this now that my bot is being used by a lot of people
async execute(/* stuff */) {
const res = await fetch("api");
const json = await res.json();
// whatever you want to do with json
}```
@earnest phoenix
@opaque eagle thank you so much sir
Oh
Now i have this error
ReferenceError: Cannot access 'fetch' before initialization
fetch('something'); // ReferenceError
const fetch = require('node-fetch');```
It means you tried using fetch before it was initialized, typically when you try defining a variable then set the value to the same name as it.
Show your code pls
Wait i have this: fetch("https://dog.ceo/api/breeds/image/random")
const Discord = require("discord.js");
module.exports = {
name: 'dog',
description: 'This is a random command',
async execute(client, message, args) {
const res = await fetch("api");
const json = await res.json();
const fetch = require("node-fetch");
fetch("https://dog.ceo/api/breeds/image/random")
.then(res => res.json())
.then(json => {
let embed = new Discord.MessageEmbed()
.setTitle(`Here is a dog`)
.setImage(json.message)
.setFooter(`Awwww`);
message.channel.send(embed);
console.log(json.message)
console.log(json)
console.log(embed)
})
}
}
move your requires to the top of the file
okay
lol i read "oop, salad"
xD
my keyboard has been repeating keys twice for some reason
I think it's my fingers though
TypeError: Only absolute URLs are supported
"api" is not a url
Ohh wait so i have to put a link there?
yes, just like you did with js fetch("https://dog.ceo/api/breeds/image/random") .then(res => res.json())
no, just change "api" to the api's endpoint
const res = await fetch("https://dog.ceo/api/breeds/image/random");
that means message.channel is undefined
How come
So js again
i don't know, how are you calling the execute function?
Async execute?
But I can open a mail by using M?open (clientid)
yes, where do you call this function
hmm
Here?
client.on('message', async message => {
let prefix = db.get(`prefix_${message.guild.id}`)
if (prefix === null) prefix = "h!";
if (!message.content.startsWith(prefix) || message.author.bot) return; //if the content does not start with the prefix or author is a bot
const args = message.content.slice(prefix.length).split(" ");
looking for .execute()
also you can condense ```js
let prefix = db.get(prefix_${message.guild.id})
if (prefix === null) prefix = "h!";
into
```js
let prefix = db.get(`prefix_${message.guild.id}`) || "h!";
if (fs.existsSync(commandFiles)) {
require(`./commands/${command}.js`).execute(message, args);
} else {
message.channel.send("error, not found");
}
this?
yes, notice how you are only passing two variables into the execute function
why have an unknown command error 😩
^
and alos, this is the function header for the dog command:
async execute(client, message, args) {
Oh so i miss out client?
they don't match up
require(`./commands/${command}.js`).execute(message, args);
^^^^^^^ ^^^^^
async execute(client, message, args) {```
@twilit rapids we got a spammer
Oh
👏
if (args[1] === 'ROCK'.toLowerCase){}
dang yall know how to code bots im dumb
hello, can we show classic nitro badge in userinfo?
yes i think this but if he dont use gif?
Hi.
I wanna host my bot on heroku, so I wanna know where to store my discord bot token? I need to fetch it in my .js file on github, but can't really place token in some config file as it's visible to others.
Any help on this?
heroku has an env var section
you add there on site
Well that's cool then. Thanks
@hazy sparrow toLowerCase is a function
oh
is there a way to mathematically determine the winner in rock paper scissors
@earnest phoenix Is it under Settings->config vars?
just use if statements idk
oof
its been awhile but i think so
@misty sigil can we do with API?
you add a key and value
no
yep
okey thank you
and do I need to install heroku package as well in my bot to fetch it?
i thi k you use process.env.VARIABLE
but you might wanna look it up
i javent hosted on heroku in a couple years
I just wanna host somewhere s I don't have to host locally and deal with express 😄
express is really easy
yea...i been going with $5 digital ocean droplets...cuz the free heroku goes to sleep
for development phase sleep is alright
TÜRK VARMI TÜRK ?
Do I have to register bot somewhere as well to get it online?
if(ball === 1){
message.channel.send("Rock! It's a tie!")
}
if(ball === 2){
message.channel.send("Scissors! I will beat you next time...")
}
if(ball === 3){
message.channel.send("Paper! hehehe better luck next time!")
}
}
if(args[1] === 'PAPER'){
if(ball === 1){
message.channel.send("Rock! I will beat you next time...")
}
if(ball === 2){
message.channel.send("Paper! It's a tie!")
}
if(ball === 3){
message.channel.send("Scissors! hehehe better luck next time!")
}}
if(args[1] === "SCISSORS"){
if (ball === 1){
message.channel.send('Rock! hehehe better luck next time')
}
if(ball === 2){
message.channel.send('Paper! I will beat you next time...')
}
if (ball === 3){
message.channel.send("scissors! it's a tie!")
}}
else{
message.channel.send("That's not a valid option! the options are rock/paper/scissiors")```its always running the `else` part
What's ball
i have a question...if i built a website that had discord oauth login option....could i login using any info provided from an active bot?
const ball = Math.floor(Math.random() * (3- 1 + 1) + 1)
and what is args[1]
like use a bot token to be valid auth on my site
and what is
args[1]
@sonic lodgeconst args = message.content.slice(prefix.length).trim().split(/ +/);
No you have to login with an account
ok ty
i'm just assuming args[1] is always going to be rps in your case
isnt rps args[0] or am i missing something?
Do you shift the array?
umm no
const command = args.shift().toLowerCase();
this one?
why do i have undefined here?
it's args[0]
what is the difference between String.slice() and String.split()
@earnest phoenix because you don't set a value for the field
ohh
hmm so if i change it to args[2] will it work fine?
put \u200b
@earnest phoenix .slice returns a string, .split returns an arr
if you want it blank
@hazy sparrow change it to args[0]
okay
if another issue like that comes up again just log args to see what the problem is
okay, ty for the help\
"Hello".slice(1) //ello
"Hello". split ("") //["H", "e", "l", "l", "o"]
But can i leave the value empty?
yes
@earnest phoenix .slice returns a string, .split returns an arr
@golden condor huh then why doesmessage.content.slice("/ /")[1]return the second word of the message instead of the second letter that usually happens in strings
But it will show undefined
Oh okay
But can i leave the value empty?
@earnest phoenix uuse \u200b for blank fields
theres another problem now
it won't show undefined
ohhh
Oh thanks
waot
@golden condor huh then why does
message.content.slice("/ /")[1]return the second word of the message instead of the second letter that usually happens in strings
@earnest phoenix because you used [1]
it does
and slice returns a string
it does

slice returns a string yes
if you do it on an array it returns an array
unless you slice an arr
btw i found a mathematical way to find the winner of a rock paper scissors game:
// 0 = rock, 1 = paper, 2 = scissors
function result(p1, p2) {
if ((p1 + 1) % 3 === p2) {
return 'p2 wins';
} else if (p1 === p2) {
return 'draw';
} else {
return 'p1 wins';
}
}```
ok?
close if statement
in case everyone wanted to condense their massive if statement blocks into one function
My brain hurts
nm
this is my code:
let args = message.content.substring("C-".length).slice("/ /");
// User: C-help doge
args[0] //help
args[1] //doge
I'm Hella confused
if i cba
🚙
nvm i don't use slice in my code it was my dumbass brain who thought i did
i cbt
maybr
that just slices the first two characters
nvm i don't use slice in my code it was my dumbass brain who thought i did
i do use substring tho
Why don't you just slice it I am confused lol
if you still wanna see my code:
Why don't you just slice it I am confused lol
@golden condor the prefix is also included in args[0] and i don't want that
that's my source
maybe that'll help
are you confused with slice and split?
Who have bot list server

İ need bot list
@golden condor the prefix is also included in args[0] and i don't want that
@earnest phoenix use slice? It will still work?
what is the problem
no i mean i need to cut off the prefix from the message before splitting
message.content.slice(2)
bruh why do u have coin miners on your site
just slice or substring and split
no
selling pain for free
My shit about explicit user consent applying...
ok...
@earnest phoenix already have a lot
My shit about explicit user consent applying...
@slender thistle they get the tos thrown at their face now so
if(1) 0
``` solve this
"They use the website therefore they want to mine shit for me"
ah yes
if(1) 0
``` solve this
@earnest phoenix it will run false
no
wait who has miners on their site
just use a normal way of making money
code
0 == false
1 == true
it'll be 0
just use a normal way of making money
@misty sigil what's normal
its just the most braindead code i could think of
which one of you has a bitcoin miner
on their site
i don't have a bank account to get stuff
code
X user can't give consent for user Y
both are separate persons and must give consent by their own fucking will
bitcoin mining in peoples browsers on a bot page is like 10,000 level sped
and it uses less than 10% of cpu at max
bitcoin mining in peoples browsers on a bot page is like 10,000 level sped
@earnest phoenix it's NOT bitcoin
Solve this: ```js
if ("") {
console.log("hi")
}
console.log("no")```
it's mintme.com
crypto currency mining on peoples browser
is just sped overall
Solve this: ```js
if ("") {
console.log("hi")
}console.log("no")```
@sudden geyser undefined
Aka what does it output
"" = undefined
huh
it'll just log no
wrong
discord.js is weird or wut
that's not discord.js
lmao
Run it for yourself
thats vanilla js
mmm vanilla delicious
not all js is discord.js
wait what?
not all js is discord.js
@misty sigil but vice versa
i'd doubt it
hmmm
There is JS code in all JS code
doesnt "" null undefined 0 return false for comparators?
There is some Discord.js library code in JS code
all node* is c++ technically
and c
all js is js
js is js
js
Python is java
yes
doesnt "" null undefined 0 return false for comparators?
@opal plank yeah but there's a trick in the string
no
no python is a snake

python is like c iirc
cpython
ah
Oh
npm docs
Some rules
scroll down twelve lines
Don't put JS in your package name
99% of packages on npm
the heck
wut
why
what the hell is happening
anarchy
Lol

!!"" is false
huh
lemme type smth weird i found today:
indent moment
yeah tell me your life story in #development
you reek of c and python
Mobile
excuses
thats js and python combined
wait c
and python
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}```and im on mobile
thats C
yes now you can put on your resume that you know c
nice
who?
you
ok
well i do know more than that lmao, i can make simple console app on C
and smth
Smth weird happened today I has to parse json twice before it worked
let stringifiedSmth = JSON.stringify("{money: 1000}");
fs.writeFileSync("userData.json",stringifiedSmth);
let readDaFile = fs.readFileSync("userData.json");
console.log(readDaFile); // {"money": 1000}
let parsedSmth = JSON.parse(readDaFile);
console.log(parsedSmth); // undefined
parsedSmth = JSON.parse(readDaFile);
console.log(parsedSmth); // [object Object]
daddy i swear i don't use json for storing user data
for some reason it did that
is that a json db
@misty sigil smth I'm working on for my package configs only
cuz
sqlite
for configs
ewww
ummmmm json should only be used to store static data
tell me about it lmao
or a database

even configs are good to be stored in database
say you got other bot instances, you can keep them all sync'd that way
In the past I met someone who made their database by having a raw text file but structuring it like a database
so they wrote a database raw which was kinda impressive
life
or use a proper databse lol
https://pastebin.com/W4G6qHEd
the problem is only with PAPER
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
its not a bad idea ngl, but stilll its better to use real one
Why are you assigning in the if condition? if(condition2 = args[0] === 'PAPER'){
Everything about that code hurts me
start using switch @hazy sparrow
@hazy sparrow use to lowercase for your own sake
@opal plank not very important for now eh
and lowerCase()
it is
if someone types Scissors it wont match
or scissors
neither will work cuz its perfect matching
thats not the problem
const ball = Math.floor(Math.random() * (3- 1 + 1) + 1)
@hazy sparrow I think the issue is in your last statement: else if(!condition1 || condition2 || condition3){
You only check if the first condition is negated. Are the other two supposed to also not be negated?
The amount of repeated code
@golden condor😅
You could chop down a lot of your code to make it more readable and understandable with some refractors.
@hazy sparrow I think the issue is in your last statement:
else if(!condition1 || condition2 || condition3){You only check if the first condition is negated. Are the other two supposed to also not be negated?
@sudden geyser yup. other two are also supposed to
this triggers me so much im about to spoonfeed him
The spoon is the sea and you're in the middle
Get out of sea before you're forever lost
...
this triggers me so much im about to spoonfeed him
@opal plank i'll appreciate it very much thank you
yup. other two are also supposed to
@hazy sparrow so try negating them with the not (!) operator
I don't know, maybe it's because paper is in the middle and also has to go through condition3 with the || operator
@hazy sparrow so try negating them with the not (
!) operator
@sudden geyser so!condition1 || !condition2 || !condition3)?
yes
Yeah try it and see if it works
hmm in that case it didnt work. now rock and paper has that problem but not scissors
Try replacing || OR with && AND
hmm ok lemme try that
Also:
const _matchups = {
"paper": "rock",
"rock": "scissors",
"scissors": "paper"
}
const playerChoice = firstArg.toLowerCase();
const botChoice = ...;
if (_matchups[playerChoice] === botChoice) {
// the player wins
} else if (playerChoice === botChoice) {
// draw
} else {
// bot wins
}
Here's how I would to RPC. Before you say this is spoonfeeding it's not
Try replacing
||OR with&&AND
@sudden geyser it worked
good
but you should try polishing your code and how the game works like the others said
yea i'll try to remove some code
Also:
const _matchups = { "paper": "rock", "rock": "scissors", "scissors": "paper" } const playerChoice = firstArg.toLowerCase(); const botChoice = ...; if (_matchups[playerChoice] === botChoice) { // the player wins } else if (playerChoice === botChoice) { // draw } else { // bot wins }Here's how I would to RPC. Before you say this is spoonfeeding it's not
@cinder patio it's that simple??
yea
yup
oh my word
might have to go with if's
cant think of a clever way to premeditate the result comparators without if's
that space before default 
You may also not want to initialize the balls and values array every time the function is called
kk
the function should only be called once
once everytime someone uses the command
oh i see what you mean
good catch
i hate to do this but i think i'll have to run if's to check result
GOD i have still learn lots
like i said, rn i cant think of a clever way to check results before hand without if'ing the fuck out it
wtf he fixed the space
it only was like that cuz i didnt press save
Really it's not too difficult. One way that comes to my mind is a dictionary way: ```js
let choices = {
rock: { name: "rock", losesTo: "paper" },
paper: { name: "paper", losesTo: "scissors" },
scissors: { name: "scissors", losesTo: "rock" }
};
let botChoice = choices[Math.floor(Math.random() * 3)]
let userChoice = choices[content.toLowerCase()] // Handle other stuff later
if (userChoice === botChoice) {
// ...
} else if (userChoice.losesTo === botChoice.name) {
// ...
} else {
// ...
}```
I don't know if this works but it's the basics
#development message only 2 ifs in my solution
It's like 3 conditions
Ifs are definitely better than switch cases here
cant disagree with that
why are you guys spoonfeeding me im not that noob 😭
Lol
nah, it's just fun to come up with other solutions
Use random module ez
my code looks like trash looking to your solutions
Make it better then
@earnest phoenix yea ofc
Good
problem solved
others servers will be like "oMg gO lEaRn sOmE bAsIc jAvAsCrIpT"
Rock paper scissors without ifs / switches:
const _matchups = {
"paper": "rock",
"rock": "scissors",
"scissors": "paper"
}
const _results = {
false: () => { console.log("Bot wins!"); return true},
true: () => { console.log("Player wins!"); return true},
"draw": () => {console.log("It's a draw");}
}
const playerChoice = "scissors";
const botChoice = "rock";
_results[
_matchups[playerChoice] === botChoice ||
(playerChoice === botChoice && "draw") || false]()
lmfao
that worries me
good shit indeed
When docker runs yarn install in the second stage, it says it can't find git... how does it work in the first stage but not in the second, if both use the same base image?```
FROM node:alpine as build
WORKDIR /app
COPY . .
RUN yarn install && yarn build
FROM node:alpine
WORKDIR /app
COPY --from=build /app/dist /app/dist
COPY --from=build /app/package.json /app
ENV NODE_ENV production
RUN yarn install
CMD ["yarn", "start"]```
install git
But it works in the first stage though
And they both use node:alpine as their base image
Where can i get the API links for discord.js?
Im not sure which one is the good site to get since im new to discord.js api
API links? the docs are at https://discord.js.org
Hmm under which section
documentation section
bruh nvm

API links? the docs are at https://discord.js.org
@opaque eagle I think she means the Discord API URLs to hit the routes directly
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Probably there ^
wait is that that short?!
i always wrote https://discord.com/developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Lmao
i always did https://discordapi.com/
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Why do they keep so many domains
makes no sense
why not just discord.com and discord.dev
so much simpler
doesnt really matter
@opaque eagle do you have a node package that's straight from git?
Does anyone know how can I receive data in Javascript sent from Python via Flask
A webserver?
Open a web socket and send json to it?
Or even better, a proper API
APIs can let separate languages talk to each other @earnest phoenix
I just want to list my registered users on a table that's all is it worth creating an API
store data in a file
read it
ez
oh flask
I have no experience in creating apis
flask is for application servers
👀
i guess
Problem is I get data like [123,1,1,1] so writing and reading from a file would not be easy
use json format
Or idk split via commas i dunno
It comes as json I tried getting the data with Jinja as {{data}}
How does one get a guild ping and the discord.js lib ping? In d.js
What do you mean by guild ping? You could get your client's ping (ws: <Client>.ws.ping)
I need like a server ping
It comes as json I tried getting the data with Jinja as {{data}}
@earnest phoenix u using js to work on that data?
Some servers take longer to message than others sometimes I find
Would sending an API request that's based on a guild's endpoint satisfy? For example, sending a message in a guild.
whats ur problem exactly @earnest phoenix
Yes
Then do something like this:
let start = Date.now();
/* ... send the message ... */
let ms = Date.now() - start;```
That's how long it took for the promise to return, which is how long it took to send the HTTP request.
x = listMembers() (which returns a list of members as multiple json objects: [{(),(),(),()}, {(),(),(),()},{(),(),(),()},{(),(),(),()},{(),(),(),()}]
I am sending this from Flask as members = x
I now want to use x on javascript which x can be accessed with {{x}} on html that prints out all members
I want to get it as a js variable so I can create a for loop and process that variable for my needs
||@earnest phoenix||
I get this error when I try to use node-fetch on an endpoint
TypeError: Request with GET/HEAD method cannot have body
First of all, I'm not dumb, I can read what that says. I'm just wondering how I can bypass it.
- The official RFC specs for REST requests doesn't say that GET requests can't have a body.
- I wrote the API I'm trying to fetch. That endpoint will look for the request body.
- It worked fine in curl.
That being said, how can I bypass that error?
Please ping me on reply
ohh
Huh
i still dont get it tho
Json objects???
Are they normal js ones
y dont u store the data in a json file
and read it
me?
me
oh nvm
Thanks
Huh
ima sleep ig
@earnest phoenix dm me . maybe i can help u
Or
I will if I need thanks
Just help in here
We'll fix your errors, if any
ye
I found a cheap little trick in js
can we have patents on applications ?

wdym
also here's the trick:
types
nvm
what do you mean code9
@opaque eagle try and see if axios supports it, also i recommend using post for requests with a body
numpy is a very good module
Patenting a discord bot? 😂
ye
lol
eval can use template strings so you can do specific stuff using user input by using ${}
var (varName) = (varValue); // won't work
eval(`var ${varName} = ${varValue}`); // does work
It is really useful
I can fetch specific properties from specific objects

using eval is bad practice
Also let & const > var
well yes it works like a normal function would
@pale vessel you need a brain to understand it
@sudden geyser if its not locked to owners only then sure
isolated vm + sandbox 😎
yeah but even there it's still looked down upon
Wdym
You cant bypass an id check
@sudden geyser if its not locked to owners only then sure
@earnest phoenix and it certainly isn't locked to discord bots only i use it in my custom database library i am working on
????????
yep
it was useful for me
as in using eval() in general is still looked down upon
heck my own kinda-useless npm package came handy for me
@sudden geyser its actually sometimes useful for me
me too
eval is so cool
like what, dynamically evaluating some code as a string?
Only i can use it so im good
it is literally a necessity for my database package
Say debugging an issue with music queue s
like what, dynamically evaluating some code as a string?
@sudden geyser imagine fetching a specific value from objectxbased on user input
Wait wait
just don't do stupid things and it'll actually be useful
eval > 100 if statements
You use eval to handle user input
can my message be starred lol
Oh my fucking god
Oh my fucking god
@earnest phoenix stop swearing to god
code913 you managed to set off the #1 issue with using eval
^

Is your bot here?
that English
is too hard
Let me break it
Is your bot here?
@earnest phoenix definitely not
I can fuck your bot in under 5 mins
code913 you managed to set off the #1 issue with using eval
@sudden geyser i 👏 don't 👏 use it 👏 for 👏 bots
Anyway how is the example you gave useful though? https://canary.discordapp.com/channels/264445053596991498/272764566411149314/747153595077492776
You still need to know the name of the variable to use it.
You just said you did
I can fuck your bot in under 5 mins
@earnest phoenix there is no eval command
It's not limited to bots. It's limited to programming
^
math command as eval in disguise 
big brain
Lol
yes
whwre
on Google
why are you asking that here lmao
Search on Google "discord bot list"
ah yes, dbl as the first result
did a few loops and returned back to where you started
Anyway how is the example you gave useful though? https://canary.discordapp.com/channels/264445053596991498/272764566411149314/747153595077492776
You still need to know the name of the variable to use it.
@sudden geyser what about a whole database package that uses better-sqlite3 to make a complex database where you can do shenanigans and it all works on the principle that i set specific values based on the values provided in a function and the eval command does the stuff i won't be able to do with normal javascript
Oh god
@earnest phoenix pls just stop ive seen u give terrible advice and even worse programming practices

I have no idea what you said since I'd need to see your code base where eval is helpful but I can only think of a few scenarios where eval can be used. In general, it's good practice to avoid using eval unless you absolutely have to.
Just search up "Eval is evil" on Google for research
I never use eval other in my eval command
emphasis on unless you absolutely have to cuz i have to
Let me correct that:
"unless you ABSOLUTELY have to"
what the fuck is going on in any case
We're talking about eval and when to use it
im out
Lmao
why didn't my bot respond
you forgot the slash
fork bomb moment
Lmao
btw, i was just lying, that hack actually works. you can thank me later once your server is auto-boosted to level 3
why
Can anybody guide me on, How to record everything from a voice channel?
👀
monkaw
keeping user data is likely against tos
monkatos
What are you trying to implement?
im really unsure how much of a greyline is recording voice chat
man i cant figure this out....im trying to grab a random message from a channel to use as a quote but my channel.messages Map is empty?
I don't trust the actual zoom app from taking good care of my data
It's probably not cached
do you trust keybase?
I don't use keybase
good
I got rid of my account a week or two before the acquisition
im grabbing the correct channel...all the data is correct...just no messages
fetch()
^
I want to record from the voice channel. And it would be only for one personal server
use mee6 or something
What language are you using
i tried fetch...fetchMessages
probabyl a bad idea unless user gave consent
get
nodejs
d.js?
yes
the object is empty
voice receive moment
Map is 0
can bots even recieve audio?
havent played with audio
It is for education purposes
kappa
@earnest phoenix your bot only stores messages sent after your bot starts. Older messages are not available unless you request them from discord using fetch. You can only fetch a maxinun of 100 messages at a time
so u can save it as mp3
Plus there are storage limits for messages, the default in discord.js being 200 messages per channel, after which older messages start getting deleted from the cache
so i need to fetch from cache for older messages?
These limits can be customized
I've tried to install Canvacord for something and I get a error when I try to run my bot
PS C:\Users\Jon\Desktop\LvlBot> node .
C:\Users\Jon\Desktop\LvlBot\node_modules\canvacord\src\Canvas.js:25
throw new Error(`The class ${this.constructor.name} may not be instantiated!`);
^
Error: The class Canvacord may not be instantiated!```
Code
```js
const Discord = require('discord.js')
const client = new Discord.Client()
const setup = require('./setup.json');
const fs = require('fs')
const Canvacord = require('canvacord')
const canvas = new Canvacord()
const ms = require('ms')
const db = require('quick.db')
const { TOKEN, PREFIX } = require('./setup.json');
client.login(setup.TOKEN)
client.on('ready', (ready) => {
console.log(`${client.user.tag} is online!`)
})```
Oki. Thanks
sad ngl
@sudden geyser @opaque eagle @opal plank Let's not post malicious snippets of code that could potentially harm clueless users 👀
big sad
i DID put a ps after it though
gullible people gang
I've gotten a new error now, Without the new
TypeError: Class constructor Canvacord cannot be invoked without 'new'```
I assume it's supposed to be a class used statically
so the discord.net gh repo tells us to use Discord.Commands instead of hard coding a command handler. Is that true?
@still merlin just Canvacord
Okay thanks
@slender thistle alright, my bad

i need me that emote
so the discord.net gh repo tells us to use Discord.Commands instead of hard coding a command handler. Is that true?
@tight plinth yeah
It has a Register commands async function
Which will search for functions that start with the attribute [Command()]
If you want to see how I did it, my project is public
when you type # or @ in the discord text input box there is an autocomplete that pops up. is there a way to use our own prefix to create a custom autocomplete?
Are you talking about mentions and channels?
@faint prism yes
so whats the correct way to grab old messages const channel = swcbot.guilds.get(msg.guild.id).channels.find(channel => channel.name === 'swc_chat'); const msgs = channel.messages.cache.fetch();
I don't think so. That's a discord client side thing
is not working
@faint prism dang, thanks
im getting channel just cant figure out grabbing old messages
Isn't it Download Messages or something
but get() only works on cache
hence why you fetch if its not cached
if(!cache.has(something)) fetch(something)
im using get to grab channel and its grabbing the channel
so theres a discord rest api or something i can fetch from? ill check that out
so theres a discord rest api or something i can fetch from? ill check that out
@earnest phoenix yeah that's what the library handles for you. It probably has what you're looking for in it, but you could always just make the call directly to discord API
cool tyvm
fetch from discord if you want quicko updates
cache doesn't store everything
laughs in redis
redis?????
yup
go with redis
buy a vps with alot of ram, and another with alot of cpu power
higher end we get into a problem without caching and doing that many requests
imagine doing 140+ calls per second
if you werent caching stuff
Always flexing your grafana stats
nah this is some next tier flexing shit
im literally pulling 50% of twitchs global viewers
and its using 8% of the hosts cpu
EIGHT FUCKING PERCENT
thats 1.7 mil viewers there talking
is there a rate limit to fetching
f
@proven lantern i did not, my bot is more focused for streamers/twitch users
its too unique
that means discord.js-light is an almost useless thing
fetching everything = rate limits
caching nothing = hey tim you're cute
It just doesn't cache everything that you don't need
This library solves the problem by giving developers full control over how and when discord.js should cache the data it receives from the API.
alright
It doesn't say anywhere that it will fetch automatically
I'll just cache everything
¯\_(ツ)_/¯
but have a setInterval function clear the cache every hour
so it deletes the unnecessary stuff
and starts caching whatever discord users and guilds and stuff do
why
using 0.2% of the mem of this host
IS IT JUST MY HOST
what do you think is the best tutorial online to learn mongoose
i seriously need to stop using sqlite
prob docs
lmfao
im using postgres so i cant help with mongo
thats my preference when it comes to db
The name is SO WEIRD
this is a good starting point for mongo
https://api.mongodb.com/
huh
this is a good starting point for mongo
https://api.mongodb.com/
@proven lantern ok I'll read it

https://ptb.discordapp.com/channels/264445053596991498/272764566411149314/747166978329935892
@opal plank are you guys unable to quote messages or what
im just edgy
why am I having such a hard time finding the api endpoints?
i found the root request
which?
for discord lol
no shit
yea i cant find endpoint
i need to grab all messages from a channel..i have channel id
thats under channel
so just channel?id=id
ty
M

hi
anyone know what this means
This application has been inorganically grown, so we cannot accept your application for verification at this time.
or aka
Validation errors:
This application has been inorganically grown, so we cannot accept your application for verification at this time.
your bot is in too many servers that have the same owner
oh great
that guy again
someone keeps adding it to 8 servers :(
how do i verify now e.e
your bot is in too many servers that have the same owner
Not exactly, it just grew to fast for "normal" standards and thus has been flagged
oh
lol
i shouted it out on a 3.5 k server
:)

what do i do now?
hello ?

you wait™️
So I'm trying to get my bot set up with sharding... (Discord.js 12.3.1)
I'm using the Sharding Manager and all is working fine, but I want the shards to connect to my (Maria) DB with a different user each. Any ideas on how I could achieve that?
Why would you need to connect with different users?
sweet i got it all working...now i show a random quote from channel in help embed footer
couldnt get the embed Objects to work though..had to make my own { embed: {}}
object and send that
Why would you need to connect with different users?
Wont there be problems when I'm trying to establish multiple concurrent connections with the same credentials?
@blazing portal I'm using MongoDB and it works with the concurrent connections
So I'd assume it'd work
How many connections do you have?
2 (shards / connections)
Well that's not many yet. It may work for 2, but I don't want to have to go back to this later and change it again...
But good to know anyway. thanks
Databases are good at handling 'simultaneous' accesses by multiple connections to the same table.
It'll be fine lul
yes i know databases handle concurrency with ease, but afaik not by the same user
I'd assume they'd handle that too
Because in an app you're gonna have multiple read/writes going on at the same time, probably from the same user
Yeah i guess you're right
MongoDB shell
What would be the proper way to replace 2 fields in all documents in a collection?
Or, rather, is it possible? I have an option to write a Python script without a problem, but I'm wondering whether that's possible with pure MongoDB shell.
This was not my friends DM 
definetly not possibly an exploit, nothing to worry about
module.exports= {
name: 'ban',
category: 'moderation',
description: 'ban members',
run: //my code
}```
This is my ban.js
I want in the help.js file to get the description and category, how do I get this?
(javascript)
can you give me an example?
assuming you mapped it somewhere, just send that map to your help.js as param
it depends on how you got your stuff setup
const Discord = require("discord.js");
const {readdirSync} = require('fs');
module.exports = {
name: 'help',
category: 'nutzvoll',
description: 'Zeigt dir Hilfe',
run: async(client,message,args,guild) => {
var c = readdirSync(`./commands/`)
console.log(c)
if (args == 'ban') {
readdirSync("./commands/").forEach(dir => {
const cmd = readdirSync(`./commands/${dir}/`).filter(file => file.name == args + '.js');
console.log(cmd.name)
return
})
}
}
}```
idk how you mapping your commands
this is my help.js
cool but it doesnt answer my question
how you mapping your commands?
cuz you'd need it on index
actually
nah that might work
usually you'd do on it your index
so you arent reading dirs on every command call
but anyway
You've got me stumped
you should require() that module with the command name
why my laptop can't connect to my new vps \
everytime you run !help it'll read the dir, there isnt a need for that
you likely have your commands mapped on your index
cuz otherwise what would be the point of dynamically organizing them like that
const {readdirSync} = require('fs');
const ascii = require('ascii-table'); // npm install ascii table
// If you want you can not add it and do a normal CommandHandler, I have this simply for aesthetics
let table = new ascii("Commands");
table.setHeading('Command', 'Load status');
module.exports = (client) => {
readdirSync("./commands/").forEach(dir => {
const commands = readdirSync(`./commands/${dir}/`).filter(file => file.endsWith('.js'));
for(let file of commands) {
let pull = require(`../commands/${dir}/${file}`);
if(pull.name) {
client.commands.set(pull.name, pull);
table.addRow(file, '✅')
} else {
table.addRow(file, '❌')
continue;
} if(pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
}
})
console.log(table.toString());
}```
can someone help
is it a linux vps?
yes
putty
you cant use rdp
bruh
exactly the same way you doing this
thats for windows pcs/vps
but my vps have window
exactly the same way you doing this
@opal plank ah thanks
im assuming you copied that code from somewhere
my friend help me install it
@hushed axle bruh you just said it was linux


oh sorry i dont do windows vps
how do I install linux
im as lost as new d.js users here
theres a fuckton of stuff to do tho
tmux, nano, ls, cd(which im used to)
terminals are wanky
all that shit is new territory for me
you wait™️
@thick gull hoe much do i have to wait usually?
terminals are wanky
@opal plank same but once you learn some basic commands they get friendlier
I don't know
1 week like?
Ask here
discord.gg/discord-developers
like remember that one time you opened the command prompt and was like "what is this black screen of death"
ok
like remember that one time you opened the command prompt and was like "what is this black screen of death"
no that happened when I got a virus
im used to powershell and cmd, but theres so much new stuff when you jump into linux its overwhelming at first glance
And it opened prompt
Is this helpful Erwin? https://launchschool.com/books/command_line/read/introduction
Launch School - Introduction to the Command Line
(text)[link] or vice versa?
Thanks
thats a bit too basic for what im used to but i'll take a look
oh theres more
perfect
yeah that does the trick @sudden geyser
It took me about half a day to read but yeah it should do
How do i do the effect of typing in discord js v12? ??
@meager whale check pins in #support
ok thx
-helptest
We aren't a server full of guinea pigs, and are not obligated help you with features that can easily be tested with alts or friends. If you don't have either - at least you can make alts without problems.
what is it
i just set up a db and started saving messages before bot sends them....so i have a proper history to pull from now










let me show you