#development
1 messages · Page 994 of 1
again, console log those two variables i stated before
try this command and see the output, on a test command or on that one
what command?
translate.getText('esto es una prueba',{to: 'en'}).then(function(text){
console.log(text)
});
either a eval or a test command
then its the to:'en' part
its likely 'en-US' not 'en'
try this
console.log(text)
});```
my bad, theres a space
@_@
i literally just copy + pasted.
one sec
?
space, where?
to: 'en' =/= to:'en'
in the previous snippet i gave you i did not put space in between
i don't think it would make a difference lol.
me neither but idk how their parser works
are you awaiting it?
do it
ah sh.
someone can help my discord to grow up???
oof
@slender birch add the bot to the page and hope its unique enought to get attraction
its not an easy feat, mine is unique yet doesnt get enough discovery to go up
thanks for your help
ive got ~50 guilds in 3-4 weeks
@opal plank, i want to make my bot unique.
mine is at 33 currently
but as you can see, a lot of competence.
mine has features that no other bot has, yet its still very small to get recommended around
i am at 25
@steep garnet why not use a different API?
advertising is annoying, i dislike going around asking people to try it
mine just 2.
add some way to reward voting. its more likely to get added with more votes
@pure lion, bc the other one is worst.
I'm at 31
i already got that in place for the minigames
@steep garnet it's not? How is it worse?
i had also a good start. the First server that used my bot got 10k users
mah, it throws the same error all the time.
Oooo nice
they are getting the same error regardless of the api, told me to await the promise
anyway @opal plank, where do i actually put the await?
mah, it throws the same error all the time.
@steep garnet I'll link an NPM
you need to make it async first
^
on... the promise
client.on('message', async () {} )
async func() Something {
await //ur stuff
}
ye, i knew where to put it.
then you can run is sequentially
did you await the promise?
:|
you only added async from what i saw
ah sh, here we go again.
they are getting the same error regardless of the api, told me to await the promise
await can only be used in async
you added async, add await on the promise now
:(
spoonfeeding
to put it simply
this code should output a number from 1-6, but instead its outputing the code itself
sync code cannot wait for async code or wait for promises with .then
async code can wait for sync code but cannot wait for promises .then
promises with .then can wait for async and sync iirc
mhm.
you have absolutely no idea what i just said, do you?
:(
ugh, fine, heres an example, learn from it
idk why i'm here in first place.
let something = await translate.getText(textToTranslate, (to: langToTranslate))
console.log(something)
we arent suppose to spoonfeed you
spoonfeeding only creates vampires
lmao.
aka you come back next time you get stuck
perfect, next task.
sync and async code blocks
@steep garnet read this later https://scotch.io/courses/10-need-to-know-javascript-concepts/callbacks-promises-and-async
ty so much. 👍
np
can someone help me
let cmd = client.commands.get(command)
try {
delete require.cache[require.resolve(`../../commands/${cmd.category}/${commandfile}Command.js`)]
client.commands.delete(command)
const pull = require(`../../commands/${cmd.category}/${commandfile}Command.js`)
client.commands.set(cmd.name, pull);
cmd.aliases.forEach((alias) => {
client.aliases.set(alias, pull);
});
} catch(e) {
console.log(e)
}
message.channel.send({embed: {
color: client.color,
description:`The command \`${args[0].toUpperCase()}\` has been reloaded!`
}})``` creating a reload command, returns command is reloaded but in teh message event command.run is not a function only for that command specifically..
const client = new Discord.Client();
client.on("ready", () => {
console.log("I am ready!");
});
const rollDice = () => Math.floor(Math.random() * 6) + 1
const prefix = "bow";
client.on("message", (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
if (!message.content.startsWith(prefix)) return;
if (message.content.startsWith(prefix + "ping")) {
message.channel.send("pong");
} else
if (message.content.startsWith(prefix + "foo")) {
message.channel.send("bar!");
} else
if(message.content.startsWith(prefix + "roll")); {
message.channel.send("rolled a" + rollDice);
}
});
each command here executes "rolled a = () => Math.floor(Math.random() * 6) + 1"
for some reason
probably gotta remove the ; on this line:
if(message.content.startsWith(prefix + "roll")); {
ok ill test that
@idle mountain it works (thx) but the roll comand executes "rolled a = () => Math.floor(Math.random() * 6) + 1"
instead of a number from 1 to 6
How to make our bot display the number of servers where it is present ????
Is there a way to periodically log a value into quick.db, e.g:
(User side) !disable (command name)
(Table name = command name blacklist)
*Add guild id to DB*
A different server:
!disable (same command)
Unsure if it would overwrite, and how I would write correctly
Fox, wants your lib?
Yes but i didn't find
What is your library
discord.js
Thanks
Np
some1 know why my discord bot token is changing all the time?
you mean when you refresh the page?
yes
it refreshes every time you refresh the page, that's normal
old tokens will still work until you click regenerate
the problem is that it doesnt work
then there's a different problem in your code
it's showing unauthorized?
click regenerate and try again
part of the token hash is a timestamp of when it's generated, so there's a different token for every second (or millisecond)
<rejected> Error [TOKEN_INVALID]: An invalid token was provided.
at Client.login (/home/runner/gfdsgfds/node_modules/discord.js/src/client/Client.js:204:52)
at /home/runner/gfdsgfds/index.js:36:8
at Script.runInContext (vm.js:131:20)
at Object.<anonymous> (/run_dir/interp.js:156:20)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
[Symbol(code)]: 'TOKEN_INVALID'
}
}```
i have the token in an .env file like this: "token=token"
and then i have in the main code: client.login(process.env.token);
its all ok but it doesnt work
try using the new token
Try console logging your token and see if its the correct one
Try console logging your token and see if its the correct one
@haughty night i did it but it didnt log it in. It throws that message in console:
oops
its too large
im not a professional but i know what i do
Did you do console.log(process.env.token)?
yes
And the error is in that text file?
Gotta grab my pc then, my phone doesnt want to open the file
in that text file is the message it throws on the console when i do console.log(process.env.token)
i cant now wait pls
@dusky mist That file looks more like you consoled logged your client
Like console.log(client)
That is the response you would get when console logging your client
@haughty night i just changed in client.login() the process.env.token for the real token, now it doesnt throws an error but it doesnt work
When I try to push a guild ID in my quick.db, it returns 'target is not an array'. How would I fix this?
I was just about to ask if you could do that
Uuuh so
Try regenerating the token and try again
Nice, so the problem lies with the env
How does your .env look like
Can show me, without the token ofcourse
yes ofc
its just like this: "token=token"
client.login(process.env.token)
yes
recommendation, use a json file
do this token=token without the ""
the problem is that i use repl.it and the project is public
if i do it in json file ppl could know my token
do this token=token without the ""
ok
why not simply exclude json from the list?
i also have github for example, you can exclude specific files from being shared
how can i do that?
.gitignore
do this token=token without the ""
it throws an error but its tiner than the other one
What does the error show
<rejected> Error [TOKEN_INVALID]: An invalid token was provided.
at Client.login (/home/runner/gfdsgfds/node_modules/discord.js/src/client/Client.js:204:52)
at /home/runner/gfdsgfds/index.js:33:8
at Script.runInContext (vm.js:131:20)
Hint: hit control+c anytime to enter REPL.
Promise { <pending> }```
@steel wedge repeating the same question within 5 mins wont help you much
its the same error
but the other one was larger
i dont rlly know whats happening
i will try do: token="token"
its expecting a string
client.login('someStringyTokenHere')
doing client.login(SomeStringyTokenHere) wont work
hey it worked without ""
let token = process.env.token
client.login(token)
in .env it doesnt need ""
whats the most simple way to execute a random number between X and Y
Error: Cannot find module '../../commands/undefined/HelpCommand.js'
``` i tried console logging it and it returns the right category
```js
console.log(client.commands.get(command).category)
onst category = client.commands.get(command).category
const pull = require(`../../commands/${category}/${commandfile}Command.js`)```
full code: ```js
try {
console.log(client.commands.get(command).category)
const category = client.commands.get(command).category
const pull = require(`../../commands/${category}/${commandfile}Command.js`)
delete require.cache
client.commands.delete(command)
client.commands.set(args[0].toLowerCase(), pull);
let cmd = client.commands.get(args[0].toLowerCase());
if(cmd.aliases === undefined) {
} else {
cmd.aliases.forEach((alias) => {
client.aliases.set(alias, pull);
});
}
} catch(e) {
console.log(e)
}
console.log('xd')
message.channel.send({embed: {
color: client.color,
description:`The command \`${args[0].toUpperCase()}\` has been reloaded!`
}})
```
undefined
undefined category
no no
category
when i log it
it returns utility
soo ye
@restive furnace @opal plank
can someone help me?
i dontk now then
Math.floor(Math.random() * X) + Y
ill try that brb
will that even work?
When I try to push a guild ID in my quick.db, it returns 'target is not an array'. How would I fix this?
so no one can help
x = 10
y = 20
math.floor(0.1 * 10) + 20
well, im too sleepy for coding now
cya'll o/
ok cya
its always giving 6
(Math.random() * rand2) + rand1
@pure lion it but rand2 as 6 and rand1 as 1
its always giving 6
rand 1 = 1 rand2 = 6
np
Hello i want to create a dashboard for my bot. Do you have a site for me ?
@hazy sparrow
Well my bad, Math.floor(Math.random() * (max- min + 1) + min)
Hello i want to create a dashboard for my bot. Do you have a site for me ?
@earnest phoenix uhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
I have this convo if it helps
Well my bad, Math.floor(Math.random() * (max- min + 1) + min)
@haughty night it works, tysm
no worries
btw
when i try to log something in my quickdb, it shows that its in an array (```js
[ { ID: "GuildID'S", data: [ '710964023117479966' ] } ]
```cmd
TypeError: Target is not an array.
help
is the field you want to send data to a field that allows arrays?
disabledSnipeDB.push('GuildID\'S', msg.guild.id)
try ``` disabledSnipeDB.push('GuildID'S', [msg.guild.id])
Okay thx
is there a way to make a bot online and run without the command window running?
idk never used quickdb. cant help you that much with it
@hazy sparrow what language?
linux or windows?
Error: Connection reset by peer
at Shard._onWSClose (C:\Users\callu\TutorialBot\node_modules\eris\lib\gateway\Shard.js:1853:23)
at WebSocket.emit (events.js:315:20)
at WebSocket.emitClose (C:\Users\callu\TutorialBot\node_modules\ws\lib\websocket.js:194:10)
at Receiver.receiverOnFinish (C:\Users\callu\TutorialBot\node_modules\ws\lib\websocket.js:790:20)
at Receiver.emit (events.js:315:20)
at finish (_stream_writable.js:645:10)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on Client instance at:
at Shard.emit (C:\Users\callu\TutorialBot\node_modules\eris\lib\gateway\Shard.js:2111:26)
at Shard.disconnect (C:\Users\callu\TutorialBot\node_modules\eris\lib\gateway\Shard.js:118:18)
at Shard._onWSClose (C:\Users\callu\TutorialBot\node_modules\eris\lib\gateway\Shard.js:1863:14)
at WebSocket.emit (events.js:315:20)
[... lines matching original stack trace ...]
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
code: 1006
}```Hi I keep getting this error with eris and I don't know how to fix it (I think it is from discord resetting the connection) does anyone know how to fix it/handle it?
I agree
either use Docker (requires Windows 10 Pro) or start it as a service
ok can i start it as a service in windows 7
its possible but i cant tell you how. i use linux
@golden condor server/sharding issue?
Is there anyway to handle the Connection reset by peer error or to fix it
ok that helps ty
you can set a timeout and reconnect
server/sharding issue?
I'm not sure, I've been getting this error with all my bots in eris
Hmmmm
did you run it from your PC or a Server?
^
me?
nope
ok
did you run it from your PC or a Server?
@lusty quest my pc
its possible your connection cant handle it
But I get the same issues on a server
Ok
client.on("debug", console.log) ?
undefined 1593163708678 /gateway 200: 138ms (463ms avg) | 1/1 left | Reset 1593163708678 (0ms left)
{"op":2,"d":{"token":"MY TOKEN HERE","v":6,"compress":false,"large_threshold":250,"guild_subscriptions":true,"properties":{"os":"win32","browser":"Eris","device":"Eris"},"presence":{"game":null,"status":"offline"}}} 0
{"op":1,"d":0} 0
The bot is ready!
{"op":1,"d":4} 0```
seems to login
maybe a memory leak
or some sort of rate limit
It is a bot I use for a tutorial
It has one command
And one package
Which is eris
so I think that should be fine
thats strange
it has happened with the past 2 bots I tried with eris
And I tried hosting on glitch, repl.it, local, rpi and vps so I am really confused
That's annoying and strange
When running a discord.js bot on multiple machines, can somehow be assured that every guild will always be handled by the same machine? Right now increasing the number of shards will rearrange the guilds accross the machines due to the shardingformula.
That's annoying and strange
@pure lion yes itis
why did you care about having the same guild on the same server?
because then i can have a databse on that server for that guilds
why not use one linked database
i dont think this is possible usually you have one database for all servers
i need to separate the data, shard it
if you have issues with bandwdh shard the database
You could create a REST API and connect it to one central server
or use MongoDB. you can make a sharded database that connects to one endpoint. where it loadbalances the querys
what yous talking bout im confused
the queries should not be loadbalanced, the need to be fixed according to the sharding key
Why does this only happen with eris and not d.js
so do people create multiple bots for this maybe? i mean i could easily let one bot with one local database go to 100k servers and simply create a new bot and exchange the invite link everywhere
i dont get your issue. MongoDB should handle it.
@earnest phoenix if you came here to vibe, just leave
is there anyway to handle it, so that the connection resumes?
not really they have a Database Cluster the Shard Servers connect to
nah im good I asked what going on
is there anyway to handle it, so that the connection resumes?
client.on('disconnect'
oh
lemme see
If there's a way to execute code when the bot disconnects just run the login thingy
client.on('shardDisconnect', (event, shardID) => {
setTimeout(() => client.destroy().then(() => client.login(process.env.BOT_TOKEN)), 60000)
console.log(`[DISCONNECT] ${get_date(new Date())} Notice: Shard ${shardID} disconnected from gateway with code ${event.code} - Attempting reconnect.`)
})
try this
if the bot crashes it reconnects after a delay
How is Eris different from djs?
(you probably need to edit the console.log bcs there is a function running in it for formating the date)
idk
client.on("error", (error, id) => console.log(`An error occured: ${error}`))
client.on("disconnect", () => console.log("Disconnected"))
client.on("shardDisconnect", (error, id) => console.log(`An error occured: ${error}`))
client.on("shardResume", () => console.log("Shard resumed connection"))```I added all this in
Oh you said to do that
ok lul
disconnect is V11 shardDisconnect is V12
(it's eris)
ohh. then IDK if the new one is correct
but you can add the set timeout and the login to the one that works
if you shard the bot i guess shardDisconnect is better
I will try both
ok
See if it works
Eris uses shards as a default thing anyways
The error event returns the error + the shard id
Thanks for your help, I asked in the Discord API server and no one would help, they would just tell me what I already told them and basically ignore me
Ty
can anyone help? ```js
case 'search':
let woolooEmbed = new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle('A wild wooloo spawned!')
.setDescription(`Try catch wooloo.`)
.setImage('https://imgur.com/oGqz0Wd.png')
let nickitEmbed = new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle('A wild nickit spawned!')
.setDescription(`Try catch nickit.`)
.setImage('https://imgur.com/GjX0hfx.png')
let blipbugEmbed = new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle('A wild blipbug spawned!')
.setDescription(`Try catch blipbug.`)
.setImage('https://imgur.com/ANKaMxc.png')
let rookideeEmbed = new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle('A wild rookidee spawned!')
.setDescription(`Try catch rookidee.`)
.setImage('https://imgur.com/NARWgBE.png')
let skwovetEmbed = new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle('A wild skwovet spawned!')
.setDescription(`Try catch skwovet.`)
.setImage('https://imgur.com/FupP7mL.png')
}
})
those pokemon are able to be found when they write .search in the route 1 place
can anyone help me with that?
switch ('search') {
case 'route1': {```try this
you need to give switch some variable
https://prnt.sc/t6ujtb https://prnt.sc/t6uk39 can someone help me?
show full error
do you have a server.js file? show your casetofon folder
you dont even have a server.js file
good morning everyone, hope everyone is okay. just wondered if anyone could give me some help on this. when using eval for sharding i seem to be running into a syntax error [unexpected identifier] thanks in advice for your help.
client.shard.broadcastEval(`const guild = this.guilds.cache.get('${args[0]}');
if (guild) {
const guildOwner = guild.members.cache.get(guild.ownerID);
guildOwner.send('You Have Been Blacklisted For Violating Our ToS https://projectbump.xyz/ToS :warning: Please Join Our Support Server To Appeal! https://discord.gg/SrEUJ4z');
guild.name;
}
else { false; }`)
.then((results) => {
if (results.find(r => r !== false)) {```
switch ('search') { case 'route1': {```try this
@lusty quest u made that for me?
Oi
ty
@long yew yes but its not completly correct
Tim tu fala português né?
in switch you need a array with the possible cases iirc
i don't understand how do add that route 1 thing fully
@earnest phoenix idk about unexpected identifier because broadcastEval is weird version of eval. but in your code, guild owners are not guaranteed to be cached, so you would need to fetch it or you risk getting a cannot send of undefined error. also try to explicitly return guild.name instead of leaving it in the open, and you dont need the else block, just check for undefined instead
@opaque oxide sim
@long yew case is where your current case search is
switch ('search') {
case 'route1': {
let woolooEmbed = new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle('A wild wooloo spawned!')
.setDescription(`Try catch wooloo.`)
.setImage('https://imgur.com/oGqz0Wd.png')
let nickitEmbed = new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle('A wild nickit spawned!')
.setDescription(`Try catch nickit.`)
.setImage('https://imgur.com/GjX0hfx.png')
let blipbugEmbed = new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle('A wild blipbug spawned!')
.setDescription(`Try catch blipbug.`)
.setImage('https://imgur.com/ANKaMxc.png')
let rookideeEmbed = new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle('A wild rookidee spawned!')
.setDescription(`Try catch rookidee.`)
.setImage('https://imgur.com/NARWgBE.png')
let skwovetEmbed = new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle('A wild skwovet spawned!')
.setDescription(`Try catch skwovet.`)
.setImage('https://imgur.com/FupP7mL.png')
}
})
@long yew how do you want your command to work? like this? !search route1?
something like this (there are missing brackets at the end)
Então tim
@quartz kindle yes he want to get this
Por algum motivo meu bot só funciona com a permisão administrador
in that case, you need to switch the args
ie ```js
switch(command) {
case "search": {
switch(args[1]) {
case "route1": {}
}
}
}
assuming he has args defined
Só funciona quando eu ativo o administrador
i do
ie ```js
switch(command) {
case "search": {
switch(args[1]) {
case "route1": {}
}
}
}
@quartz kindle so that will work?
thats just an example
Isso e um problema @quartz kindle ???
ok thanks
not for you to copy and paste
ik
@opaque oxide sim, bots nao deveriam ter admin perms
é uma vulnerabilidade e um risco
O xenom tem essa perm +-+
not discord.py related but the staff in python are braindead and cant help
node index.js
se o bot for hackeado, ele pode destruir seu server, banir tudo e deletar tudo
Mais já que só funciona com a perm administrador
funciona oq
Pois n tem commandos desse tipo
O único commando de Moderação
Por enquanto
E kick
nao é uma questao de comandos, se ele for hackeado o hacker pode criar os comandos que quiser, a unica proteção é as perms
anyway i guess this channel should be english only
Sim sim
we can speak portuguese in #memes-and-media
ingles
Eu tô com sono!!!!!
eu tb!!!!!!!!
Excesção
still wrong lmao
Acho que isso aí tá errado +-+
Exceção ou Excepção em portugal
Lol
Não é que você tem 12 anos que tu fala errado
ele envia uma embed com os comandos na pasta
isso
Ata
?
é mais facil fazer com ele certeza
Eu sei
O meu n e assim n
I see how it effect to work it moving
what
Is that attact to discord bot command
O ruim só DVD e que
Não dá para fazer bot de musica
I'm so confused rn
Dbd
Uh
@quartz kindle can you quick.db?
i dont use quick.db
Foc
but its docs are easy to understand
Is there any can do about {( cmd )} ?
Not for me apparently
@dusk sphinx i dont understand anything you're saying
I am in another lvl that you don't meet
What command do the discord bot online
lmao
Discod bot online
Omv
we don't support bot makers
mainly because you don't have direct control over the code
Cry do you know how to quick.db
O utheo
if you have an issue with a bot maker app, go complain to the app developer
Oi
i do not dice
Demora quanto tempo demora para os cara vê meu bot???
Como assim
@pure lion just post your question, quick.db is easy enough that people can understand it without using it
Okay
@opaque oxide 2-3 semanas
let woolooEmbed = new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle('A wild wooloo spawned!')
.setDescription(`Try catch wooloo.`)
.setImage('https://imgur.com/oGqz0Wd.png')
let nickitEmbed = new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle('A wild nickit spawned!')
.setDescription(`Try catch nickit.`)
.setImage('https://imgur.com/GjX0hfx.png')
let blipbugEmbed = new Discord.MessageEmbed()
.setColor(`RANDOM`)
.setTitle('A wild blipbug spawned!')
.setDescription(`Try catch blipbug.`)
.setImage('https://imgur.com/ANKaMxc.png')
``` for e.g these are some pokemon that will spawn, how do i make it so that there is a percentage chance that one will spawn?
@quartz kindle de onde
The trigger cmd of prefix
s
@opaque oxide Onde tu hospeda o bot
app
Api
what is happening here
a br invasion
Agora tem que verificar né??
@quartz kindle ok ill leave you to it (;
@opaque oxide Alguma hora eles vão ver
no pls
só espera
dont leave me alone with them
tipo
Tem muito bot pode levar umas semanas
go to #memes-and-media to speak a different language
q
@long yew you will need some math
Haha
for example if(Math.random() > 0.1) this has a 10% chance of working
Math.random() returns a random decimal number between 0 and 1
Quero fazer comandos de diversão
that is cool
Ok
youve been told like 3 times to go to #memes-and-media
lol
Utheo
sim?
O server suporte dele tá em construção
simp
Mandei no seu pv
#memes-and-media for other languages
If you guys don't move to #memes-and-media rn you will be muted
You have been told multiple times by server members to follow the rules
did someone know here what parameter i need to add to a query in MongoDB to get every Document where the set Timestamp is older as the provided one in the query
u wot
i want to get every Document from a MongoDB that is older than the Timestamp i query. Every Document in the DB also got a Timestamp from the Creation
in every collection?
only one
is this correct?
if(Math.random() > 0.15)message.channel.send(woolooEmbed)
else if(Math.random() > 0.05)message.channel.send(nickitEmbed)
else if(Math.random() > 0.15)message.channel.send(blipbugEmbed)
else if(Math.random() > 0.2)message.channel.send(rookideeEmbed)
else if(Math.random() > 0.25)message.channel.send(skwovetEmbed)
else if(Math.random() > 0.1)message.channel.send(caterpieEmbed)
else if(Math.random() > 0.05)message.channel.send(hoothootEmbed)
else if(Math.random() > 0.05)message.channel.send(grubbinEmbed)
actually its possible none of them get sent
actually yes
oh
lmao
because you're getting a new random number every if
actually it would work
because he probably doesnt want to send on every single message
nvm what i said
a whole few bytes
Declare a variable that is Math.random and check it against that variable
they're also creating embeds
Same
I try to create new command that no one tried b4
Declare a variable that is Math.random() and check it against that variable
would make a function to generate the random number. additional set a percentage for every item. then check if the generated number is in the range of the percentage it should spawn
Is [] use able for command
In what context
Declare a variable that is Math.random and check it against that variable
@golden condor idk how
This [sauce]
How do I find a specific value inside of an array, like a guild ID? (DJs)
Is is symbol also work in command
can it find a string tho?
Yes.
TypeError: 710964023117479966 is not a function
<array>.find((entry) => entry === "thisstring")```
Will either find it or return undefined.
oh okay
O..um...parameter is for number right
what? No lol
No?
Parameters are things you pass in a function
Yeah thats what I ment lol
I mix them up alot lol
function name(parameter1, parameter2) {
//code
}
Just triggered the cmd but..is it use 2 of symbol each to up
what
😕
TypeError: Cannot read property 'find' of undefined
Is your array actually an array?
yes
O
var arr = [array]
arr is undefined tho
(placeholder)
No arr in there idk why
Wherever you're trying to access this array it isn't accessible to the .find function.
What key do i need to make the bot online
Key?
Symbol key
if(Math.random() > 0.15)message.channel.send(woolooEmbed)
else if(Math.random() > 0.05)message.channel.send(nickitEmbed)
else if(Math.random() > 0.15)message.channel.send(blipbugEmbed)
else if(Math.random() > 0.2)message.channel.send(rookideeEmbed)
else if(Math.random() > 0.25)message.channel.send(skwovetEmbed)
else if(Math.random() > 0.1)message.channel.send(caterpieEmbed)
else if(Math.random() > 0.05)message.channel.send(hoothootEmbed)
else if(Math.random() > 0.05)message.channel.send(grubbinEmbed)
``` someone help me fix this
how do i make this work?
Idk.
i wanna make it so there is a percentage chance of one spawning when someone writes .search
no, usnig switch just skips to whatever value because o the break;
Maybe you should store Math.random into a variable.
That's what I said
whereas if checks everything and doesn't skip
Switch is programmatically slower because of how it's compiled into computer code.
But it would be less cluttered
im suffering
It looks nicer fair.
Switch is only more efficient if the amount of provided cases are low.
I am looking for a good package/API to use for my bot as it keeps getting rate limited with yt-search. Would I get less rate limits if I used lavalink search or another API/package?
But even still, The difference between using if else and switch with a low amount of cases/statements is not noticeable.
Lavalink can still get ratelimited but pretty sure it web scrapes.
unexpected what?
Token
The front or the back for those
Just click on all your brackets and see what ones don't have a sensible pair.
Although depending on what editor you're using it should just show a red squiggly line somewhere.
@warm marsh so would lavalink be better?
Do i need put if for that
😋
It's got a bit of setting up but imo it's better, Not once have I been rate limited from it. Touch wood.
Ok
hello
i have succeded in running the bot online
but discord.js told me this First, make sure to close the process in your console. You can do so by pressing Ctrl + C inside the console. Go back to your code editor and add the following piece of code above the client.login() line.
and i did, so neither does the bot appear online or store messages in console
hi, with css or bulma, does anyone know how i can make the table be longer?
@dire stag try to run the code again like you did at the start
By exiting out of cmd and then retrying your code since you already closed it from running. There shouldn’t be a 2 terminal issue
@digital ibex change the width
o ok
https://www.w3schools.com/html/html_tables.asp @digital ibex
👍👍
@dire stag b careful if ur trying to log all messages to console :') its against tos to log or store anything more than required when utilising api or sdk
Logging messages won't really do much unelss you are watching the logs 24/7 or are storing them. Plus discord can't find out if you log message content.
read developer guidelines
ok well ı dont really need to
if you're logging all messages
@spare goblet what does that mean in terms of things like snipe commands
@golden condor except ur technically breaking TOS
whats snıpe commands?
snipe is a feature
if you're logging every single message for literaly no reason
that's against TOS
Fair point
but whats sniping?
Like when someone deletes a message you can see it
whats a good point in why you should log all messages
2.4 End User Data. “End User Data” means all data associated with the content within the functionality enabled by the API or SDK, including but not limited to message content, message metadata, voice data and voice metadata. You acknowledge and agree that Discord and its end users, as applicable, retain all worldwide right, title and interest in and to the End User Data. If you have access to End User Data through the API or the SDK, you shall ensure that your Applications do not collect, use and/or disclose End User Data except (a) as necessary to exercise your rights under this Agreement,
well bots do that
**If you have access to End User Data through the API or the SDK, you shall ensure that your Applications do not collect, use and/or disclose End User Data except (a) as necessary to exercise your rights under this Agreement, **
collect includes both logging and storing
whats a good point in why you should log all messages
@dire stag there isn't many I can think of off the top of my head
if it's outside of your necessary features then
So a snipe command would be okay?
ındeed
For example
ı wıll porbably remove ıt
a snipe command is fine beceause its only for one message
Ok
wh<ts a snıpe command?
When my bot restarts I clear all snipes anyways
@dire stag seeing a message after it's been deleted
hi, i have this: html <% commands.forEach((command) => { %> <%- include('guild/custom-commands', { command }) -%> <% }) %> in ejs, does anyone know why its doing this:
?
this is all my html: ```html
<body>
command
</body>
if (!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send("You don't have permission!");
const deleteCount = parseInt(args[0], 10);
let embed = new Discord.RichEmbed()
.setDescription("Purge")
.setColor("RANDOM")
.addField("**Messages: **", `**${deleteCount}**`)
.addField("**Purged By**", `**<@${message.author.id}> with ID ${message.author.id}**`)
.addField("**Purged In**", message.channel)
.addField("**Time**", message.createdAt );
if (!deleteCount || deleteCount < 2 || deleteCount > 100) {
message.channel.send("Example: " + prefix + "purge 10");
message.channel.send("Please enter a number between 2 and 100");
return;
}
const fetched = await message.channel.fetchMessages({ limit: deleteCount });
message.channel
.bulkDelete(fetched)
.catch(error => message.reply("Error. Contact an administrator."));
}```
what is wrong here?
i know i have to change message to msg
what is the error
except that?
So the code inside guild/commands .ejs is command?
that'll be why it is repeating command
theres nothing interacting with the ejs code
How do i reduce/trim a string? https://hastebin.com/eseqakotid.js
Its for a server info
command
Ping me if u knw
<string>.trim()
anything in trim()?
i dont need that
define botConfigs
How do i reduce/trim a string? https://hastebin.com/eseqakotid.js
Its for a server info
command
how
roles
do i define that
trim
umm?
ah yes
do i define that
@delicate shore you tell me, it's your code
I just had a brain fuck
@delicate shore dont use copy pasted code plz
someone pls help me here
another user of glitch
@modest maple I have glitch premiun
reduce the string from 100 roles to 5 roles
Data.findOne({ timestamp: {"$gt": time} });
``` Does this give me the document where timestamp < Date.now() (mongodb)?
premum
how i do that
shoulda get a vps but you do you
Data.findOne({ timestamp: {"$gt": time} }); ``` Does this give me the document where timestamp < Date.now() (mongodb)?
@lusty quest what is time defined as
yes bad
its litteraly Date.Now()
I could get a 6 core, 16GB ram server for that amount lol
Oh then yeah
i pass it just there
mongoose
https://docs.mongodb.com/manual/reference/operator/query/gt/ i'm just checking the docs bare with me
VPS
@delicate shore just learn how to use js smh
mongoose is a client for accessing MongoDB
Yes it should in that case
so how do we host bot on MongoDB?
U dont
man this guy
if you want a VPS recomendtation get a 5$ Droplet from Digitalocean
ok?
But if u want all of them, put .find instead
Adding onto that, you can get contabo
Mongodb is a database glitch is a host
or ovh
ohhhhhhhhhhhhhhhhhhhhhhhhhhhhh
mongoose is a mongodb orm
But like if i buy VPS then?
smh
VPS is a virtual computer
@lusty quest do you want all of the documents or just one?
thing
I'm making a purge command and I'm not sure how to check if the delete count is over 200, How Do i check?
hmmmm ```
DB timestamp: 2020-06-26T07:16:42.000+00:00
Date.now(): 1593174706598 -> MongoDB should convert it to the correct timestamp
if (number > other number)
huh
Remind me what time format that is again (I forgot the name)
can anyone help me?
i just want to get one document where the timestamp is older than Date.now()
@golden condor unix timestamp
ok
let arr = [1, 2, 3, 4, 5, 6, 7, 8]
function random_pokemon(arr) {
arr[Math.floor(Math.random() * arr.length)];
}
if (random_pokemon(arr) == 1) {
message.channel.send(woolooEmbed)
} else if (random_pokemon(arr) == 2) {
message.channel.send(nickitEmbed)
} else if (random_pokemon(arr) == 3) {
message.channel.send(blipbugEmbed)
} else if (random_pokemon(arr) == 4) {
message.channel.send(rookideeEmbed)
} else if (random_pokemon(arr) == 5) {
message.channel.send(skwovetEmbed)
} else if (random_pokemon(arr) == 6) {
message.channel.send(caterpieEmbed)
} else if (random_pokemon(arr) == 7) {
message.channel.send(hoothootEmbed)
} else if (random_pokemon(arr) == 8) {
message.channel.send(grubbinEmbed)
}
}
})
``` what is wrong with this?
So
if(deletecount > 100) return message.channel('err message')?
wtf
discordapi only allows 100 at max iirc
Just store each embed in the array
o
then use the random to access the embed
why did you convert a Date to a number?
So i was working on a canvas, but how can i get the time to be exact, just like .setTimestamp() does on an embed?
guys
new Date(Date.now())
how to use MongoDB
@golden condor that does not work
can anyone help me?
To get the time it was sent you can use new Date().toLocaleString().split(/\, /)[1]
new Date(Date.now()).getTime() will return a unix timestamp @lusty quest (also how will a document be made after you peform the action)
usually MongoDB should convert Date.now() to what you send me
You don't provide nothing for us to help you.
i did
Just try feed in the unix timestamp maybe
All you state is that it doesn't work.
let arr = [1, 2, 3, 4, 5, 6, 7, 8]
function random_pokemon(arr) {
arr[Math.floor(Math.random() * arr.length)];
}
if (random_pokemon(arr) == 1) {
message.channel.send(woolooEmbed)
} else if (random_pokemon(arr) == 2) {
message.channel.send(nickitEmbed)
} else if (random_pokemon(arr) == 3) {
message.channel.send(blipbugEmbed)
} else if (random_pokemon(arr) == 4) {
message.channel.send(rookideeEmbed)
} else if (random_pokemon(arr) == 5) {
message.channel.send(skwovetEmbed)
} else if (random_pokemon(arr) == 6) {
message.channel.send(caterpieEmbed)
} else if (random_pokemon(arr) == 7) {
message.channel.send(hoothootEmbed)
} else if (random_pokemon(arr) == 8) {
message.channel.send(grubbinEmbed)
}
}
})
``` what is wrong with this?
@long yew
i get no error
Then you're not executing it correctly.
if you send Date.Now() you get 2020-06-26T07:16:42.000+00:00 bcs mongodb converts unix timestamps
Also you're missing a return in the function.
Oh
What I don't understand is how a document will be made after you send a request
what do i need to add or change?
Add a return
function random_pokemon(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}
@warm marsh that thing you said
Date().toLocaleString().split(/\, /)[1] returns undefined
thats simple. when i create the Document i set the Timestamp + xDays. then i have a event running every 5 minutes that checks if a timestamp is older than Date.now().

