#development
1 messages · Page 828 of 1
The best way to get good performance in JavaScript is to find a exploit that allows you inject shellcode directly into V8.
The best way to get good performance in JavaScript is to find a exploit that allows you inject shellcode directly into V8.
@sacred knoll #memes-and-media
you're not being constructive in any way
not you pie
Pie are you on a PC or mobile?
pc
Alright. I was just enjoying the lockdown.
you can test stuff on console
Try the browser, The console is the best way to learn.
ok
yez
Yeah
ok
it will work because an empty array can be checked for content
time flies by fast, it's already 12:12am here
yes, i mean the checking will work
the function will not
but the code will correctly check if the value exists and not run the function because the value doesnt exist
The function will call due to it being JS.
does an empty array automatically get assigned to 0
no
an empty array is an array without indexes. when you attempt to get a specific index from it, it will return undefined
now there is
var myArray = [0];
if (!myArray[0]) console.log("happy")```
var myArray = [0]
it wouldn't log
var myArray[0] = 'something'
because you set the array as containing one index that's 0
There isn't a requirement for having that 0 in there, Unless you were trying to see if a specific index had something.
it did
it wouldn't log
@pale vessel it would
it did log
Shouldn't have.*
oh yeah there's !
yes
i have something i learned thats complicated
let me do it
Okay, im back with another question, to get all users from the server my bot is in, do i need a GuildManager or a Guild?
!myArray[0] = !0 = 1 = true
undefined & null & false & 0 all mean false in js
Okay, im back with another question, to get all users from the server my bot is in, do i need a GuildManager or a Guild?
@hidden spindle guild
Cool thanks!
guildmanager is the "settings" menu in the server
oooh
undefined & null & false & 0 all mean false in js
@sacred knoll except they don't
depends on what you compare it with
not the way you said it
if you use them as comparators then yes, they can be false
They are all considered falsy values but aren't equal to false.
but themselves aren't false
here it is
var myArray = [1,0]
var choice = myArray[Math.floor(Math.random() * myArray.length)
console.log(choice)```
I did not mean they are false. But they're falsy.
nice
0 == false -> true
false == false -> true
null == false -> false
undefined == false -> false
undefined and null literally mean "no value"
But !undefined is true
if you identify something as null does the value set to 0
it's not
!undefined = true is correct.
so is !null
No
null
Should log null
it says this
When you evaluate a null variable, the null value behaves as 0 in numeric contexts and as false in boolean contexts. For example:
because null is null xd
because console.log converts everything inside it to string
Depends on context but yeah.
I think so
Aight, im trying to follow this page: https://discord.js.org/#/docs/main/stable/class/Guild
so far i have:
const guild = new Discord.Guild('wefit');
client.on('ready', () => {
const { members } = guild;
console.log('Guild', { guild });
console.log('Guild Members', { members });
});
But im getting members undefined
Where did i screw up?
var x = 5
if (true) {
var x = 5
}
console.log(x)```
it would like 5 because it's true
right
why setting x again?
It would log 5 no matter what
But yeah, If works like if (statement is true) do else
imo var should not really be used due to broken scoping
speaking of if else, ternary operators are very useful in this context
var x = 5
if (true) {
var x = 4
console.log(x)
}
would that not log
because x does not equal 4
@naive mantle try this javascript.info
how do i make it so its not reassigning
seems you are lacking basic understanding of javascript itself
the tutorial might help
helped me atleast
👍
im reading it
== or === is for comparison.
if (x == 4)
as im doing this
so
basicallyt
var x = 5
if (x == 4) {
console.log(x)
}``` will not run because x doesn't equal 4
let val = 10;
if (val >= 5) val = 15;
console.log(val); // val = 15;
Yes, Won't run due to x being 5 and not 4.
== is kinda broken with type coercion in JS
him with his coercion
so use === isntead
I'd say so
it's best to use === in most cases
Just for the habit
Just make sure the datatypes are the same if you're trying to get your if statement to pass.
It's nicer when the lang helps with that ^
i think weak comparison is only useful for falsy values with != null
!== can still be done.
!= will trigger for undefined, null and falsy
which is generally what you'll want
!== will not
Yes.
Anyone has any idea about my guild member problems?
you can't create discord entities yourself
http://xyproblem.info ; what do you really want to do
Asking about your attempted solution rather than your actual problem
Did bots get their perms revoked for creating servers?
rip tls
Did bots get their perms revoked for creating servers?
@warm marsh no
Thanks
bots cannot create guilds if their guild count is above 10
but if your bot is in 5 servers (iirc) then you cant create a new server
^ actually 10
Alright.
@hidden spindle Discord.Guild takes, client and an object of guild data.
So the reason you're not getting anything is either because you're trying to get the guild before bot is ready and/or it doesn't exist.
Yea, i figured a way to do it
I had to destruct guild from client and find the guild i want through the cache
same as the channel
something like this
const wefit = guilds.cache.find(guild => guild.id === 'xx');
Yeah.
hot
Objects work slightly different. Just means you can't re-assign the datatype. You're stuck with it being an object.
if you say
const obj = {};
obj.x = 0 + Math.floor(Math.random() * 10);
// wont:
obj = true;
const MY_OBJECT = {'key': 'value'};
MY_OBJECT.key = {'yes': 'no'};
MY_OBJECT.key.yes = ("happy")```
you are assigning
a value
to the value
to the value
righrt
right
try it and see
ok
There isn't a need for parenthesis on the "happy".
i did
MY_OBJECT.key = {'yes': 'no'};
MY_OBJECT.key.yes = ("happy")
console.log(MY_OBJECT.key.yes)```
and it logged happy
so
you can
wait CAN YOU MAKE AN INFINITE LOOP OF ASSIGNING VALUES
No need to specify properties as string pie
you can do key: 'value'
const obj = {};
for (const i of new Array(100000)) {
obj[i] = i;
}
since the contents of an array are not protected
you can add
contents
with
arrayname.push ("thing")
right
yikes
what is Discord Bot List Acces Token
wot
its a token to access the top.gg API
ie: to make your bot show how many servers its in, in the website
you get it in your bot's edit page
aha k
Not the place but yes
srry lol
Hey anyone know how to make a say command via typing in console? In python. Ping me witj answer
aioinput
?
he just told u
the name of a lib
now if someone says tha name of a lib
guess what u gotta do
fucking google ot
docs
Hello guys do you now a command for a bot (v11) to delete a "-" in channel name ?
Hello
No
Is there a discordjs thing I can use to detect when a role is added? I was going to use bot.on('roleAdd') but I couldn't find that, or any articles on it. It's only how to add permissions to a user.
if you're on v12, you can find the full list here https://discord.js.org/#/docs/main/stable/class/Client
or if you're on v11 then https://discord.js.org/#/docs/main/11.6.2/class/Client
if you're talking about a role being added to a member, then you can only get it through fetching audit logs i believe
Noo
Ok
How would I do that with audit logs?
All I am seeing are events for message deletion, kicks, and bans, but no roles.
Listen to the guildMemberUpdate event
^
you'll have to compare the user roles from before and after the event, which the event provides as arguments
i don't know i don't use mongo
ah oki
I have never changed my code. But when my bot has been opening for the past few days, it gives this error. It just doesn't connect. Or it gets connected after many attempts. Sometimes he gives this error when he gives a command. (discord.js ) server heroku But it does not connect when opening in the command window.
2020-03-16T08:32:54.414016+00:00 app[web.1]: Error: Something took too long to do.
2020-03-16T08:32:54.414051+00:00 app[web.1]: at /app/node_modules/discord.js/src/client/ClientManager.js:40:57
2020-03-16T08:32:54.414052+00:00 app[web.1]: at Timeout._onTimeout (/app/node_modules/discord.js/src/client/Client.js:436:7)
2020-03-16T08:32:54.414053+00:00 app[web.1]: at listOnTimeout (internal/timers.js:549:17)
2020-03-16T08:32:54.414054+00:00 app[web.1]: at processTimers (internal/timers.js:492:7)
@quartz hill https://github.com/discordjs/discord.js/issues/3956
but havent shard bot
heroku use no glitch
i believe the issue is the same though.
discord is flagging ips from glitch and heroku
or, well, has been for the past few days
its a guild packet that does not arrive, and discord.js refuses to mark itself as ready until all guilds are received
But the same happens on my computer.
hm yeah then it's the issue tim stated
"This seems to have to do with shards with unavalible guilds, which would explain leaving an undefined guild. These may have increased due to an increase in Discord users due to Covid-19"
this?
if you do js client.on("raw", r => { if(r.t === "GUILD_CREATE") { console.log(r.d.name) } })
you will see all guilds being loaded when your bot connects
at some point it gets stuck on some guild
Wee woo, its raw
Does this mean that bots with this issue are not able to boot until it's solved? 
Or when the guild becomes available again^^
something like that
if you keep restarting it, it eventually manages to receive it
its kinda random
Good thing I moved away from Djs's sharding manager ages ago 
Good thing I'm on discord.py lmao
11.6.2
Where exactly should I use this code.
you said you are not using shards
i think it works yes
thank you very much again.
hi
hi
ih
does anyone know why when i do text-decoration: none i still get a link underlined. css
hi
check your selectors, might be wrong or being overwritten
i done that but it made no difference
and ok
the other things like actually work, but not the text decoration
so
ok
button {
text-decoration: none !important;
padding: 10px;
background-color: #fffffffa;
border-radius: 5px;
}```
ik its basic
😳
yeah
oh
Is anyone else having shard's failing with "Shard X's Client took too long to become ready"?
a lot of people apparently
haven't seen any VPS dud having trouble
usually links are put in anchor tags
so your selector would be ```cs
a {
//...
}
I'm hosting it myself and I'm having 2 shards refusing to work 😦
if you want to apply it globally to ALL <a> elements, do what cry said
with !important
Not only related to glitch/heroku @copper cradle
Discord.js issue
not sure if discord.js issue or discord api issue
@flint dawn just keep retrying, should work at some point
a:button {
text-decoration: none !important;
padding: 10px;
background-color: #fffffffa;
border-radius: 5px;
}```
```css
button {
text-decoration: none !important;
padding: 10px;
background-color: #fffffffa;
border-radius: 5px;
}``` the first one shows:
the second one shows:
Aight I'll give it another couple of hours
just a
@quartz kindle I'm using a different sharding manager and I don't have the issue
the issue doesnt happen to everyone
only a few random people
oh
Yeah everything was working fine but today it just doesn't want too
It happened to me when I tried my second bot (Switched it back to the normal sharding manager)
how would i select the button link then
what's your html
me?
yes
ok
well
lemme get it
button a {}
i hope they're not doing what i'm thinking they're doing
button a
it happened to me on my old bot, but not happening on the new bot, but the guy who posted the issue on github said he tested on all d.js versions and all have the issue lmao
dms
w-
Could it be over a certain amount of shards that it starts to happen or does it not matter?
i'll send toe pics after i get it normal
How many shards do you have
from what i've seen, the issue is that a single guild doesnt not arrive, and discord.js keeps waiting for it forever
8
and refuses to enter ready state
if your html has an a tag inside of a button, then your selector is supposed to be button a
seems like djs sharding manager issue
ok
you can however force it to mark itself as ready
how would i remove the
How would I go about trying that?
not sure if that will break anything tho, especially concerning said guild
weird things joining it and on the end
whats your djs version?
https://discordapp.com/channels/264445053596991498/272764566411149314/689957686539976731
(yes, its a link to a link, deal with it lmao)
are you using a WYSIWYG editor lol
<!DOCTYPE html>
<title>Lost</title>
<h1>Lost - A perfect Discord Bot</h1>
<noscript>You must enable JavaScript to access Lost's site.</noscript>
<ol>
<head>
<link rel="shortcut icon" type="image/x-icon" href="https://cdn.discordapp.com/avatars/650136984211292180/3dbcf8a2f49c193cd460eb441c7856a0.png?size=512" />
<div>
<button><a href=" ">Apply</a></button>
<button><a href=" ">Invite Me!</a></button>
<button><a href=" ">Support</a></button>
<button><a href=" ">Contact</a></button>
</div>
</head>
</ol>
<link href="styles.css" rel="stylesheet" type="text/css">
<body>
<div class="footer">Lost 2020 ©️</div>
</body>
thats my html file
Couldn't you just copy the link bruh
@quartz kindle cheers I'll try it now
lmao
in HTML, should I create a separate paragraph element per each newline
It said it took too long but I think it booted anyway
in HTML, should I create a separate paragraph element per each newline
no, it's named paragraph for a reason; use the br tag

r/cursedimages
What is shard
cry, do u kno
What is shard
@ionic anchor a smaller part of a bot; sharding is used to split a big bot into a bunch of smaller connections through the gateway to reduce traffic and stress
know what?
you don't need noscript since you aren't loading any javascript
you're applying the same css to both <a> and <button> and your css has padding, so both are being padded inside each other creating those distances
in any case using buttons inside <a>s and <a>s inside buttons is not recommended
either use a button with an action, or an <a> styled as a button
former is suggested more as it gets picked up by accessibility readers
ok
and it's able to tell the end user it's a button
button inside a is not valid according to html5 spec tho
idk about a inside button
app.post("/login", (req, res) => {
console.log(res.body);
let jsoncontent = JSON.parse(res.body);
if (jsoncontent.username && jsoncontent.password) {
res.send(`{\n"status": "success"\n"username": "${jsoncontent.username}",\n"password": "${jsoncontent.password}"\n}`);
} else {
res.send(`{\n"status": "error"\n}`);
}
});
I'm trying to just get the data..
{
"username": "hi",
"password": "hi"
}
for some reason res.body is undefined
Imagine not checking if the request actually contains a body and your web servers fails 😔
iirc you don't have to parse the response body
is you're using express, you need the body parser middleware
otherwise body will be undefined
ah yeah
ah true lol
wow another error
{ username: 'hi', password: 'hi' }
SyntaxError: Unexpected token o in JSON at position 1
at JSON.parse (<anonymous>)
epic
did res.body become [object Object] 🤔
add that .toString(), becomes [object Object]
ovi
F THIS
i mean i fixed it
JSON.stringify
if res.body is already json, then just use it as is lol
wat
let jsoncontent = JSON.parse(JSON.stringify(req.body));
why though
i messed up the status , too..
well it works now finally.
that makes no sense
you cant stringify a string, it will just become a string with escaped quotes lol
it would actually be like
JSON.stringify({a:10,b:20})
then its not a string
Ok so, I'm having trouble with sqlite3 (the python module) I'm running this query
SELECT * FROM {ctx.guild.id} ORDER BY itemName LIMIT 10 OFFSET {10 * page}
But it's returning an empty list
This is literally a random error that started to occur literally from nowhere
unless I'm blind
and shivaco is offline
holy cow
who could help me
btw, it isn't erroring
and it shouldn return an empty list, bc there are more than 30 items in that table
alright
that doesnt really solve his problem tho
I am aware
I'm not too good with sql queries but I thought I'd give this tip if they aren't already using it
how many items are there actually in that table
lemme check
any idea why this wont work? js serverQueue.connection.play(`http://${this.node.host}:${this.node.port}/${track.videoId}.mp3`)
whats the error
(node:17256) UnhandledPromiseRejectionWarning: TypeError: serverQueue.connection.play is not a function```
serverQueue.connection = await voiceChannel.join()```
looks like your connection is failing
there are exactly 30 items
can you run the same query without a limit/offset
SELECT * FROM {ctx.guild.id} ORDER BY itemName
ok
@scarlet bane do you think its v12 only?
Yeah it already joined
hmph
Ill update to v12
could honestly be a bunch of things, discord isnt very clean with failing calls
ill see if that works
bruh
idk why
wdym
is the query I posted working? or the one you posted
the one I posted
ikr
maybe you were passing a string or some stupid thing like that
I don't think so
ending up with 10*"2" = "22....2"
glad to help
RangeNotSatisfiableError: Range Not Satisfiable
at SendStream.error (C:\Users\jnsho\node_modules\send\index.js:270:31)
at SendStream.send (C:\Users\jnsho\node_modules\send\index.js:670:19)
at onstat (C:\Users\jnsho\node_modules\send\index.js:729:10)
at FSReqCallback.oncomplete (fs.js:172:5)```
send code
It says range not satisfiable
it means the server cannot serve the requested ranges
So i have a command that shows the avatar of a person who uses it(it also shows the mentioned user's avatar) but how can i make the avatar look big?
It shows it like this:
I'm using the code(inside the Embed):
.setImage(url=`${message.author.avatarURL()) And for the mentioned users: .setImage(url=`${message.mentions.users.first().avatarURL())
(discord.js btw)
avatarURL({size: 2048})
Oh ok... Thx
ok this is just plain stupid, it broke again 😩
ok so i tried installing discord.js using npm (npm install discord.js), and it did install (+ discord.js@12.0.2), but i think it is an older version. my bot keeps erroring out with TypeError: Discord.RichEmbed is not a constructor
its MessageEmbed in v12
o
Every time I hear v12 I want to just punch something for how stupid most things changed
is voting down?
wdym
so its possible its broken
i mean searching not voting
I see
ah i think voting has same issue then
http://data.roki.ovh/roki/rxAMIrUttWfXsc3.png it sends 403 so i guess we have to wait
yeah i can't vote either
guys i am trying to make a bot its says dbl.webhook.on('vote', vote => {
user = client.users.cache.get(vote.user)
client.channels.cache.get('685971547315240969').send(new Discord.MessageEmbed().setColor('RANDOM').setThumbnail(user.avatarURL({ format: 'png', dynamic: true, size: 2048 })).setDescription(Thanks you for voting <@${user.id}> (**${user.id}**)! As a reward, you get... Eternal respect from my dev))
});
not working can you help me
?
you can't just say "not working"
lol its not working
then fucking send the error
@wide ridge https://i.imgur.com/JbCP2mj.png
Can anyone help me how to make a website dashboard fot bot?
learn front end and back end web dev
Guys can you help my bot
Join it if you can help me to slove the problem
Thanks you
do not do that
delete the message
DMs are find but not here because people can do malicious things
@shut kindle
I keep getting this error and cannot vote on my bot.
2020-03-19T06:38:27.551317+00:00 app[web.1]: at IncomingMessage.<anonymous> (/app/node_modules/dblapi.js/src/index.js:118:25) ```
There is no change in the code. Bot was working yesterday.
ooh thx
with js, I have a string longer than X characters. how can I "split" it to obtain [X charachers text, the rest] ?
make array and then make a loop like this (not best way but i dont know better): var x = "hellohellohelloheloohelllohello"; x.split(""); var x1 = ""; for (var i = 0; i < 10 /* max charters per split */; i++) { x1 += x[i]; }
and then x1 should become "hellohello" @tight plinth
Yea failed to load
Figured. Sent a mail to support. Awaiting response!
yes..
WTF
Its back up
can i use multiple heroku account to run a program
ask heroku
ok
@shut kindle finally (you made a new one or u use my bot's core?)
no way he made a new one
can anyone tell me how to set the bots game with Eris?
docs
class Util {
static async getChannel (id) {
let channel = client.channels.cache.get(id);
// if (!channel) return "Channel not found!";
return channel;
}
}
error
Where is this class located?
In util.js
Okay
client isn't in that file unless you made it a non static class and passed into the constructor.
You're exporting the client object not the live one.
yeah
Make the util class a non static one or at least that method.
Well I just removed static and going to try it
Export the util class and then init it and pass client to constructor.
same error
// util.js
module.exports = class {
constructor(client) {
this.client = client;
}
getChannel(id) {
let channel = this.client....
}
}```
Then in your main file do
const util = require('path/to/util');
client.util = new util(client);```
Or how ever you want to store util to access later.
if you want to ping people, its always best to use <@userID>
so i have a bit of an issue
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:668:15)
at Function.Module._load (internal/modules/cjs/loader.js:591:27)
at Module.require (internal/modules/cjs/loader.js:723:19)
at require (internal/modules/cjs/helpers.js:14:16)
at Object.<anonymous> (/rbd/pnpm-volume/488dad32-76a9-43f2-81ea-402b856ecc4b/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/util/Util.js:1:19)
at Module._compile (internal/modules/cjs/loader.js:816:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
at Module.load (internal/modules/cjs/loader.js:685:32)
at Function.Module._load (internal/modules/cjs/loader.js:620:12)
at Module.require (internal/modules/cjs/loader.js:723:19)```
but its not on my end
this module is not in or used in my bot period
nvm it went away 🤔 updates?
mongoose.connect("mongodb+srv://[username]:[password]@xxxx-xxx.mongodb.net/test?retryWrites=true&w=majority", { useNewUrlParser: true });
A dependency wasnt installed then. Idk what would depend on snekfetch tho
is this the correct way to connect to a mongoose server?
A dependency wasnt installed then. Idk what would depend on snekfetch tho
@amber fractal according to the error itsnode_modules/discord.js/src/util/Util.js:1:19
...
That's not from my code.. i mean unless i own d.js and didn't know it 🤔 but seems to be fixed for now
appreciate it regardless but the error shows that its the d.js module itself that was erroring
@hoary elm then installing Discord.js v11.5.1 (not npm install discord.js, that'll add v12) again and see if that fixes it.
hmm 

can i use multiple heroku account to run a program
to bypass limitations? @cerulean pebble
i mean why not, i know tons of people who just make a new Heroku account when the Free Dyno runs out!
you can also just get a random credit card from google images and add it
even if it doesn't exists
heck even stock photos of credit cards are valid for heroku
^^
@lyric mountain i try but it fail
/*
The following code goes into it's own file, and you run this file
instead of your main bot file.
*/
const Discord = require('discord.js');
const Manager = new Discord.ShardingManager('./YOUR_BOT_FILE_NAME.js');
Manager.spawn(2); // This example will spawn 2 shards (5,000 guilds);``` does this still work?
ehm, sharding a bot?
your bot is big ?
nah, not that much, but i just wanna test it for later.
it means that your bot isn't big enough to be sharded
lmao
so it can't be sharded
xD
I just translated what he meant
ah yes, broadcasting the crap
:3
anyway, were you supposed to pass a file to sharding manager?
Hye ! I have this error when i send n!help
at Function.normalizeFields (/home/container/node_modules/discord.js/src/structures/MessageEmbed.js:433:8)
at MessageEmbed.addFields (/home/container/node_modules/discord.js/src/structures/MessageEmbed.js:249:42)
at MessageEmbed.addField (/home/container/node_modules/discord.js/src/structures/MessageEmbed.js:240:17)
at Object.run (/home/container/commands/help.js:15:14)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:25) 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:25) [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.```
fields.flat is not a function
on /home/container/commands/help.js, line 15, 14th word
it's written there
And how to solve this probleme ?
It's my cod ```const {
MessageEmbed
} = require('discord.js');
module.exports = {
name: 'help',
category: 'bot',
async run(client, message) {
var commands = client.commands;
var commandList = new MessageEmbed()
.setAuthor(message.author.username, await message.author.displayAvatarURL(), client.opt.url)
.setDescription(Voici la liste de mes commandes | prefix: ${client.opt.prefix})
.setThumbnail(await client.user.displayAvatarURL())
.setColor(client.opt.color)
.addField('Bot', '' + commands.filter(e => e.category === 'bot').map(c => c.name).join(', ', true) + '')
.addField('Music', '' + commands.filter(e => e.category === 'music').map(c => c.name).join(', ', true) + '')
message.channel.send({
embed: commandList
}).catch(console.error);
}
}```
@lyric mountain isnt that error coming from d.js lol
yep
Just i reinstall discord.js ?
are you using v12?
yes
then just reinstall it normally
Just reinstall ? discord.js and it's good ?
that's not the method signature
look at the docs
you may only add one reaction in one method
Anyone know that one translator community that allowed developers to add their project for translations? They can upload files, such as JSON or Java Properties. It started with a "Z", pretty sure. The Astolfo bot devs used it back when it was still a thing for it's translations
i just love this with js users - making up their own properties, methods and other shit that doesn't exist, and then thinking it's magically going to work just because js isn't typed
crowdin @slow elk ?
lmao
No, it started with a "Z"-
no idea, crowdin is the most commonly used platform for localisation management
crowdin is free to projects that are opensource
In Discord.js version 11.4.2 What the event to detect role added to & roles removed from a use.
Like for example member leave event is guildMemberRemove
guildMemberUpdate
For bot the cases?
what
both*
yes
OOh oks thanks
you'll have to compare the member's roles before and after the event, which the event provides as the arguments
oks thanks
var dispatcher = await node.play(track.videoId, message.guild, "over_internet")
console.log(dispatcher)
dispatcher.on('finish', () => {
console.log("ended")
})```
it says ```
(node:19016) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'on' of undefined```
The function is:
res = resolve
serverCache.player = await serverCache.connection.play(http://${this.node.host}:${this.node.port}/${videoId}.mp4)
console.log(serverCache.connection.dispatcher)
res(serverCache.player.dispatcher)```
sorry for the block of code
lmao
well... is node.play returning anything?
lemme check it should
if the method doesn't return anything then you don't have anything to assign to a variable
i don't know - i have no clue what you're using nor how you structured your code
What's a good reaction limit for a starboard (number of reactions before the bot will post the message)
whatever you feel like
for best results make it customisable
so people can adapt it to their guild
That's a good idea actually I have it using a database so should be pretty easy
//Edit Role Adds & Role Removes
client.on("guildMemberUpdate", async(member) => {
let guild = await member.client.guilds.get(`611881570202025986`).fetchMember();
let MuteID = '624675605312569354';
let StaffID = '611882066912477185';
var staff = client.channels.get("689931831344365575");
var mute = client.channels.get("689931759848259699");
staff.setName(`Role Count: ${guild.roles.get(StaffID).members.size}`);
mute.setName(`Role Count: ${guild.roles.get(MuteID).members.size}`);
});
ERROR:
(node:12) UnhandledPromiseRejectionWarning: Error: Invalid id provided.
at Guild.fetchMember```
context please
In Discord.js version 11.4.2 What the event to detect role added to & roles removed from a use.
Like for example member leave event is guildMemberRemove
Also, The error tells you the issue.
Should I not do it?
just change member.client to client
fetchMember has an invalid id. Thus uses fetchMember(id) not fetchMember();
(node:12) UnhandledPromiseRejectionWarning: Error: Invalid id provided.
I provided the correct ids
are you sure?
doesn't fetchMember() have a signature?
https://discord.js.org/#/docs/main/v12/class/StreamDispatcher?scrollTo=player
does anyone know where the end event is? so I can check when the connection stream is over?
Yes recheck and reloaded the bot but the same error
I am trying to get the number of members in the 2 roles on guildMemberUpdate - Discord.js Version 11.4.2
//Edit Role Adds & Role Removes
client.on("guildMemberUpdate", async(member) => {
let guild = await client.guilds.get(`611881570202025986`).fetchMember();
let MuteID = '624675605312569354';
let StaffID = '611882066912477185';
var staff = client.channels.get("689931831344365575");
var mute = client.channels.get("689931759848259699");
staff.setName(`Staff Count: ${guild.roles.get(StaffID).members.size}`);
mute.setName(`Mute Count: ${guild.roles.get(MuteID).members.size}`);
});
ERROR:
(node:12) UnhandledPromiseRejectionWarning: Error: Invalid id provided.
@heavy marsh
let guild = await client.guilds.get(`611881570202025986`).fetchMember();
// Should be
let guild = client.guilds.get(id);
let guild 2 times?
No only the second one
replace the first.
doesn't fetchMember() have a signature?
@heavy marsh ^
What do you mean?
someFunction(args)
^ signature
ahhh
Those are called parameters ?
But I looked it up and it was used like that
No fetchMembers() is used like that. fetchMember(id) takes a parameter.
Those are called parameters ?
@warm marsh signature are the collection of parameters, parameter is a single argument passed to a function
Thanks alot it works
is there any easier way of doing this? js serverCache.connection.dispatcher.streams.ffmpeg.on('end' ......)
No fetchMembers() is used like that. fetchMember(id) takes a parameter.
@heavy marsh seems like you're missing a "s"
dispatcher.on?
that doesn't have an end event ;-;
//Edit Role Adds & Role Removes
client.on("guildMemberUpdate", async(member) => {
let guild = client.guilds.get(`611881570202025986`);
let MuteID = '624675605312569354';
let StaffID = '611882066912477185';
var staff = client.channels.get("689931831344365575");
var mute = client.channels.get("689931759848259699");
staff.setName(`Staff Count: ${guild.roles.get(StaffID).members.size}`);
mute.setName(`Mute Count: ${guild.roles.get(MuteID).members.size}`);
});
This works now 🎉
how do I change the markdown color in my bots page? I know to change the whole body u need css, but idk about the markdown color, thanks in advance
css
no
don't just apply css to body
body is the whole page
.content h1, .content h2, .content h3, .content h4, .content code, .content strong
( headers ) ( code blocks) (bold characters)
What is the even to get ban added & Deleted?
Thanks
wait, what?
A list of all events are under client -> events.
@heavy marsh it's guildBanRemove
For deleted
KuuHaKu?
client.on("guildBanAdd", async(ban) => {
let BanCount = await ban.guild.fetchBans()
var bans = client.channels.get("689973370238009392");
bans.setName(`Ban Count: ${BanCount.size}`);
});
Is this correct?
I am not sure about the setName but yes
no its a function you are all good
I would add a reason to it so when you go to audit logs
bans.setName(`Ban Count: ${BanCount.size}`, 'There was another ban')```
yes
Ahh ok
so in the audit logs it would say why the name was changed
yep thanks 🙂
why does request.body
return
<Buffer 68 74 74 70 3a 2f 2f 6c 6f 63 61 6c 68 6f 73 74 3a 36 39 2f 2d 4f 62 64 76 4d 6b 43 4b 77 73 2e 6d 70 34>
when its an object?
I mean string
whoops
lmao
if(req.headers.type == "over_internet") return res.send(`http://${req.headers.httppath}/${id}.mp4`)```
see
set content type to utf8
oh Tim, I was looking into your discord.js-light and it seems so smart the way it does things
application/json im guessing?
Is spawning one shard the same as not using shards?
pretty much yeah
alright
res.set('Context-Type', 'text/plain')
if(req.headers.type == "over_internet") return res.send(`http://${req.headers.httppath}/${id}.mp4`)
if(req.headers.type == "server_only") return res.send(`${__dirname}/songs/${id}.mp4`)```
i mean, a shard is a connection
still returns a buffer
you always have at least one connection
I assumed it would be just about the same
im so dumb
fumb
Content-Type
are you loading it in the browser, or where?
var result = await request.post(`http://${this.node.host}:${this.node.port}/download`)
.set('Authorization', this.node.password)
.set('id', videoId)
.set('type', type)
.set('httppath', `${this.node.host}:${this.node.port}`)```
using the request library?
using node-superfetch
--oof, sent early
@mystic violet from what i understood, node-superfetch uses the same syntax as superagent, since it doesnt have any documentation
superagent documentation states that it doesnt process plain text responses automatically, you need to add it yourself
i've never used superagent or superfetch so idk either
but if all else fails, you can always convert the buffer yourself
yeah
So last night I did some calculations and realized how valuable disk space is when I only have 100GB
The rewrite of my bot is using a mixture of JSON and filenames. This uses a lot of disk space.
I also realized that, even though usimg multiple files greatly reduces the impact of corruption, it comes with a large disk space cost.
After doing some calculations, I realized that I can store the basic user data for each user who sends a message whatsoever in as little as 22 bytes. This assumes that the user does not run any bot commands, I already know where each user's data is being stored, and I cache the names of keys elsewhere.
I am going to see if there is a way to write data directly to the disk, without buffering it in memory, in which case I can go back to single file. If so, I can store my data per user in a 32? byte block, where 28 bytes are dedicated to the data and 4 bytes are used to indicate a block, if applicable, where overflow data can be stored.
I'm also going to need a few blocks to indicate which blocks are available (I can indicate the availability of 28*8 other blocks within a block), as well as a few blocks with data usable to look up other data.
Additionally, I will want to be sure to write in a system to address another file of data if my current file gets too large.
I'm still working out some of the exact details
how much information to you save to a JSON?
In sharding, how would you get information from all of the shards such as guild counts?
I'd have to check the storage again, but it's definitely inefficient
Guild counts are calculated at runtime via events.
Anyways
with JSON, single-file leads to corruption, while the size of multi-file is at the will of the hosting filesystem
why dont you use a DB?
I dunno, I was thinking about looking into one, but, except for firebase, I think they would be alot stricter
If filesystems allowed me to put arbituary, unescaped filenames, and blocks were only 32 bytes, I would totally continue to use multi-file and wouldn't need this large, complex plan
For now, I'll work on the bot's features, and take care of storage later. Luckily, I segmented off my storage code into it's own package, so I don't have to deal with anything intertwined.
Actually, MongoDB might work
Lemme look at something
Some kid named @|| ☭ USSR ☭ ||#9380 just pretended to have my bot’s token and then tried to use eval to get the token, then asked right after for eval perms, then played dumb, if he joins your server beware lmao
hello
nohello
why do people do weird stuff
lol I'd like to see him try with me
How do you get the total ram usage over multiple shards?
you hosting on multiple servers or somthing lmao
no, is it just process.memoryUsage().heapUsed / 1024 / 1024?
megabytes, hence the /1024/1024
okay, then it should except make it Math.floor(process.memoryUsage().heapUsed / 1024 / 1024)
and it shoukd work
https://hasteb.in/ehuvoyut.coffeescript
How can I solve the problem?
an error appears when adding a bot to the server
I take the server ID and check it in the ban or not, and if it is in the bath house then the bot leaves the server
Sorry for my English)
ok thank you
lmaoooo
Need help in translation here?
yes
Lmao im so dumb, I had it defining the ram, and I just forgot to add the ram value, I had it set to 11
Так в чём тут проблема? @open flicker
ошибка в том что когда бота добавляют бота сервер то ошибка (я проверяю ID сервера на бан в базе данных) @slender thistle
Похоже, что guilds.get(data.ID) возвращает undefined
хм
@lyric mountain What's the other thing for guilds.get(id)
is he on 12 or 11 because its guilds.cache.get
У тебя какая версия discord.js?
DiscordJS 11.6.2
ok thats good
can you show more of your code?
you can paste it inside code blocks here
```js
<code here>
```
@crimson vapor https://hasteb.in/ehuvoyut.coffeescript
is that it?
yes
is banServer defined?
??
you could also change
catch {
null;
}``` to
```js
catch (err) {
console.log(err)
}```
that would show more of the error I think
ok
what DB do you use?
mongodb
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'leave' of undefined
at F:\Luni\guild\guildCreate.js:7:37
at F:\Luni\node_modules\mongoose\lib\model.js:4830:16
at F:\Luni\node_modules\mongoose\lib\query.js:4391:12
at F:\Luni\node_modules\mongoose\lib\query.js:2869:28
at processTicksAndRejections (internal/process/task_queues.js:76:11)
Emitted 'error' event on Function instance at:
at F:\Luni\node_modules\mongoose\lib\model.js:4832:13
at F:\Luni\node_modules\mongoose\lib\query.js:4391:12
at F:\Luni\node_modules\mongoose\lib\query.js:2869:28
at processTicksAndRejections (internal/process/task_queues.js:76:11)````
ok yeah
you need to add more to the banServer.findOne()
I think
you need to match a guild ID I assume
Do you think it's Luni.guilds.get(data.ID).leave() erroring out
What you're doing doesn't make sense
I do not
he's basically making a server blacklist
