#development
1 messages · Page 855 of 1
It's definitely using a webhook, you can change a webhook's name and avatar for every message
Ok, I'm trying to write a function that gets parts of a string based on start and end values. Here is what I have so far:
function getStringPart(string, start, end) {
var r_string = {};
for(i = start; i < end; i++) {
r_string[i] = string[i];
}
return r_string;
}
In stead of returning a string it returns something that resembles a C++ Map container. I don't really know JS well or how it handles strings so if anyone knows a better way to do this.
you can use regex? Can you give an example of what you are trying to do
you are returning an object (r_string is an object)
Is there a way to get it as a string?
would something like to_string() work in this instance?
For the example you gave, you can do what most people do which is splitting on spaces
Wouldn't that split the message too?
yeh but you see
@fallow quiver you're trying to get a substring based on start/end indexes?
Yeah
the other 2 values are always going to be 1 "word"
you can simply use string.slice() or string.substring() or string.substr()
so you can simply join the rest back together
Hi, does someone use sequelize as db?
I do
Could I also use commas as separation characters instead of whitespace?
Sequelize is something like a wrapper for a bunch of databases actually
yeah you can
yeah I know, I just mean that
you can delimit a string with any character or pattern using string.split("char")
I made a level system but the problem is that it's not unique for the server
Ok, I'll look into it, thanks
that will give you an array/list, not a string
If my name is jhon and the rank in this server is 5, the rank of jhon is 5 also in other server
and obv also for others "jhon"
how do you handle that?
i thought about an hashMap
you need to make a separate ranking for each guild
yeah I know
yeah, does your user table have a row where you store guild ids?
yup, it's global
global can be pretty handy sometimes
coz server levelings are annoying when u are like lvl 50 and u get banned, or server oofed
mmm honestly i don't find it a usefull feauture
yes but maybe you have the same name of another person
in another server
and this create conflict
if u are doing names
$('#save').on('submit', function(e) {
e.preventDefault();
var formData = $(this).serializeObject();
$.ajax({
url: '/<%= serverid %>/save',
type: 'post',
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify(formData),
success:function(data) {
if(response == "ok"){
document.getElementById("resp").style.color = "green";
$("#resp").text("Saved Successfully.");
}else{
document.getElementById("resp").style.color = "red";
$("#resp").text(response);
}
},error:function(error){
console.log(error);
}
});
});
im trying to send a request via ajax with json. the request is getting made and a error is getting logged but the request is working, thats what i get from the console:
readyState: 4
getResponseHeader: ƒ (e)
arguments: (...)
caller: (...)
length: 1
name: "getResponseHeader"
prototype: {constructor: ƒ}
__proto__: ƒ ()
[[FunctionLocation]]: jquery.min.js:2
[[Scopes]]: Scopes[3]
getAllResponseHeaders: ƒ ()
setRequestHeader: ƒ (e,t)
overrideMimeType: ƒ (e)
statusCode: ƒ (e)
abort: ƒ (e)
state: ƒ ()
always: ƒ ()
catch: ƒ (e)
pipe: ƒ ()
then: ƒ (t,n,r)
promise: ƒ (e)
progress: ƒ ()
done: ƒ ()
fail: ƒ ()
responseText: "ok"
status: 200
statusText: "OK"
__proto__: Object
any idea of how can i fix it?
That doesnt look like an error
status: 200
thats what i get from the console...
That looks like the request object
if i use only success and console log it, nothngi happens
if i do
error:function error and i console log it
thats what i get
idk why
status: 200 thats not an error my guy
while im here can anyone explain what the watching activity is?
is it 3 just not mentioned in api docs?
i know its not cuz the request is working
thats what i said
but why its sending it with the error object
Okay so my bot has to update like over 2300 channels in 183 guilds periodically - but every time I do this is vastly slows down when it gets about halfway done and sometimes just stops due to "socket hang up" and the "ECONNRESET" error. Anyone know how to circumvent this? I'm using the async functions to edit the channels and waiting for them before editing another etc.. I just expected it to take as much time as it needed and keep going, like waiting until it can do it; instead it just seems to stop. How do I fix this?
Hi guys, so I made this eval command in discord.js and when I run the code on my laptop it works perfectly, but when I run it on my free hosting service, it says that message and client are not defined
@earnest phoenix thats considered api abuse and is against the discord TOS
soo... what do you do?
why do you even need to update that many channels?
because the channels show information that needs updating
like that member count bot
that is bad design
so what do I do instead?
you shouldnt be doing that at all
if you want something like that, make it only 1 channel per guild, and space the updates by at least 1 minute
wait so how do the other bots do it then?
In discord.js
How do I detect how long a cooldown is left
Do I have to use a specific cooldown system?
it has these voice channels
and a hell of a lot more servers than me too
Can't I just artifically slow it down and purposely make it go for a longer period..?
it's not like it needs to happen often
on a server-by-server basis that is
@earnest phoenix if you really want to update a lot of channels then add a delay of multiple seconds between every channel update
Anyone here have any experience with node-cron? I want to check if my syntax is right but I want it to run at the start of each month so I'd have to wait 25 days to see if it works lol
This is the interval I've written for that: 0 0 1 * *
If anyone knows if that will run at the start of each month or not that would be helpful
you could try it by setting it to 0 0 6 * * and if that runs midnight then it will also work the 1st of the month if you set it to 1
Is that really the fastest it can go?
Oh thanks both of you
you're gonna run into global ratelimits pretty fast too
because that means these other bots would be literally impossible to create
by my knowledge..
@earnest phoenix you want to make sure your bot never rate limits and while updating channels you still want to handle other commands/requests
What do people use to host their bots?
Yeah that's what I was wondering, how do I know when I've hit the limit and need to wait..?
@amber fractal Thanks that's really helpful
Because I have been using repl.it with uptime robot for ages and it is free good hosting.
@slate quail I host one bot on my NAS at home and one bot on a VPS
Ah
"good" is a relative term
@earnest phoenix you can ask them how they do it, but i wouldn't update more than once per minute
you're very limited
..right
Very low ram, no read/write access, you'd have to use hosted databases
probably not a lot of storage
everything is "good" if it is free, because you can't expect anything
Does it?
At least for python
I mean, it is that or using a raspberry pi zero w in my situation. If we are talking free
I would use a RPI over free hosting
Why?
You could always look at "free" trials of certain services such as gcp or aws
I have stable internet and I have full control over a RPI
@earnest phoenix there's definitely better ways than a simple loop going through all channels with a delay inbetween
You should make sure that you're not updating something that hasn't changed
You could also have it update only if a "certain amount" of change has been hit
I am running a flask web server with uptime robot pinging it every 5 mins to keep it online
In the background of my discord bot
Either way it's just dumb design that missuses channels for things that don't even matter
you have to send that data, top.gg doesn't just know and #topgg-api
@blissful scaffold Would dividing it among shards make it able to do more? Or is that not how shards work
because I always thought the other bots could do it because more shards meant less limits
I never used shards, so I cant tell you if that will work
Right
@latent ocean you want to take a look here:
https://top.gg/api/docs
the api will let you send the number of servers to top.gg
guys i have a problem when i use Discord.MessageEmbed();
(node:7821) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function
at Function.normalizeFields (/home/pi/bot/test/node_modules/discord.js/src/structures/MessageEmbed.js:436:8)
at MessageEmbed.setup (/home/pi/bot/test/node_modules/discord.js/src/structures/MessageEmbed.js:70:91)
at new MessageEmbed (/home/pi/bot/test/node_modules/discord.js/src/structures/MessageEmbed.js:11:10)
at embedLikes.map.e (/home/pi/bot/test/node_modules/discord.js/src/structures/APIMessage.js:164:40)
at Array.map (<anonymous>)
at APIMessage.resolveData (/home/pi/bot/test/node_modules/discord.js/src/structures/APIMessage.js:164:31)
at TextChannel.send (/home/pi/bot/test/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:166:62)
at Client.client.on.msg (/home/pi/bot/test/index.js:36:21)
at Client.emit (events.js:189:13)
at MessageCreateAction.handle (/home/pi/bot/test/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
(node:7821) 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:7821) [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.
update node js
v10.15.2
@blissful scaffold merci
oh i see
d.js v12 requiring node.js v12 or higher @earnest phoenix
@earnest phoenix shards have their own rate limits but only for websocket requests, not for REST requests
REST requests are global across all shards afaik
What's the difference?
request guild members 
oh
channel edits are REST so they will count for global limits
you could make something like a queue per guild
listen to events, and every time an event happens that changes the stats, add an update to the queue, if the queue is empty, process it immediately
else, it will wait in the queue
although per-route rate limits are applied to channels, not guilds, so having a per-guild queue wont help much
how did you update?
apt
apt's node version is old af tho
I suggest use NVM
can you set a bot to dnd
yes
bc my bot doesnt set to dnd it only sets to online and idle
what is your lib
but thats the problem im doing it right and nothing happens
also im pretty sure some versions of node.js v11 can work with d.js 12
In discord.js
How do I detect how long a cooldown is left
Do I have to use a specific cooldown system?
i could be thinking about npm idk
I use Sets atm
and after a while the cooldown will be set to false
But I wanna know how much time is left on it
maybe something on npm
Save when the countdown started (in ms) and how much seconds it is
I have found this
this is probably what he needs
go on and fork dat out of stackoverflow cuz who doesn't I do it every day
Math.round((started + cooldown) - Date.now()); should do the job.
started is when the cooldown started in milliseconds
cooldown is how many milliseconds the cooldown lasts
That will return the time between in milliseconds, divide by 1000 to get the seconds and maybe round it then
contact a mod i guess
epic
i mean, it's probably safe right?
look at the top "lean"
"Join servers for you"
it kinda seems like a self bot just from that screenie
not safe I think
^ strong agree
It looks like a bot to replace your entire existence on Discord.
So i have this command called cookies where it checks how many cookies you've got in the cookies.json and sends an embed of it...
But it works on the mentioned users and you can't check your own cookie amount... When you check your own amount it says can't read the property of 'id' of undefined...
Aren't i supposed to write:
message.author.id
For my own or the message's sender's id?
message's author
Yea yea
@summer torrent so check my code up there... Why does it say can't read the property of 'id' of undefined?
@earnest phoenix can u send ur code
🔭
Bruh scroll up @finite bough
@summer torrent so check my code up there... Why does it say can't read the property of 'id' of undefined?
@earnest phoenix which line
Hmm @summer torrent
🧐
That error confused the shit out of me literally...
I mean it's just one error but i used the command 2 times and it printed the error 2 times @finite bough
ok that console is too clumsy
(the 3rd is a permission error which was probably from a server that my bot joined but didn't had permission)
So how's it undefined?
is message defined?
In none of my commands it's undefined but it's just undefined on this one... Somehow...
@finite bough ???
Isn't message a function?
Like let message = "bruh" or something?
nope
Then what do you mean by it?
client.on("message", message =>{
That's on the very very top
message.channel.send("bruh")
check the brackets
@finite bough i literally don't see any issues with the brackets
Are you guys literally talking about this?
@elder vine i try that... Still nope
I can't properly see
^
What version of djs do you use?
12.1.1
Alright, good.
doesnt rlly matter rn
So I have a handcuff command with my bot, and what I want it to do is detect if a member has been handcuffed and respond with a message, what I currently have didn't work and I don't know how I would google search it. Its under an if statement, if somebody could point me in the right direction that would be amazing!
Do you use a users fetch?
Nope
Cody, what is the code?
^
case 'bcuff': {
let member = message.mentions.members.first()
var embed = new RichEmbed()
.setTitle('Cuff Test!')
.setColor('#a1ee33')
.setDescription('🔒 ' +<@${message.author.id}>+ ' Has cuffed: ' +<@${member.id}>)
message.delete
message.channel.send(embed)
var handcuffed = 'cuffed'
if(member.id, handcuffed = true) {
message.channel.send("You can't use commands when in cuffs!")
} else {}
break;
Here is my code.
What line is the error on?
No error.
What is the error?
I wonder how message.author.id can be undefined...
Like what...
Just doesn't do what I am looking for it to do.
@elder vine i mean scroll up and see my code but here
Does it do anything?
So say I ran /cuff @granite pagoda, what I want it to do if said use tries one of the commands I want it to respond with "You can't use commands while you're in handcuffs!"
what line is the error on?
Yea
@earnest phoenix
but how would it know if it was cuffed?
I want it to do something when someone else that is cuffed sends a message.
You need to store the cuff then.
@quartz kindle yea?
in a database or something.
return; @stable nimbus
@earnest phoenix you're checking for message.mentions.users.first().id
regardless if a mention exists
How to check if an invite exists by a certain user?
discord.js
my bot is really getting ratelimited rn lol
@quartz kindle so what would i do instead of that?
<Invite>.inviter
first check if a mention exists
wheres the collection of invites? is it in channel?
Oh ok that would make sense... @quartz kindle lemme check
let mention = message.mentions.users.first()
if(mention) { do stuff } else { do other stuff }
all other logic comes after that
like how do you get invite? from a channel?
like channel.invites.find("inviter", "Name")
v12
guild.fetchInvites()
.then(invites => console.log(Fetched ${invites.size} invites))
Does fetchInvites() get ratelimited?
@quartz kindle still the same can't read the property of'id'of undefined error...
Hmm...
@earnest phoenix
you should put ALL mentioned user logic inside the if(mention) block
and ALL user logic on an else
Idk how does that work or mean... Can you show me? @quartz kindle
Wait... Why on that if(mention) tho?
That works...
There's 2 of them
let embed = new MessageEmbed();
if(mUser) {
if(!cookies) { do cookies }
let cookie = cookies[user]
embed = embed.bla().bla().bla()
} else {
if(!cookies) { do author cookie }
let cookie = cookies[author]
embed = embed.bla().bla().bla()
}
channel.send(embed)``` @earnest phoenix
Hmm good idea but that do cookies and do author cookie... Wdym by that?
Like create a cookie profile for them that doesn't have cookies? @quartz kindle
yes
Oh ok... Lemme try that
xD
thats what i mean by placing ALL logic in the same scope
you dont need 3 IFs, you can organize everything in one IF
^
@quartz kindle (sorry to mention) but the code I showed earlier about the invite thing (with the weird timeout) its getting ratelimited as hell
even though im only creating 5 invites
but people use the command alot
Add a cooldown to it
I have a 30 second cooldown
Queue the events
Try figure something out, and we're here to help.
or I can keep all guilds invites in a cache somewhere
instead of requesting them each time
I can just pick them out
and update them every few minutes
Do you have a database?
yeah
Mongo?
nah quick.db
Well, then someone else shall help u :P
@mystic violet are you fetching existing invites or creating new ones?
creating new ones
I want it to create one
and keep it like that
but people keep executing the command
and I dont wanna turn the bot off ;-;
I have a beta bot though
just dont like the ratelimits
bruh its already on 100 servers
not on any bot list or anything
;-;
I made it yesterday
im not sure about the rate limits for creating invites
but its probably much lower than getting them
in any case, after creating one, you should save it somewhere and reuse it
the problem is checking if its still valid
Re-code and fix then.
True
I better do that
ill get started asap
and keep the invites
and remake them like every 2 hours
imo 1s delay between the same type of request is a somewhat safe bet
@quartz kindle also that worked... Thx
Is there ever a time when Tim's solutions don't work
@amber fractal nope... Tim is just the god of resolving errors and codes...
@_@
Im on discord js
How to fetchAllMembers
Because bot.users.size not showing the good numbers of members
use reduce()
@earnest phoenix bot.users.cache.size
fetchAllMembers is a client option. you add it to the client when your create it
you're allowed to hit ratelimits once, but after that you must respect the RetryAfter header, if you don't - that's where it gets problematic
but fetching all members uses a LOT of ram
Hmm
you can get an accurate user count if you join together the guild.memberCount of all guilds
bot.users.cache.size doesn't work
Its for show all members of all guild in a message
you want to show only number of members? or also usernames?
then join together the memberCounts
guild.memberCount has the accurate number of members a guild has
you need to loop over all guilds, and add together their memberCounts
Okey
can you reduce on guilds?
yes
but. what about users in multiple guilds?
using a reductor function is the most efficient way
users will be duplicated
nothing you can do about that
also why would you make your bot look worse
Tim doing a great job.
well, of course you are not supposed to use guild literally
you need to get the guild from somewhere duh
like message.guild if in a message event
No look my code
Wait
2 min plz
But how's it possible to get all the guilds that the bot is in and fetch it's memberCount? @quartz kindle
.addField("Utilisateurs 👶 ", `${guild.memberCount}`, true)
Look
That hurts.
i told you
you have to get the guild from somewhere
not literally use guild without context
@earnest phoenix you can loop over all guilds
Like fetch the guilds id... And then use it in the function
a for loop, or a forEach, or a reduce
@earnest phoenix you can access ALL guilds from client.guilds
where client is the name you gave to your client
if you use bot, then its bot.guilds
then you can either use a for loop, or use .forEach() with a counter, or use .reduce() with a function
Wait was guilds not changed to a GuildsManager?
client.guilds.cache
by default all guilds are cached yes
So you can uncache it then?
lol
unless you use workarounds
.help
i die inside a little bit everytime i see ! . - ? being used as a prefix
Can someone say me why my nodejs stopped working?
not without an error
But i get no error 😅
Nothing just happens
Neither nodejs, nodemon nor npm work
how do i make my commands insensitive?
What du you mean @earnest phoenix
i think hes talking about upper/lowercase
that it doesnt matter
like -help and - HeLp
yea i think
@earnest phoenix install nvm (check their github for instructions)
and install node using nvm
Anyone know how to easily "record time" in nodeJS? Like set a timer going, run some code, and then resolve it or whatever and get the amount of time since starting it and resolving it?
there are many ways to record time
process.hrtime(), performance.now(), Date.now(), console.time()
all of those can be used to record a time, and then compare to a second recording to get elapsed time
I tried this, it gives me a collection back, but it doesnt show the invite the bot made
message.guild.invite = Bot.invites[message.guild.id].filter(invite => invite.inviter.id == Bot.user.id)```
this is the Bot.invites
Bot.guilds.cache.forEach(g => {
g.fetchInvites().then(guildInvites => {
Bot.invites[g.id] = guildInvites;
})
})```
using .forEach with async code is a very bad idea unless you want paralelism
are you looking it up right after creation
if you have 100 guilds that will send 100 requests at once
and get you rate limited
a for loop with async/await
not sure if collections can be iterated directly, but you can try that yeah
for(g of Bot.guilds.cache) {
g.fetchInvites().then(guildInvites => {
Bot.invites[g.id] = guildInvites;
})
}```
so like that?
no, let invites = await g.fetchInvites()
and for async(g of guilds) {
the await there will pause the loop until a value is returned. a .then will not pause it
no, thats invalid
the loop needs to be inside an async function
okay cool
Idk how you dont lose your mind in here tim
im pretty stupid when it comes to loops lol
says g.fetchInvites() is not a function
async function RegenInvites(Bot) {
for(g of Bot.guilds.cache) {
let guildInvites = await g.fetchInvites()
Bot.invites[g.id] = guildInvites;
}
}```
hmm
It's a promise
wdym
let g of bot.guilds.cache
async function RegenInvites(Bot) {
for(let g of Bot.guilds.cache) {
let guildInvites = await g.fetchInvites()
Bot.invites[g.id] = guildInvites;
}
}```
doesn't work
do you mean
like g = ""
before the for
or something
(node:7996) UnhandledPromiseRejectionWarning: TypeError: g.fetchInvites is not a function```
yep
where are you running this function?
Oh wait
on the guide
it said to wait
1 second
on ready event
to create invites
wait i found why
when you loop over a collection using for of it iterates over entries, like Object.entries()
so g is [id,guild]
oh, 🤦
so I would be guild = g[1]
yes
Yep it worked
thank you
so much
!!
So. again with that filter command (lol im so sorry)
message.guild.invite = Bot.invites[message.guild.id].filter(invite => invite.inviter.id == Bot.user.id)```
it isn't responding with any invites
console.log(Bot.invites[message.guild.id])
yes @earnest phoenix and @earnest phoenix, is there a way to make the commands insensitive?
lib?
again, you're talking about stuff like "THIS" and "this" right?
that it gets ignored
that it gets ignored
yes hope
lib
pls
discord.js
To make commands not work?
tim?
no i want it to work regardless of the caps, so if someone does help or HeLp it executes the same command
.toLowerCase()
make it toLowerCase() in cmd handler
@earnest phoenix it does not matter if !bla or !BLA or !blA
okay thanks everyone
sure
No problem, hope it helped.
gladly
<collection of invites>.filter(invite => invite.inviter.id == Bot.user.id)
why doesnt this work
Is the invite fetched?
Yes
@earnest phoenix what kind of bot you do program?
Can you use "bot's id here", to see?
@earnest phoenix a bot that has everything, Fun commands, misc, moderation etc.
thank you for trying to help my ignorance lol
xD
@noble egret tf
Any error?
What is it supposed to do?
nothing appears in console
@elder vine
i want to send data to express
but nothing appears in console when send data
any logs on the browser console?
try $("form").on("submit") instead of $("#save_perData").on("click")
put a console.log at the beginning of the function to see if the function is working
tf is this?
(node:24089) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
yep, i'm try this change #save_perData to form and use console.log in top code and put console.log("working") first this function and show the working but ajax is not working
The bot has missing permissions @high bough
What did i miss?
@slate pilot btw cache not cashe
yep, i'm try this change
#save_perDatatoformand useconsole.login top code and putconsole.log("working")first this function and show the working butajaxis not working
but i see this value in file app.js
check the network tab in the browser console before you click, see if there is a network request
Where is id="numbers" stored?
https://nmw03.is-inside.me/W8931znC.png
https://nmw03.is-inside.me/N8BwKA4o.png
I do not understand this
I'm making a starter bot (just trying to learn) and im getting this error:
@scarlet hill Currently, almost everyone is having problem using js this.commands.filterArrayIt's better not to use it.
I don't know where i am using it though/how to not use it
Find out the exact line of the code that uses it.
In my shardingManager I keep coming across issues with trying to get the server count for all shards
const manager = new ShardingManager('./indexOld.js', { token: token });
// const DBL = require('dblapi.js');
// const dbl = new DBL(topggtoken, { webhookPort: process.env.PORT, webhookAuth: process.env.WEBHOOKAUTH });
let totalShards = 2;
manager.spawn(totalShards);
manager.on('shardCreate', shard => {
console.log(`Launched shard ${shard.id}`);
console.log(manager);
});
console.log(manager.shards.size);
if (manager.shards.size == totalShards - 1) {
manager.fetchClientValues(`guilds.cache.size`)
.then(results => {
let totalGuilds = results.reduce((prev, guildCount) => prev + guildCount, 0);
console.log("hi")
console.log(totalGuilds);
})
}```
how do you post server count to dblapi using shardingManager?
my basic idea is this:
- get server count for all shards
- divide by total number of shards
- post for each shard id
But I keep coming across issues with fetchClientValues not being ready?
Alternate solution: Just set a timeout for every 30 mins and do fetchClientValues then, because by then all the shards will be ready anyways?
does anyone know what permission a bot needs to fetchInvites()?
manage server
How does the Roles position work? Like if I would do for example:
guild.roles.create({
data: {
name: 'Super Cool People',
color: 'BLUE',
position: '1'
},
reason: 'we needed a role for Super Cool People',
})
Would that role be at the top of the roles?
Hmm, even tho I set that to position: '100' it still comes out in position 1 :[
probably because there aren't a hundred roles
try grabbing the position of the highest positioned role and set that in create instead
How would I get the location of my reader folder? My command is in commands, owner, and eval, and the reader is in src, loaders, then reader, this is what I have which it cant find. const config = require("../src/loaders/reader"); //get data from botconfig file
Error: Cannot find module '../src/loaders/reader'
Is it .json or not?
the shards for my bot are always going out randomly, and I'm not getting any errors. Is there something i can do to keep the shards from disconnecting? (discord.js v12 if it helps)
Might have something to do with this
u will find it in their website
MongoDB
We're the creators of MongoDB, the most popular database for modern apps, and MongoDB Atlas, the global cloud database on AWS, Azure, and GCP. Easily organize, use, and enrich data — in real time, anywhere.
Anyone know how I can send a DM to a user with sharding?
Using discord.js v12
Essentially I want to send a DM to the user who just voted
same method as without?
using webhooks oh
I never managed to do dbl webhooks+sharding
without it I did
client.users.cache.get(vote.user).send(voteMsg);
erm yea
with it, I tried broadcastEval, but it ends up sending multiple messages to the user
if they're in servers that multiple shards are hosting
someone mentioned that
"you could use <Shard>.send() to make one of your shards dm the user"
Is this true? How would dming work with a shard for voting?
apis
Yep
But note some of then don't work properly
ok im trying to send a form via json with ajax. my code is:js $.ajax({ url: '/<%= serverid %>/save', type: 'post', dataType: 'json', contentType: 'application/json', data: JSON.stringify(formData), success:function(response) { if(response == "ok"){ document.getElementById("resp").style.color = "green"; $("#resp").text("Saved Successfully."); }else{ document.getElementById("resp").style.color = "red"; $("#resp").text(response); } } ,error:function(jqXhr, textStatus, errorMessage){ console.log(errorMessage); } }); And the error i get is : ```console
SyntaxError: Unexpected token o in JSON at position 0
at parse (<anonymous>)
at jquery.min.js:2
at l (jquery.min.js:2)
at XMLHttpRequest.<anonymous> (jquery.min.js:2)
any idea of how can i fix it?
the request is being sent and its saving and all i just get this error and idk why
i think i know why
i get from the server side ok
thats what i defined when its working
so maybe thats the o?
thats what i get
Starter here I think its a common
Im getting a message when using node .
node : The term 'node' is not
recognized as the name of a
cmdlet, function, script file,
or operable program. Check the
spelling of the name, or if a
path was included, verify that
the path is correct and try
again.
At line:1 char:1
- node .
-
+ CategoryInfo : O bjectNotFound: (node:String ) [], CommandNotFoundExcept
ion
+ FullyQualifiedErrorId : C
ommandNotFoundException
Im getting this when im trying to code the login part
@woeful fractal download node first https://nodejs.org/fr/
how i can get adidas yeezy and wunders api
I downloaded the node
@woeful fractal "node : The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program." so your node have problems
try to fix install
Should I delete node and reinstall?
yes
@earnest phoenix https://google.com
@woeful fractal BTW what node u installing
Does anyone know what an Error 502 means?
bad gateway
just wait and try again later
I have a small problem, I got a code from someone that made it for me, it worked perfectly till I tried to run it today and got a bad token error, the token is correct tho.
https://http.cat/502 @obtuse wind 
I have a small problem, I got a code from someone that made it for me, it worked perfectly till I tried to run it today and got a bad token error, the token is correct tho.
@distant sky show error and code
Can I DM the code? I would prefer not to send the code here.
yes
I have a small problem, I got a code from someone that made it for me, it worked perfectly till I tried to run it today and got a bad token error, the token is correct tho.
@distant sky
Discord.py (forgot to mention that)
Wondering if anyone would like to point out what I am doing wrong here:
async function updateChannelPerms (array, channelID, permissions) {
console.log(array);
for (var i = 0 i < array.length; i++) {
bot.channels.fetch(channelID).then(c=>{
let userToEdit = await bot.users.cache.get(array[i]));
c.updateOverwrite(userToEdit , {SEND_MESSAGES: permissions});
});
}
}
I'm not great with async/await stuff
array, channelID, permissions
this stuff returns undefined inside the fetch promise, but not out of it, I know I need to use await to fix this, I am just not surely exactly how to utilize it
Check out the JS top.gg API page https://top.gg/api/docs#jslib
You can simply do the guilds cache size. If you're sharding you can broadcast an eval for the guild count and post the total sum.
npm is useless for me 😦
it needs to install the node package, but it needs it to install it
Did you check the process arches to see what they supported?
Did you also try to remove your node modules and reinstall the dependencies?
it needs the "node" folder in node_modules, but it just isnt there https://lumap.is-inside.me/v12wUJa7.png
I tried
but nothing
Yoinks, did you install it wrongly?
I just did npm i
try npm-install-missing
ok
you're not supposed to have a node folder in node_modules lol
what are you trying to install?
just my bot's dependencies
it can't install any module at all
not even upgrade npm
did you install node using nvm?
yes
node -v yes
6.13.7 for npm
I tried hours an hours of google, can't find any solution
literally this one
k
https://lumap.is-inside.me/cyFGtngT.png interesting
I have to install packages 1 per one?
node is dumb
do npm rebuild quick.db
doing it
what is "funding"
idk
donations/patreon/sponsorship
to provide devs with funding and stop package ads
since when are there ads in packages? or in open source in general
it usually just means if there is no funding, development will stop
there were a few packages with ads, i read some articles on it at some point before they implemented npm fund
there was a big fuss
anyways sorry #memes-and-media back to dev speech 
ye
unless you set it via system environment variables, or load them from env files
removed webhooks, works
all you needed was to specify a port lol
ye
managed to open a port with my box aaa
webhooks r bacc
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
npm rebuild err
gyp
Is possible to spawn new shard during session?
For the setInterval is it like this?
@broken jay possible? yes. good? no. should you do it? no
@raven urchin that setInterval is basically doing nothing but wasting cpu
How do large bots handle spawning new shards
Hola
Doesn't it mean that they have to fully reboot basically
just have redundant shards
yes it does
Español
Which takes a long time because of the shards being one each 5s
yes
Me agregan
thats why the only time they increase the shards is when they double them
why do you think most large bots have 1000 guilds per shards
lets them grow for a while before needing to
ie: from 64 shards with 2k servers each to 128 shards with 1k servers each
^^
🖕🖕🖕🖕🖕🖕🖕
@late hillx chupame la polla
habla-se inglés en este canal
@quartz kindle How can I make it so the ${client.users.size} update every 20 seconds?

mete te por el culo @earnest phoenix
@twilit rapids
Nice
Tim do be kinda mad doe 
he started lmao
though i like that they're not using the general chat 
he started lmao
But youre not a kid
i am allowed to be a kid every once in a while


Duane beat u to it timo
@raven urchin js setInterval(() => { // what to do in the interval, ie: setActivity() }, 20000) // every 20000 milliseconds
the code you want to be run every 20 seconds
trying to do what Tim sent. But showed an error.
It's where it just refreshes the users count every 20 seconds
Removing module won't work.
No.
it will get the cached members automatically tho
You would need to set the activity inside the interval function
Oh, lemme try
How would I get the highest roles position of the person who executed the command?
What library and version?
I got it working, thank you!
V12.1.1
No problem
Hi, when editing a message, can you confirm the ID stays the same but the object message itself changes?
Use .highest @earnest phoenix
Yea, ID of message does not change.
So message.member.roles.highest?
I'm kinda new to d.js, started on d.py
message.member.roles.cache.highest?
Oh, Thanks!
No problem
Another quick question. For setStatus. How do we do it? Been trying to figure it out
Read the docs?
client.user.setPresence({ activity: { name: 'with discord.js' }, status: 'idle' })
yea setActivity also works
setStatus is a thing
how do i make all packages reinstall themselves or update?
im on a new project and i dont wanna install them 1 by 1
(pnpm)
npm i
npm WARN deprecated snekfetch@3.6.4: use node-fetch instead
npm ERR! code ETARGET
npm ERR! notarget No matching version found for node.js@^0.0.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'hello-sqlite'
npm ERR! notarget
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npm-cache/8.15.1/_logs/2020-04-06T12_05_34_410Z-debug.log```
how can i know if a message is embed
if(message === ?)
nvm
npm audit fix
So I'm just starting out, what code language should I use?
It is all personal preference to be honest
I see thanks.
guys i need help
in c# dsharpplus
how do i make a music bot? join and leave functions are in, i wanna do something like rythm where it searches from youtube
client.on("message", message => {
if (message.content.startsWith("^slot")) {
message.channel.send(fish = Math.floor(Math.random() * 3) + 1);
message.channel.send(fish2 = Math.floor(Math.random() * 3) + 1);
message.channel.send(tod = Math.floor(Math.random() * 3) + 1);
if(fish === fish2 && fish === tod){
message.channel.send("winner");
}else{
message.channel.send("better luck next time muggle")
}
}
});```
hey could anyone help me put that in a cool down earlier i tried and it didn't work so wel
why are you sending 4 messages lol
How can i check for a channel user permission if you get what i mean?
its a slot machine and i don't know how to put all 3 plus the winner or loser message in one message
Check if the user has VIEW_MESSAGES permission in a specific channel.
oh
Help Cinnamon first.
let fish = Math.floor(...)
let fish2 = Math.floor(...)
let tod = Math.floor(...)
let result = `${fish}-${fish2}-${tod}\n`;
if(fish === fish2 && fish === tod){
result += "Winner";
} else {
result += "Loser";
}
message.channel.send(result)
Tbh that's well written code. ^^
How can i check for a channel user permission if you get what i mean?
Check if the user has VIEW_MESSAGES permission in a specific channel
i had to use switch case for my mute command
d.js?
what was ur problem again?
How can i check for a channel user permission if you get what i mean?
Check if the user has VIEW_MESSAGES permission in a specific channel
(Ticket System)
message.auhtor.hasPermissions? wasnt it that?
yes
Wait
message.member
Do you want to check it in a channel or?
Cache the channel and then check the permission
So like.
u can do it either by
channel.get()
channel.member.hasPermission?
seeing if the role has permission
Not I role i need.
switch is only good if you have 3 or more if-else cases lol
User permission.
client.channels.cache.get(id)
😛
let target = message.channel.permissionOverwrites.get(member);
Would this works perhaps?
@pine aspen channel.permissionsFor(user).has(permission)
hello @quartz kindle how are you ?
gr8
@quartz kindle thank you i was able to use that method to create a dice game
is there any way to make shortcut via cmd?
literally
say i have bruh.exe, and need to make shortcut of it
PATH
get the path location for bruh.exe
did you guys managed to get the command row deleted?


