#development
1 messages · Page 702 of 1
if it's relevant the package i'm using to commuicate is https://veza.js.org/ (id call august but hes on mobile
)
(Discord.JS)
How do I make a report command like, the input is /report @someone (reason) and I want it to be sent in an embed to a channel in my Discord server.
The output will be like:
User#0000 has been reported
(Reason)
Reported by UserWhoReported#0000
If someone could help that’d be great!
I'd suggest using two fields for that
Field1 name: Reported User
Field 1 value: (the reported user's name and tag)
Field2 name: Reported By
Field2 value: (the person who reported)
ok
Keep a database of the user and store it somewhere into another channel too
TR
if (!message.content.startsWith(ayarlar.prefix)) return; Bu Komutta
if (!message.content.startsWith("." && `<@${client.user.id}>`)) return; Bunu Yapınca Çalışmıyor. Yardım Edebilir Misiniz ?
ENG
if (!message.content.startsWith(ayarlar.prefix)) return; In This Command
if (!message.content.startsWith("." && `<@${client.user.id}>`)) return; Not Work . Please Help ?
does somebody know how to wait for a foreach loop to end in js?
need it ASAP
Afaik you cant
You can return a promise and get data out of it, but you still cant wait for that data specifically.
like i want to do something when a loop ends
Yeah ik
like sending results of whathappened in the loop
Im saying that isnt a possibility
You can do something like https://stackoverflow.com/questions/38406920/best-way-to-wait-for-foreach-to-complete
&& is one condition, they need two booleans
How can i fix this error? Its a error when i do !warn <mentios> Reason>
(node:6624) UnhandledPromiseRejectionWarning: TypeError: message.member.hasPremission is not a function
at Object.module.exports.run (C:\Users\wesle\Desktop\Funny bot\Commands\warns.js:8:25)
at Client.bot.on (C:\Users\wesle\Desktop\Funny bot\index.js:71:28)
at Client.emit (events.js:198:13)
at MessageCreateHandler.handle (C:\Users\wesle\Desktop\Funny bot\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\wesle\Desktop\Funny bot\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (C:\Users\wesle\Desktop\Funny bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (C:\Users\wesle\Desktop\Funny bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
at WebSocket.onMessage (C:\Users\wesle\Desktop\Funny bot\node_modules\ws\lib\event-target.js:120:16)
at WebSocket.emit (events.js:198:13)
at Receiver.receiverOnMessage (C:\Users\wesle\Desktop\Funny bot\node_modules\ws\lib\websocket.js:789:20)
(node:6624) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6624) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
If you will help me slide in my Dm or say it in this channel
@earnest phoenix message.author.hasPermission
i go to check it
if (!message.author.hasPremission("MANAGE_MEMBERS")) return message.channel.send("Sorry jij kan dit niet doen");
premission
this don't work
you have the incorrect spelling
it tells you
that the function does not exist
because
sorry my spelling is very bad
Premission
but thank you
Hey Im having a problem with something on my bot if anyone is aviable to help can you dm me.
message.author won't work btw.
meow can you explain it
So basicly
im trying to get the bot help command into catagorys like !help fun !help info !help mod
but its not woroking when i do the !help (cat)
@earnest phoenix is there an error?
Please enter at least 300 characters excluding special characters in your detailed description. Add your commands. Spaces or empty spaces are not counted.
im uploading a bot on discordbots.org
300 words spaced
and it says that
simple as i can put it
but what i need to do i dont get it?
How can I make my purge command show the correct amount of messages deleted
D.js master
count the amount of messages you pass to the bulk delete method
what?
i dont understand
Please enter at least 300 characters excluding special characters in your detailed description. Add your commands. Spaces or empty spaces are not counted.
put a total of 300 words with spaces, and have; what it does, it's main help command, it's specialty
I already have
.then(messages => {....}
the long description
But when I do true (the second param of bulkDelete) it returns 0 messages deleted when I’ve deleted 20
The deleting of the messages work out
Yes I fetch messages
no
ok so
if you put in !purge 20
Please enter at least 300 characters excluding special characters in your detailed description. Add your commands. Spaces or empty spaces are not counted.
then the first arg is the deleted count
dudes what i need to do
wth
it means exactly what it says
use your brain
@earnest phoenix enter 300 characters
but where
about your bot
in brief description?
no
Okay but that’s not accurate @earnest phoenix
in the long description
where then?
They can put 100 but in reality it only deletes 20 messages
@lusty dew ok, but when you fetch messages their should be a count
yes
but there is no any other description
HELP
@lusty dew the second parameter is whether to filter old messages because you can't bulk delete messages older than two weeks, setting the second parameter to true will filter it out
limit: integer
THERE IS NO OTHER
description
SOMEONE HELP ME
yall be nice
@earnest phoenix the black bar is where you need to add the long description
http://prntscr.com/pazopw @earnest phoenix
I know but when I put true then I do
.then(messages => {message.channel.send(messages.size)})
``` it returns 0
have you read what i said
well i know
jesus christ can no one use their brain today
i use something similar but i can’t recall how i got the message count lmao
i know it’s simple but
lol
So my next question is if you would stop being so damn ignorant
ohh @loud salmon thanks
Is how can I get the actual number of messages deleted while still having true
@earnest phoenix write about your bot. talk about its features, its commands, and how it works
in both descriptions?
if you cant reach 300 characters, then you need to add more features
do i have to explain it like i should explain it to a kid?
set true on the second parameter
it will make old messages that can't be bulk deleted go boom from the collection
it returns the amount of messages that can and were bulk deleted
ok thanks
if it returns 0 it means that 0 messages have been bulk deleted
so, none
But that’s false
you can't bulk delete messages older than 2 weeks
I know
so you probably have some other code deleting it too
using the DELETE request on the message itself

does it return 0 regardless in which channel, regardless of whether there have been recent messages or not
cry did explain it
It returns 0 when any messages have been deleted
you use messages.size right?
after using js bulkDelete().then(messages => { // code that you have });
@lusty dew
You don’t have to ping me wtf
You just sent the message
ok
Give a person time to respond
sorry for harming you by pings
hey hey hey, clearly everyone in this conversation is worn out. My suggestion is that everyone take a 5-10 minute break
found this
No I just don’t like being pinged for no reason
go in a different discord channel, watch a youtube video, or just try and walk around for a bit

🤷
const fetched = await message.channel.messages.fetch({limit: args[0]});
message.channel.bulkDelete(fetched, true)
.then(messages => {
message.channel.send(`:check: Deleted ${messages.size} messages`)
});
This is my bulkDelete code
He's helping you chill a ping won't kill you
is args[0] an integer or string
If it is a string it becomes an int
any more toxicity from anyone here and they get a break much longer than 10 minutes, kthx
you can be muted again if the toxicity continues
my suggestion is to go to the official discord.js server
🤷 whatever
damn
If you guys don't want to help then don't have a development channel
???
people have been trying to help you though, but its just been a bit unclear
due to 3 people asking questions at once
🤷
if you summarize what you have done so far, and what you need help in one message, then it may be a bit of use
Eh idc anymore
also, not saying this is your issue, but looking here might be of help http://xyproblem.info/
Asking about your attempted solution rather than your actual problem
Im just not gonna worry about it and leave it as it is
ok
https://discord.gg/bRCvFy9 is the discord.js server actually
oh wew
I am already in it
gg
Yesterday
you can’t expect anyone to respond after a day...
even see the message after a day-
sigh
👌
is there any way to reload an event ?
what lib
How dare a fellow neko be mean
you don't have time to be mean
js
idk how to do it but id assume you would have to unbind then rebind the callback for an event
js is not a library, its a language
if your library is discord.js, all events are saved in client._events, you can add/edit/remove them from there
uh help
is there any reason that discord.js v12 would consume way more memory than v11
i just migrated to discord.js v12 and i'm getting upwards of 100 MB RAM usage
meanwhile on discord v11 it was only around 25 MB
Well there’s a lot more instances of a lot more things in master
Make sure to sweep messages to make sure your cache is gigantic
i just rebooted it and its at 25 again
and i do sweep messages
hopefully it doesn't go up again
discord.js
CODE
index.js
// this channel is the assigned channel where the bot will play Guess The Number!
let gsnChan = message.guild.channels.find(channel => channel.name === `guess-the-number`);
let gsnc;
if (!gsnChan){
gsnc = "There is no **Guessing Channel** set for this server!"
} else {
gsnc = `<#${gsnChan.id}>` // gsnChan.id = get the id of that channel || gsnChan.name = get the name of the channel
}
let gchannels = JSON.parse(fs.readFileSync("./guesschannel.json", "utf8"));
if(!gchannels[message.guild.id]){
gchannels[message.guild.id] = {
gchannels: gsnc
};
}
let gsnChannel = gchannels[message.guild.id].gchannels;
console.log(gsnChannel)```
command
if(!message.member.roles.find(r => r.name === botCommanderRole) || !message.member.permissions.has("MANAGE_CHANNELS")) return message.channel.send(`${emote.cross} You do not have access to use this command! (if this is a mistake tell us in our discord with **support** command)\nhint: bot commander role!`);
if(!args[0] || args[0 == "help"]) return message.channel.send(`how do you use this command? example: ` + "`" + `${prefix}setchannel [#channel | channel id]` + "`")
let gtnChannel = JSON.parse(fs.readFileSync("./guesschannel.json", "utf8"))
gtnChannel[message.guild.id] = {
gtnChannel: args[0]
};
fs.writeFile("./guesschannel.json", JSON.stringify(gtnChannel), (err) => {
if (err) console.log(err)
});
message.channel.send(`${emote.tick} Successfully set the guessing channel to ${args[0]}`)
it keeps coming back as undefined
@unreal junco what exactly comes back as undefined?
just says undefined i
i think it means
the gsnchannel
it doesnt read the channel it was set to
in the command
the default works
but not when u use the command
once command is used it goes to undefined
first of all is there any chance you can use anything other than json for your db?
no 😦
any way to solve?
use a database
arent i doing that already?
if you like json, quick.db works pretty much the same way
quick.db doesnt work for me
@unreal junco why can't you use a real db
it doesnt work on my mac for some reason
why i cant get shards with client.shards it returns undefined ?
]] moreinfo
If you want people to be able to assist you, please provide more information, such as what library and language you're using, the code in question and what you are trying to do and/or what is causing the error.
sorry im just trying to use dblapi js setInterval(() => { dbl.postStats(this.client.guilds.size, this.client.shards.Id, this.client.shards.total); }, 1800000); but here client.shards returns undefined | also client.guilds.size okay
nope all shards property is undefined | and i get this code from dbl api docs
When the discordjs shardingmanager starts a new shard, will servers from the already existing shards be moved to the new shard?
How come when I click the buttons on my bots profile, it doesn't redirect me to the official website? https://gyazo.com/a4703989d027b0ab64f64510d142afb1
The buttons do nothing although they should
onclick triggers js iirc
Oh right
How do I do it without onclick? I can't find much that covers it
Ok nvm I changed it up and i like it now.
@viral spade shards never change while the bot is running, only if the bot is restarted/disconnects
In this server? You dont.
One message removed from a suspended account.
One message removed from a suspended account.
idk maybe you'll catch pokemon hiding in the code
Since some people here seem to have experience with digitalocean
they say 'Inbound bandwidth to Droplets is always free.'
So incoming Discord events do not count for the 1tb transfer limit?
I'm considering moving my bot to a vps instead of my home server, i did read the pin
from what I understand from your explanation, download is free, upload is capped
@sullen yacht just use a div and style it
then you can add a link inside of it
<a href="idfk">pitucas</a>
its correct
huh
that's not a weird output
ok
Hey yall. In sharding, do some of you get Error 1001?
what is the description of the error
Wrong one wait
[2019-09-26 03:23:01]: LOG Shard 1/1 disconnected with the error Error: 1001: ,
at WebSocket.ws.onclose (/usr/src/app/node_modules/eris/lib/gateway/Shard.js:1655:67),
at WebSocket.onClose (/usr/src/app/node_modules/ws/lib/event-target.js:124:16),
at WebSocket.emit (events.js:209:13),
at WebSocket.emitClose (/usr/src/app/node_modules/ws/lib/websocket.js:191:10),
at TLSSocket.socketOnClose (/usr/src/app/node_modules/ws/lib/websocket.js:850:15),
at TLSSocket.emit (events.js:214:15),
at net.js:588:12,
at TCP.done (_tls_wrap.js:479:7) ,
close code 1001 should be cf load balancing
So it cant be fixed?
Load balancing.
all libraries should be able to handle that
So its pretty much normal?
In Java am I better off statically loading commands or is dynamically fine?
In djs they are strings
They are sent as strings but discord.py converts IDs to integer
^
@wheat jolt did you ever define formChan in the first place?
i feel like you've never defined
wait
it's defined
Help me please
how
that doesn't look right
`` if(message.content.startsWith(prefix + "clear")) {
message.delete();
if(!message.guild.member(message.author).hasPermission("MANAGE_MESSAGES")) return message.channel.send("Vous n'avez pas la permission !");
let args = message.content.split(" ").slice(1);
if(!args[0]) return message.channel.send("Tu dois préciser un nombre de messages à supprimer !")
message.channel.bulkDelete(args[0]).then(() => {
message.channel.send(`${args[0]} messages ont été supprimés !`);
clear.clear().then(member => {
var clear_embed = new Discord.RichEmbed()
.setColor("#40A497")
.setTitle("Clear :")
.addField("Messages supprimés:", `${args[0]}`)
.addField("Dans le salon :", `${message.channel.name}`)
.addField("Modérateur :", `${message.author.username}`)
client.guilds.get("481105805161005066").channels.get("488344143047819282").send(clear_embed)
console.log("Un modo a supprimé des msg !")
});
});
}
``
i don't think you're supposed to use of
Help me
Of is correct.
what's your error?
Do you speak French?
@wheat jolt what version of djs?
Discord.js v12.0.0, Using for (const chan of guild.channels).
Alright.
Whats really the best way to do counter things in a database? Im doing it for a punishment system, and it works, but i feel like theres a much better way to do it. At the moment of the punishments database like this: {amount: #, role: "id", users: {}}, and .users will be filled like {id: amount_of_offences}, ex: {"142408079177285632", 2};
and i've a feeling theres a much better way of doing it but i dont know
how do i edit a message that has already been sent of a bot in discord.js ?
@mild escarp Message#edit()
discord.js how can i check if someone is in a voice channel
thanc
if i declare a variable with const will it not be usable outside of the current scope?
cyber const just means the value is immutable and can't be changed unlike let
but you must initialize it
yes, i know
ah
you can't use it 
well thats fucked
let/const are scoped yes
cuz ts is stopping me from declaring it outside of the scope
does ts not let me call my variables node or some shit
@valid frigate ^
lmao whta
Wot
i dont understand okay
Wot
const node: any
const nodee = new Server('main')
Instead of js can I make a bot in java
why are you declaring node lmao
const node: any = new Server(‘main’)
@stone robin it doesn't matter what language you make a bot in
Is js better or py?
wait wait cyber
Both are good
Subjective
is that veza
yes
It depends what you are better at
veza has types lmao
@stone robin it's preference
i know
but im trying to avoid types right now
and just get the entire thing to work
Js
oh yay
i already managed to do it at the smallest possible scale
do i do it similarly in the file where i create the veza client?
wait, so how would i create my Client in the d.js ready event
and use it outside of the scope
create an extended client using extends
like class YourClient extends Client
then give it a property with the veza client in it
is that really necessary
probably not
Typed langs for ya
lmao

yes 
OtherClient client extends Client implements ClientsClient
I hate typed langs
The amount of redundancy is annoying
node: any fixed it 
this is the part where i pretend i understand what im doing, right?
Yes
How do you change simple stuff on your bots profile? Like the color of buttons etc?
css
Yeah but how do you reference them
It might be easy but i don't use css so i might need to learn it
ctrl-shift-I and get them
Okay
?help
^
@quartz kindle
for(let i = 0; i < Categories.length; i++){
server.createChannel(Categories[i][0], {type,
permissionOverwrites: [{
id: server.id,
deny: Categories[i][2],
allow: Categories[i][1]
}]
}
)
}
When we do the bot, we dot it on Visual studio code or directly in the developement discord topic ?
( I'm a begginner ^^' )
I'm not exactly sure what you mean, but I can hit you up with a guide to get started on the basics and which explains what to do and what not to do
Ok thanks u very much 😄
@earnest phoenix what is Categories[i][2] and [1]?
are you using discord.js v11 or v12?
v12 i think uhm cat1 is a jason file that make catergories and cat 2 makes channels
So for error 1001, its normal to recieve that kind of error?
error 1001 where
that's not even a valid error code afaik
it's not a http code
@unkempt arch 1. where error 2. screenshot pls 3. Please explain which lib u using pls thanks
1001 errors for a websocket are normal, it's usually just cloudflare
^
simplified, yes
Any other way to at least reduce the error?
no
So i should expect that this will spam my console when shards are increasing in number right?
you should complain to your lib devs for not properly handling a normal close
Eris tho has proper close for it tho? It aint crashing.
which lib are you using?
Eris?
are you listening to the error event?
Yeah. Full process.
well you could simply not log that error when it comes
if the process is not crashing, and the shard reconnects successfully, then the lib is handling it correctly, your choice to log it or not
Ill take the no logging one
you can log it as a single line info text, instead of the full warning/error object
Will do, thanks!
const activities = [{
"text": `${prefix} | ${client.guilds.size} servers!`,
"type": "STREAMING"
},
{
"text": `${prefix} | ${client.users.size} users!`,
"type": "STREAMING"
}]
setInterval(() => {
client.user.setStatus('dnd')
const activity = activities[Math.floor(Math.random() * activities.length)];
client.user.setActivity(activity.text, { type: activity.type , url: "url"});
}, 20000);
CAN anyone help to fix this ... - as the status doesnt update when the bot joins or leaves a guild ... - its on ready.js
well, it's in ready.js, so it wouldn't occur when your bot joins/leaves a guild (unless you have it wrapped inside a listener, but that's a big no no).
Why would you need to set the status to dnd every 20 seconds?
@heavy marsh if you want to update the numbers on an interval, you have to get their sizes again
the way you're doing it now, you're saving them in activities and then reusing the same saved value on every loop
thanks
@earnest phoenix no, you should not use this channel for general conversation, it doesn't matter how long slowmode is, you shouldn't be misusing channels if you want to stay unmuted tbf
what the fuck did i just witness
@earnest phoenix what library?
Oh, well I assume Py has a function similar to JavaScripts setPresence()
You should start your search there.
I would try to be more helpful but I know Py about as well as a blind person knows what the colour red is.
@west spoke he got muted for a week so it doesnt matter oof
Is Eris better than discord.js?
depends on what you want
generally less utilities than discord.js but much better for sharding
you have to reference the actual discord api docs for some cases
but it's fine really 
if you are willing to modify d.js for memory usage while keeping the ease of access then d.js
d.js is good on sharding now
is it really
ah fuck
the trade offs is the memory Usage
if you are not willing to modify d.js for memory
then go use eris
eris is ok
its already modified for less memory after all
but if you are williing to spend a lot of time studying d.js
then I doubt you will use eris
- Kurasuta's ipc is better than Eris Sharder
which makes me seamlessly transfer data from one shard to another
preference? 
https://weeb.amanogawa.moe/cdn/MlufrR7NRcyj8aVRII7CUPBBeTXBzHxu.png memory usage wise this is the diff
also i have no idea what kurasuta is
if you know what to do on d.js
Kurasuta is inspired by eris sharder but for d.js
so if you know eris sharder thats what kurasuta is
cba to touch eris sharder 
Im just lazy to rewrite my whole code to eris last year
thats why I took the more longer route
lmao
but the results is great
so now I have no reasons to switch
I dont want rewriting 250 files to eris
changing libs is unfortunate since it requires a rewrite of everything
I dont uncache members and users
my cache for messages is 100
sweeps every 10 mins
neat, what's your cachelifetime at?
and wouldn't sweeping interfere with the accuracy of your logging? (msgDelete, msgUpdate)
can users vote with bot commands using dbl api ?
@drowsy sentinel 30 minutes lifetime and not really
Ah, I figure 30min is enough time to be considered cached.
Could someone please give me a decent guide on how to make a ban command in discord.py? I keep searching but can't find any :P
@spark kelp no
@nimble creek we won't spoonfeed
I'm not asking for someone to sponfeed me, I'm asking if someone could give me a guide sice I can't find one
my 12k guild bot uses 550mb ram with discord.js, its up to you to be clearing your cache (although d.js could be giving better controls over it)
my 1.5k guild bot uses 50mb ram with djs-shenanigans (200-300mb with normal discord.js)
@indigo geyser next time I suggest not to spoon feed, no one really learn from it
I only wanted to help him
Yeah, I can understand. The best you can do is give him a tutorial website and a library website like discord.js.org
#rules-and-info
No, attacking a beginner is basically harassing them
And spoon feed?
Spoon feed is basically what you said
Ok
Hi, I fixed my bot problem, what do I need to do now for it to enter the server? Who do I talk to?
Anybody know?
if it was muted or kicked, contact the mod who did it.
if it was not approved, submit a new application on the website
thanks
Hola People. Want to learn about making Discord Bots? Check out this guide that @valid frigate and I made. https://vinniehat-1.gitbook.io/guide-to-making-your-own-discord-bot/
Good tutorial ^ (recommended for beginners)
Thanks
I felt things like choosing a code editor just has to go in there. It was big for me and stuff like that.
Guide looks nice. You could add some basic code for js and py from the homepage too.
I just began my first discord bot project and this guide is going to save me thanks
Vinnie did you include how to shard
haven't read it yet but will in a sec
also vinnie you can put this on gitbook https://gitbook.io
@abstract crow here is some feedback ig
- you arent really mentioning that js can be used outside of the web with node.js
- visual studio can also be used for js development (and its quite a powerful tool for the job, but also quite heavy)
- recommend more learning resources
- telling people to add their non-unique bots to dbl might not necessarily be a good idea. there is already an oversaturation of mediocre non-unique bots
- mention how important it is to secure your token before publishing to github
- the server recommendation part includes too many information that a beginner might not know or care about, such as ip addresses, bandwith, custom image support, etc.
- as vysion said, sharding
idk about sharding for beginners lul
^^^^
@mossy vine Thanks for the honest feedback. The servers part I said was for when you get more advanced, and I don't think sharding is anywhere on a beginners mindset, and as a mod for DBL we are supposed to encourage adding your bot so I added that in there. It doesn't really matter if they are all the same, its just we want to welcome them type of thing. I will take a look tho. Thanks 🙂
Docs going up on gitbook soon
@abstract crow my feedback
- better formatting: text is hard to tell apart (lists, etc)
- w3schools isn't really a good resource
- like cyber, tell people to think about what other tusers would want before creating a bot to avoid generic bot making
there are some very generic ideas at the bottom
i should make an entire seperate guide for sharding
djs docs don't cover it
well*
discordjs.guide covers it very well tho
hmm
@abstract crow that is a nice website
Well it really isn't my website, but rather just a guide hosted publicly but thx
i know but its good for begginers
Thanks 🙂
@abstract crow can I see?
@abstract crow can you invite me as a collaborator, i could help format the docs 
Can't I have to get pro
f
nvm got a trial
has anyone some ideas for my bot / what i should add?
Bc im stupid and cant come over with original ideas
Check pins
how to do an prefix with space between prefix and command?
Should a movie command be limited to NSFW Channels ?
- General: if it can return nsfw info, yes.
- Woah: Add a space at the end of the prefix (assuming it's in a value or something)
I have an idea.
You can have webcams on discord servers. When Fred boat joins and in a webcam call it should try to make it show the video. Just an idea
we arent really a suggestion discord @glad herald 🤷
well do something with that idea. Its a great idea.
no, bots can use streaming/purple status, but broadcasting video to a channel is only for users @earnest phoenix
also yea we aren't the fredboat support server @glad herald
Aight!
how fast can a bot change game status online status and pfp on milaseconds?
@soft eagle absolute minimum is 12 seconds. But we would prefer that you do something like 120 seconds
i have game as 1 minute, status 3 minutes and pfp 1 hour
thats good @soft eagle
@earnest phoenix every 15 minutes or so you can change the pfp
That‘s nice didn‘t know that
how would one go about formatting a database update of a key in "whatever.key.etc" into the actual update object
so like set("thing.value", true) would do update({thing:{value: true}})
if your input is a string, you can split it on "."
and iterate over the array and build a json obj
another option is to use eval
but how would i be able to go even further
like "whatever.thing.otherthing.value"
like idek where to start
a recursive function or a loop
im trying a for loop but im lost in how i can go into a newer object
if you split it on dots, you get an array, you can loop over it infinitely
like i can get it like {a: {b: value}} but not {a: {b: {c: value}}
the issue isnt making the loop ive no idea the logic behind how i could actually do what i need
What about setting the value after cuz that was the big part for me? I guess checking against the index and seeing if it’s the last one?
That would probably make the most sense
wew one more day
Reviewed the bot rules again (cause i forgot half of them)
Bots will receive a mute if they:
• Spam testing channels
does that include if the bot is commanded to spam? (ex: pref!spam "text" 12)
yes
okk
spamming is not allowed
good to know
@jade thistle if you have a spam command in your bot, its going to get declined
thank you
thanks for the explaination
guild.owner returns a member or an user?
returns the owner as a member of the guild iirc
Ok ty
i heard that it is possible
What's the best way to add a timeout to eval()
so for example if i start an infinite loop, it will timeout and stop after 10 seconds or so
pretty much to any code
the only way i see to do that would be to run the eval in a worker thread or a child process
what's like the best way to do image manipulation with nodejs?
yeah i worked with it a little and didn't really understand it so i was just wondering if there was something better lol. thanks though,, time to learn c a n v a s
its not dumb lul
there are alternatives tho, if you want easy to use but terrible performance, go for jimp
if you want best performance but difficult to set up, go for sharp
I hate working with canvas because it's more complicated than it needs to be
if you want flexibility and full control, go for canvas
if you want to go external, go for graphicsmagik or imagemagik
i like working on canvas because it lets me do literally anything i want
Do you guys code directly off your server or just locally?
Locally, generally use git local build/test and CI pipeline to build docker image and push to prod when merged.
No I meant like beta
even still
I didn't know if that was easier in case you are on the go and forgot to push on github
I'm pondering ways to bypass the 100 message limit on TextChannel.bulkDelete in discord.js. I've thought of just getting a huge collection, filtering out old messages, splitting up the collection into pieces of size 100, then using a for loop to await bulkDelete each piece. Does this seem like a decent idea, or would it ultimately fail?
isnt that just api abuse
Maybe
The max is discord imposed afaik
SamuraiStacksToday at 12:04 AM
isnt that just api abuse
it isn't
api abuse would be to automate that process and keep it running for x amount of minutes/hours
some libraries do the same as proxxa proposed; split the requests into batches of 100 messages/request
ok im just dumb
the problem comes when you need to do filtering
https://vinniehat.is-inside.me/ZDvfhCaM.png Would anyone happen to know why the if statement goes through?
you're assigning it, not comparing
^
omg I am so stupid
big brain
thx guys 🙂
https://vinniehat.is-inside.me/zavYNuSb.png moola time 🤣
jk I just want to implement it for the future. Thanks though guys. I am so stupid lol
I also make if statements for 1 line things like this https://vinniehat.is-inside.me/Bg4Y8pT0.png which is stupid so I am going to make that all one line
I said I was going to make it one line now lol
if(thumbnail) newEmbed.setThumbnail(thumbnail);
i mean if you have trouble reading code it's not wrong to place brackets to distinct it
huh
Good point. Its just I want cleaner code, so for me it isn't about lines or anything, but I want to learn and utilize Javascript in how it usually is coded in
I like keeping the brackets even if it's one very short line.
but I hate this:
if (true) return true;
else { ... }```
"e"
Nikki, you referring to the screenshot SamuraiStacks posted?
bonjour
jai une question urgente
je voudrais metre un bot sur mon discord et qu il me dise les kilometre sur le discord
les kilometre de eurotruck simulator
yesh @limpid flower
P sure it says e because in the if statement, it actually sets e to "e" instead of checking if e is "e"
yeah ik
Hey new to bots here. I want to add the Mudae (Mudamaid) bot to my server how can I
qt faq 1 -c @paper dagger
2b join
does someone know how to make a bot send a message whenever a youtube video is posted in discord.js
I dont know if you can do it as soon as it's uploaded, but if you use the yt api, you can get the latest vid of a creator and see if it's the same as the last time you checked
I'd just have that on an interval every so often
@amber fractal Seems like api abuse
That's better than what I thought you meant
Is this a good way to organize stuff in Trello?
I'll take a look. Thanks 🙂
@toxic oracle notion is more for wiki kind of stuff tho
@abstract crow i use clubhouse for task tracking. ive also heard that asana is decent
oo clubhouse looks pretty
@hushed berry it has good support for literally everything
i know that because i use it in a lot of different cases
I mean I have heard of notion I think and I have also heard of Asana but never ClubHouse. I don't get the stories part though
Is anyone here proficient with fluxlang?
I don't do js but isn't it like const <name> = require("discord.js");
I thinks it was const require = ("discord.js")
it is const <name> = require("discord.js");
How mine is setup:
const Discord = require('discord.js');
const client = new Discord.Client();
No..
I made it like that
do it like this
ok
const Discord = require('discord.js')
yes
variables are case sensitive. you should probably learn some basic javascript first
and its not the id the goes there, its your bot token
That sounds like a funny thing to do
Make client.login support IDs but require token when the script is run and then if the ID under entered token does not match, close the program
For activate the bot ? What i'm suppose to do ?
run the code?
(node:6230) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat '/app/ImageGenv2'
const Discord = require('discord.js')
const { get } = require('snekfetch')
module.exports.run = async (client, message, args) => {
let url = `https://nekobot.xyz/api/imagegen`;
get(url)
.query({ text:`${args.join(' ')}`})
.end((err, response) => {
message.channel.send({ file: response.body.message })
})
}```
Nvm fixed
psst, snekfetch's deprcated. Maybe use node-fetch 👀
Im trying to make an Setbio Command but it dont saves it.
const mongoose = require('mongoose');
const botconfig = require ("../botconfig.json")
mongoose.connect(botconfig.database, { useNewUrlParser: true }, err => {
if (err) console.error(err);
console.log(mongoose);
});
const RP = require('../models/rp.js');
exports.run = async (neko, message, args) => {
if(args[0] === "setbio") {
const NewBio = new RP({
bio: args[1]
});
await NewBio.save().catch(e => console.log(e));
message.channel.send("Succes")
return
}
RP.findOne({
bio: args[1]
}, (err, bio) => {
if (err) console.error(err);
const memberInfo = new Discord.RichEmbed()
.setAuthor(`${message.author.username}`, `${message.author.displayAvatarURL}`)
.setThumbnail(`${message.author.displayAvatarURL}`)
.setColor("#ff0000")
if (!bio) {
memberInfo.addField('Bio', `Has no Bio`);
}
else {
memberInfo.addField('Bio', bio.bio);
}
return message.channel.send(memberInfo);
});
}
module.exports.help = {
name: "profile",
aliases: []
}
Output:
You're saving the bio and that's it
If you want them linked to a user
You're gonna need to save some kind of reference to the user together with the bio
user id would be perfect for that
const mongoose = require('mongoose');
const botconfig = require ("../botconfig.json")
mongoose.connect(botconfig.database, { useNewUrlParser: true }, err => {
if (err) console.error(err);
console.log(mongoose);
});
const RP = require('../models/rp.js');
exports.run = async (neko, message, args) => {
const user = message.mentions.users.first() || message.author
if(args[0] === "setbio") {
const NewBio = new RP({
bio: args[1],
userID: user.id,
serverID: message.guild.id
});
await NewBio.save().catch(e => message.channel.send(e));
return
}
RP.findOne({
serverID: message.guild.id,
userID: user.id
}, (err, bio) => {
if (err) console.error(err);
const memberInfo = new Discord.RichEmbed()
.setAuthor(`${message.author.username}`, `${message.author.displayAvatarURL}`)
.setThumbnail(`${message.author.displayAvatarURL}`)
.setColor("#ff0000")
if (!bio) {
memberInfo.addField('Bio', `Has no Bio`);
}
else {
memberInfo.addField('Bio', bio.bio);
}
return message.channel.send(memberInfo);
});
}
module.exports.help = {
name: "profile",
aliases: []
}
is that better? @late hill
yes
but setbio will allow people to create multiple bios
and fill up your database
So you should do something about that
but what
Instead of always creating a new entry
You can check if there's already one created
If so, just edit that one
but how

Use findOne in your setbio to check if they already have one
if yes, edit the bio, save
if no, create a new one

just assign it to some unique key
like guildID+userID
or just userID if its not guild specific
i can see that you're already using them, there should be a way to set them as the primary key no?
so if they already exist, it will be updated, if not, it will be created
any Example please?
i dont use mongo
but looking at their docs, you should be able to achieve that by creating a unique index
Using Mongo's unique indexes will most likely throw an error when you try to create another document with the same index
So you'd still have to check yourself
he should be able to use update with upsert:true
instead of insert
but i dont use mongo so idk
also depends on how mongoose handles it
you should look into the mongoose docs
Who say how fix skip/next command (he skip all songs)
DJS, Am I better using sharding or cluster?
I’m using quick.db leaderboard on my website but all the data is all in one line how do I make it like 1. Is in a box 2. Is in a box ect
?
Anyone Knows how i can Update an Object in MongoDB?
.findOneAndUpdate()?
.findOneAndUpdate({ name: "Old Name" }, { name: "New Name" }); iirc
Guys, is it possible for discord bots to listen to the voice activity. If yes, child you please provide links to where I can learn more about this? If yes again, please provide those links.
i tried :
<div class="card-columns">
<%for (var i = 0; i < resp.length; i++) {%>
<div class="card">
<h3 class="card-header"><%=id%></h3>
</div>
</div>
<% } %>
resp.length is = 10
id is = to the IDs of top 10
but all the IDS are all together how to i push each ID to a sepearate card / box
<div class="card-columns">
<% for (var i = 0; i < resp.length; i++) { %>
<div class="card">
<h3 class="card-header"><%=id%></h3>
</div>
<% } %>
</div>``` try this @earnest phoenix
@quasi forge what library?
Serenity
hmm
EJS
serenity I'm not sure about
Welp any is fine, I can understand the basic theory and I might be able to translate. @west raptor
maybe theres something wrong with your css?
because code looks just fine
seperate divs for each ids
hm
when you say "listen to voice activity" do you mean detect when someone is speaking or like take-in what they're saying?
Welp, I am quite familiar with d.js I just wanted to y'know feel adventurous
yeah understandable
That's why going for serenity
How to Update Objectssssssss in MongoDB? 😩
hf with rust and stuff
@stray garnet lang
@quasi forge d.js
Lib?
speaking on serenity i need to update the docs link in pins
const mongoose = require('mongoose');
const botconfig = require ("../botconfig.json")
mongoose.connect(botconfig.database, { useNewUrlParser: true }, err => {
if (err) console.error(err);
console.log(mongoose);
});
const RP = require('../models/rp.js');
exports.run = async (neko, message, args) => {
const user = message.mentions.users.first() || message.author
if(args[0] === "setbio") {
const NewBio = new RP({
bio: args[1],
userID: user.id,
serverID: message.guild.id
});
await NewBio.saveAndUpdate().catch(e => message.channel.send("e"));
return
}
RP.findOne({
serverID: message.guild.id,
userID: user.id
}, (err, bio) => {
if (err) console.error(err);
const memberInfo = new Discord.RichEmbed()
.setAuthor(`${message.author.username}`, `${message.author.displayAvatarURL}`)
.setThumbnail(`${message.author.displayAvatarURL}`)
.setColor("#ff0000")
if (!bio) {
memberInfo.addField('Bio', `Has no Bio`);
}
else {
memberInfo.addField('Bio', bio.bio);
}
return message.channel.send(memberInfo);
});
}
module.exports.help = {
name: "profile",
aliases: []
}
code
@quasi forge I meant Js
Mongoose. Lemme get the link
use the mongo docs
cant find anything there
Personal recommendation tho, don't use mongoose, it's slow af
same db, different library
I agree with Steven
That one is officially made by MongoDB and it's optimised for production purposes
@quasi forge ah I might have found something
API documentation for the Rust AudioReceiver trait in crate serenity.
mongoose worked fine with my 50k server bot tho
Did you try using mongodb tho
findOneAndUpdate() so i would use that insetad of findOne()?
Yes
Ok
nah but it's like 200us why would i use different library to get 100us faster time
i prefer async functions btw @stray garnet
It's more like 40-50ms
and connecting to mongodb on each command is not good i think
i only had one connection and moved that through all of my commands
^
I connected in the ready event and added it as a variable to the client
thats even more stonks
so like client.db
using client is smart
It's the variable that should be in all of your bot related files 
resp[i].ID.slice(5) how do i convert that to a username ?
that gives the ID resp[i].ID.slice(5)
well you get can the user object from discord if your website is connected to your bot somehow
client.users.get(resp[i].ID.slice(5)) i think
why doesnt the client.fetchUser(resp[i].ID.slice(5)).username work?
try js client.fetchUser(resp[i].ID.slice(5)).then(u => u.username)
your one works
or js // only if your function is async const user = await client.fetchUser(resp[i].ID.slice(5)); return user.username
uhh
<%=client.fetchUser(resp[i].ID.slice(5)).then(u => u.username)%>
because fetch returns a promise
yep
you could (await ...).username
any way i can define it
await is not possible in ejs by default afaik
:/
i suggest you do that back in your code
Hello everyone!
I have a problem that happens more and more frequently.
I have an event called "guildCreate" and another called "guildRemove" and the problem is that it gives false positives, that is, it says that "x" server has expelled it (and coincidentally one of them I manage it) and then says it has been added.
I know they are false positives because something appears with this scheme:
guildRemove, guildCreate, guildRemove, guildRemove, guildCreate, guildRemove, guildCreate, guildCreate, guildCreate (Logically with the same server ID, same owner and same number of members)
I use discord.js
EDIT: Right now this is happening
<%=client.fetchUser(resp[i].ID.slice(5)).then(u => u.username)%>
returns
[object Promise]
const user = await client.fetchUser(resp[i].ID.slice(5));
response.render("something.ejs", {
userObject: user
});
/* ^^ is not gonna work */
``` i prefer doing it like this in your express route
nice
object Promise?
@twin kestrel its because the guildRemove and guildCreate events are fired when a server looses connection and then goes back online.
i don't know much about discordjs
they are also fired when the bot is kicked/added to a server
Seriously? Well, it happens to me constantly
thats what i think is the issue
Thanks I will try
@twin kestrel this is specified in the actual discord docs
discordjs doesnt differentiate those two occurrences by default
which is poopoo
K
huh
oh kewl
i guess people just dont wanna update
or people are using the wrong methods
i use v11 :(((
let me check v11
and yes discordjs does differentiate it in v11 too
it does in guildCreate, but im not finding anything in the guildDelete source lul
ah i found it
oofers
its handled in actions/guildDelete
<%=db.fetch(`short_${resp[i].ID.slice(8)}`)%> that returns objectPromise how do i get the data?
same as you did before
just do what EGGSY posted
i put that code in dashboard.js as well await db.fetch(short_${id})
but it only gets the top data
not everyones
``` db: await db.fetch(short_${id}),
for (var i = 0; i < resp.length; i++) {
resp.length = 10
console.log(resp)
is = resp[i].ID.slice(8)
so db only contains one item?
needs more context tho, i dont know what your code is doing with only those snippets
// in your route:
const IDs = new Array(),
users = new Array();
for (var i = 0; i < resp.length; i++) {
IDs.push(resp[i].ID.slice(8));
}
IDs.forEach(id => {
const user = await client.fetchUser(id);
users.push(user.username)
});
response.render("page.ejs", { users });
// in your EJS file (` = for coloring):
`
<% for (var i = 0; i < users.length; i++) { %>
<div class="card">
users[i]
</div>
<% } %>
`
// NOT SURE ANY OF THIS IS GONNA WORK
``` i dont really have time right now sorry this is all i can do for now
and i bet there are better ways to do this





