#development
1 messages · Page 720 of 1
^^^^^^^
is there any alternative?
not creating a image and just fetch the url's base64 data and then convert it into a image
what?
not making an image == faster
Google "base64 to image lang"
And how do I do that? I don't know much :C
ok
because those bots have a really strong server

image generation, especially when using imagemagick, uses a lot of CPU power
it won't be optimal if you're selfhosting, multi-tasking on the same machine, using a free host or have a weak machine
Ok, how would I make my bot send a message to a specific channel by ID
So only in that server, in that channel, will it send the message
@fallow quiver
client.channels.get(channelid).send(message);
what language tho
Javascript
ah
JS in this example
well then yh
You're welcome
@distant plank one way to make it faster is to rewrite that code to canvas, but good luck doing that
You can also try sharp
Supposedly its the fastest image manipulation library
Also, why is that code resizing an image 3 times?
Also check if the slowness is actually the image generation or if its the image downloading. If its the latter, get better internet
@quartz kindle How can I achieve the same effect with sharp?
Does this look okay the way I am doing this, guys? Because sometimes I get a "User aborted request" error, same with my rank card command
https://cdn.discordapp.com/attachments/632371899565080577/639567442598821888/unknown.png
https://cdn.discordapp.com/attachments/632371899565080577/639567543815897118/unknown.png
@distant plank you'd have to read the sharp docs
I dont know what kind of effect youre looking for, but sharp should support almost everythng that gm has
So i've a question that i'm probably not asking in the right area, however, our bot {HSF}LadyShadow#7111 was removed from this server.
However this servers #logs has no report of it, yet she's still on DBL's website.
Any idea what's goin' on?
ID > 347872963636494337
Mention > @sly creek
ahkie, so what's the kick reason mean exactly if i may?
DMs on "ok"
right, you can DM commands to shadow, but i don't understand why that's a reason to kick the bot?
It can be triggered without prefix
?? it does?? I'll look into that asap, thanks!!
I'm not getting any response..
Would the test have been done here in the server or on another?
So that i can see what was happening at the time of error
It was randomly reproduced in #commands I believe
To attempt to reproduce it yourself is up to you :p
@quartz kindle i didn't find anything :c.
alright ty, i'll look into it
owner prefix mixed with an alias, i'll throw in a check for it and make a re-submition to DBL
apologies for the weirdness.
How can I get a "magik" effect with sharp?
One message removed from a suspended account.
I need help with java.. I want to send a webhook. I created a StringEntity with the Json body.
The description should be a tweet. The problem is, it doesn't accept the line breaks.. Has anyone here found a solution to this problem?
@floral zinc use \n instead of a newline
I'm using that. When I type it in the Json string itself (I have to use \n) it works fine. But when I have the description as a variable and just replace the breaks with \n it results in sending a content like this:
Thisnisnantestn
Instead of:
This
Is
A
Test
Ummm I'm pretty sure it is \n\n 🤔 haven't used that in a while
I'll try tmr
@floral zinc try doing lemme try testing\\n if it's from a json
@distant plank Sharp?
You can imitate the magik affect using any image manipulator that allows for liquid rescaling
Rawr neko
@undone rose Sharp doesn't have it?
@sudden geyser that would be making the \n appear in the messagr
yeah I realized that. At some time, I remember needing to use two slashes for something else
I dont know, but thats how magik is done
Use a lib that interacts with image/graphicsmagick
That program can utilize liquid rescaling
@heavy void what are you hosting your bot on? Move here instead of #topgg-api
Whatever you're hosting on you can try restarting the running instance of your bot
Heroku isn't really ideal for discord bots, its more for websites
heroku isn't really ideal*
Heroku is good for what it's purpose was for
HE is best host
SparkedHost is what I use
all of these off brand vps moments
a lot of people go for vultr, galaxygate, digitalocean, ovh, etc
and you should move your bot off glitch asap
galaxygate is probably the best in that list for servers
Cheap, reliable, and good net speeds
yeah anything on that list, but not restricted there
imo the heiarchy is most vps servers > heroku > glitch
while you could ask someone to host your bot for you, that comes with the risk of providing your token n shit so dont do that
https://qoilo.com/hosting I've been using them for months and they offer some super cheap hosting too. I haven't had a single issue with them yet tbh. I had a VPS (one of their mid-tier ones) for a while but then I got a dedi from them for super cheap. abt $36 a month for 64GB of RAM and dual quad core xeons. This host was the one that got me moved over from Vultr, and so far it's been the only host that's been able to make me ditch Vultr
contabo is best
@sudden geyser yea I've tried that. And that does work if I put it in the Json directly. If I put it in a String and put that String in the Json it doesn't work. I dunno why
u need to make a code what knows in this whats \n means.
@valid frigate That's what I thought too
But I've had this dedi since March at this point and it's had zero issues
Hmmm...
Only issue was me forgetting to setup a static IP
Is sending a Custom Dm from any User to an Other User with a Bot against The ToS?
@fallow spire not as far as i know there is a few bots such as Nadeko that allow (usually admin or bot owner) to send messages to a specified user
Because someone in my Server with his Bot a that Feature open for everyone
@hoary elm
well if it abuses API im sure would depend on how fast the messages are sent, as far as allowing the command to be used by everyone im not sure if there is rules to that
Ok
Cuz if the Person you want a Dm to send to, has blocked you, can you use that as a "bypass"
it doesn't really care how much you spam (because you wont get api banned easily)
You should not let users send messages with your bot because you are liable for whatever your bot sends
Is a bit intrusive but not against the tos
But just like having an image search commands, while it in itself is not against tos, you should not do it, because it can break tos
mine are usually locked to owners/devs
lol
the bot devs wont care
popular bots are still doing fine
its been 3 years (or 4 kinda) since bots existed
We used to deny bots here for most image search commands lol
Very few were able to pass
i mean most popular bots have them
We didnt really care much for say
But mostly image search
But the same idea as image search could be applied to say cmds
An image search?
Commands that allow you to search for images
And?
Since they are hard to do right, most bots that had them got declined for listing
Oh ok
im guessing that would be due to NSFW returns? @undone rose
Yeah probs
Yeah you could do !imgsearch loli
😳
Obv in a more nsfw manner
yeah
yeah but that applies to alot of other bots here
But that was grounds for denial and Discord staff had confirmed that ur liable for what your bot says
So we just declined for it
What did your bot say?
Iirc you have to enable safesearch in non nsfw channels
:/
Just ask your question
How to make a dynamic timer (embed)?
How make an intervall between different status of ur bot ?
@lunar crystal library?
How can i make an Command in Discord.js that cleans up the quick.db database?
@fallow spire if you dont have it reading from/writing to/editing a JSON file, it should clean it up on restart... Example my bot has a economy system set up that runs off of quick.db and if i dont store the users balances in a json file it refreshes their balance every restart
...
@earnest phoenix timer for what? And what library
discord.js
For a command
Example:
test 5
(seconds)
And the 5 seconds pass in the embed
in edit
Oh so you want like a countdown?
Do you have the timeout defined already
No, I can't do it at all, so I ask.
var tps = args[0]
tps is the time for the countdown
setTimeout(callback, time)
what do you mean by dynamic
2
he wants it to edit the mebed displaying a different number
Etc...
Yes
thats quickly gonna get to the point of api abuse
Edit the message occasionally and update the remaining time
If your example of 5s is what it'll usually be
Just don't use it
a message every seconds seems like api abuse
Because I wouldn't update it faster than every 5s
Bruh...
even that would still be fast
3?
@earnest phoenix ``` let Timer = args[0];
if(!args[0]){
return message.channel.send(":x: " + "| Please Enter a time period followed by "s or m or h"");
}
if(args[0] <= 0){
return message.channel.send(":x: " + "| Please Enter a time period followed by "s or m or h"");
}
message.channel.send(":white_check_mark: " + "| Timer Started for: " + ${ms(ms(Timer), {long: true})})
setTimeout(function(){
message.channel.send(message.author.toString() + The Timer Has FINISHED!, it lasted: ${ms(ms(Timer), {long: true})})
}, ms(Timer));
}```
What are you using this for
you copuld use something liek this ^^
Is it that important that the user sees a very updated time
Okay ty
You should also be aware that unless you've added some restriction
people can just spam the command
and you'll have tons of these running
if (talkedRecently.has(message.author.id)) {
message.channel.send('Please wait 30 Seconds before using this command again');
} else {
let Timer = args[0];
if(!args[0]){
return message.channel.send(":x: " + "| Please Enter a time period followed by \"s or m or h\"");
}
if(args[0] <= 0){
return message.channel.send(":x: " + "| Please Enter a time period followed by \"s or m or h\"");
}
message.channel.send(":white_check_mark: " + "| Timer Started for: " + `${ms(ms(Timer), {long: true})}`)
setTimeout(function(){
message.channel.send(message.author.toString() + ` The Timer Has FINISHED!, it lasted: ${ms(ms(Timer), {long: true})}`)
}, ms(Timer));
}
talkedRecently.add(message.author.id);
setTimeout(() => {
// Removes the user from the set after a minute
talkedRecently.delete(message.author.id);
}, 30000);
}```
@earnest phoenix with cooldown ^^
Ty ^^
You can specify a language for code blocks by adding it on the top line next to the 3 `
Oh okay why not :)
is this code correct?
(node:6864) UnhandledPromiseRejectionWarning: Error: Shard 0's process exited before its Client became ready.
at Shard.<anonymous> (C:\Users\ZaidYt\Desktop\Discord Bot\node_modules\discord.js\src\sharding\Shard.js:88:39)
at Object.onceWrapper (events.js:291:20)
at Shard.emit (events.js:203:13)
at Shard._handleExit (C:\Users\ZaidYt\Desktop\Discord Bot\node_modules\discord.js\src\sharding\Shard.js:272:10)
at ChildProcess.emit (events.js:203:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
(node:6864) 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: 10)
there is another error above or below that causes this one
I need a bot setup link
Do you use JavaScript?
So I tried this.. I dont receive a webhook.. Probably because it doesnt accept the format or something.. I really dont know what else to try
what
what?
sometimes the ads load sometimes they don't
votes reset every month
But they appear when I refresh
caching bugs
np
go to the api docs and explore
im not getting it from this one, someone help
what do you not get about it
how to initialize a folder with NPM?
?
man
What did you @ me for?
which api you use ?
is it possible in java to show how many trees are grown
discordjs
i just add your bot
api?
it cool
lol yeah I've already done it with the team trees bot
cool
quite literally scrape the website
Yeah that's all we did
oh
numberOfTrees = format({})(parseInt(html("#totalTrees").attr("data-count")));```
using Cheerio
hmm
when I type npm init -y its saying 'npm' is not recognized as an internal or external command, opertable program or batch file any help?
npm is not installed
or that^
i mean all it is is litterally scraping the site
pretty simple to do manually
but that was first result on npm
ye, he even made a npm package to
@hazy sparrow after you install node.js you need to restart your computer
is NPM and node.js the same?
kk
ty
how do you install npm (asking cuz I cant fing in google. when i search they give how to download node.js)
npm comes with nodejs
oh
damn whatever i do im stuck in the hpm init -y thingy
First 500 people will get 2 months of Skillshare free: https://skl.sh/polymatter4 Patreon: https://patreon.com/polymatter Twitter: https://twitter.com/polyma...
@hazy sparrow make sure that option is enabled when installing
and of course, the "npm package manager" as well
ah, rip
ok now im stuck at Getting your bot running for a stupid reason :why is the background white while mine is black?
do i have to open a editor?
oh
got it
did you actually run the code
ye
did you put in a token to log in with your bot?
ye
is there anything showing in the console?
ohm k

@earnest phoenix how can i make widgets for my bot
it will be useful for a server stat and command list in the description
cause i know some about html
@earnest phoenix if you want to use widgets for your not page you must first of all take that simple example they give you in the edit page
Then you'll study how they connect bot components, then it'll be like decomposing an object
bot.avatar, bot.shardCount etc
i will come to that later after making a bot
hey ! just a quick java question, how to check if the first argument is equals to an element of an enum class ?
let numberOfTrees = teamTrees.getTrees();
message.channel.send(numberOfTrees)```
Not giving any err but not even sending anything
i code in JDA 😩
try putting a ";" at the end of the last line
i made an enum class to list all of my commands, their usage and their explanation
and i want to check if the first arg of the command is an element of this enum class
nothing happens with ";"
@jade thistle That don't solves the Problem...
semicolons do not matter
they're optional in js
also @leaden void what is the reason behind making your commands in an enum? it's better to put them in a List instance so you can iterate over them
i just did this BAN ("Ban", "ban [user] [time (optional)] [reason]", "Bans user from the server."),
ah that
and i assume you have a run() method override in your command classes?
I don't think there's a specific method to do that with enums but they do have a values() method that you can iterate to check for a match @leaden void
so the enum is just for description
ah ok
just for descripting
well in that case do what he suggested then tell us if that works
yup
@pallid zinc did you read the package docs? all methods are async and return promises
Thanks
there's no available iterate method
if(args[1].equalsIgnoreCase(HelpList.values().toString())) {
this don't really sounds like it will work
oof
to set up commands, you could make a base command class and extend other commands off of that class
although it's in kotlin it's not too different from java
yeah id advise only using 1 value per enum key
hmm
you can just use a for
looks bad to make a class for every value
for (EnumValue value : Enum.values()) {
}```
Well
that iterates over every value in the enum
You wanted to check if one of them matches a given argument?
Basically put the code you've put up above in there
and use the value instead of Helplist.values()
I don't think toString() will work btw
yup
Unless you've added a toString()
for (HelpList value : HelpList.values()) {
if(args[1].equalsIgnoreCase(value.getCmdName())) {
//My code
}
}

@leaden void instead of putting all my commands in an enum i just have them all in a package and on startup I loop over all the classes in there to see if they extend the main command class and just create a constructor and instance from that class
Class<?> superClass = CommandParent.class;
List<Class<?>> classes = ClassFinder.find(PACKAGE_NAME);
for (Class<?> c : classes) {
if (c.equals(superClass) || !superClass.isAssignableFrom(c)) {
continue;
}
try {
Constructor<?> ctor = c.getConstructor();
CommandParent o = (CommandParent) ctor.newInstance();
register(o, o.getCommandName());
} catch (Exception e) {
// handle the error
}
}
The ClassFinder is a class that I wrote, I won't help you with that 😛
you would still need to edit that array/enum every time you add a new command
im lazy
and i always forget to edit the enum/array that lists all the commands
don't get into class loading unless you know how to do it yet
good point
Tim thanks it work perfectly
also once you have the time, learn kotlin it's hot 😩
working like a charm
good
Thank you guys for helping me ^^
What "Extra Data" can go inside of a new MessageAttachment?
idk formate or sth
https://discordapp.com/developers/docs/resources/channel#attachment-object
This is an attachment object in the raw discord api
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
hmm yeah, i just noticed it has the url of the data
@earnest phoenix data is the data of the file (eg image/png, etc.)
hmm im having some difficulties with my rank card, it works, but im sure this will tell you my problem: https://media.discordapp.net/attachments/632404176155967498/639865266016223240/unknown.png
it takes years to load it (im using canvas btw)
data is the data of the file (eg image/png, etc.)
no it's not
i don't know why that's even implemented
might be a derp, it shouldn't be in the constructor
basically it just patches over the object's data
everything about the image/attachment is in the buffer
@earnest phoenix define "years to load"
https://cdn.discordapp.com/attachments/632404176155967498/639861402328236072/unknown.png it took longest to actually create the attachment too, could that be to do with the image size being 3000 x 1000?
Oh, ok
well above, it was 13 seconds in one of them
why are you making it 3000x1000 in the first place?
@earnest phoenix the maximum file size has to be less than or equal to 8mb
because the person who made the rank card design for me in Photoshop sent me it as 3000 x 1000
whats your "creating attachement" code?
const attachment = new MessageAttachment(canvas.toBuffer(), "rank.png");
You can resize it down
im sure you are aware resizing images is a thing, right?
to about 1000*350
i didnt think it would be an issue 
more or less
whats the background image format and size?
it takes a custom background, but the default is 3000 x 1000 also i believe, lemme double check
size in kb/mb
ohhh
its a PNG, and im loading it using the proxyURL on discord (I used to load from disk but thought maybe using a proxy URL would be more efficient for speeds)
669KB
so you uploaded it to discord and download from it every time?
no, i have the proxy URL of it saved in a database
You don't need to download it again
wait no i dont
just save the output image
thats downloading it again
if (!card) card = {
guild: message.guild.id,
user: member.id,
primary: "#44c0fc",
secondary: "#ffffff",
accent: "#44c0fc",
background: "https://cdn.discordapp.com/attachments/632404176155967498/639499306012901386/defaultBackground.png",
opacity: 0.75
} as RankCard;
you cant use an image with canvas without downloading it
oh so I was better off loading from the disk?
from a performance perspective, disk will always be faster than network
and memory will always be faster than disk
so you should load from disk, and cache in memory whatever can be reused
then, for a full background, jpg is better (if you dont need pixel perfect quality)
Thays why PIL is good
png is better for transparency
so use png for icons and objects with transparent parts, and jpg for full color backgrounds
then, use an image compressor
there are plenty of good algorithms out there that can compress images without any meaningful quality loss
for example pngquant (for pngs)
and of course, dont make images bigger than what you need them to be
keep their resolution realistic
alright so basically
- Resize the overall image
- Load images from the disk
- Cache the default background
- Use pngquant for compressing
basically yes
alright i'll give it a go, ty
doing those will probably give you a performance boost of over 50%
Looking for a bot that can reply with information that is typed in from a database, it need search function, any info on a bot DM me.
Thanks
How would i do an commandusage command?
what
srly?
your sentence makes no sense
@fallow spire You mean see how many times a command has been used or?
Yes exactly
what language
after your command's run function has finished, that's where you would update command usage
im shit at maths, can somebody give me the equation please lol:
so for my XP bar,
675 pixels = 100%
my old equation: (xp * 100 / (level * 35)) * 20.2
basically the 20.2 needs changing to something to make it correct
nvm i got it
1: node::Abort() [node]
2: 0x8ccf9c [node]
3: v8::Utils::ReportApiFailure(char const*, char const*) [node]
4: Require(v8::Local<v8::Object>, char const*) [/rbd/pnpm-volume/13671c08-f1fc-4577-8b52-c3bbb55876b8/node_modules/.registry.npmjs.org/better-sqlite3/5.4.2/node_modules/better-sqlite3/build/better_sqlite3.node]
5: Integer::Init(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Object>) [/rbd/pnpm-volume/13671c08-f1fc-4577-8b52-c3bbb55876b8/node_modules/.registry.npmjs.org/better-sqlite3/5.4.2/node_modules/better-sqlite3/build/better_sqlite3.node]
6: RegisterModule(v8::Local<v8::Object>, v8::Local<v8::Object>) [/rbd/pnpm-volume/13671c08-f1fc-4577-8b52-c3bbb55876b8/node_modules/.registry.npmjs.org/better-sqlite3/5.4.2/node_modules/better-sqlite3/build/better_sqlite3.node]
7: 0x8ce97d [node]
8: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [node]
9: 0xb0d72c [node]
10: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [node]
11: 0x2869c8d042fd
/opt/watcher/app-types/node/start.sh: line 51: 13050 Aborted (core dumped) node index.js```
What is this?
@quartz kindle what would you recommend for caching the images? sized it down now and its already loading alot faster
Can you help me with the error, please?
@earnest phoenix what node version do you have
https://github.com/JoshuaWise/better-sqlite3/issues/120 perhaps check this.
Is the node-fetch portion?
What?
anyone know a js lib that helps you fetch the full url, that url shorteners redirects you to ?
@earnest phoenix you can use anything, even an array/object/map
what would I store in a Map? just the file path?
@earnest phoenix
hmm
weird, it works on stuff like bitly, but not the specific service im working on
how many ways are there to shorten urls and redirect em
the problem is not the redirection, is when the redirection is "premium"
like when they make you do something to make the link continue, like watch an ad, or fill a survey
can i send the link, i'm trying to expand
?
im fairly certain what you're mentioning isn't a problem, it's a pretty basic service
(this specific url shortener site)
uu.expand('url here')
.then(url => {
if (url) console.log('Original url is: ${url}');
// no shortening service or an unknown one is used
else console.log('This url can\'t be expanded');
})
.catch(err => console.log(err));```
@earnest phoenix I used to use this ^^ in one of my old node.js bots
Not sure if it still works though
hmm, i used an online url analytics tool
something about the url telling the site is moved and then changing the location
Hmm
Check your URL redirect for accuracy. Our Redirect Checker will analyse all redirections. Try Now!
don't just wanna screenshot the http header incase it contain ip or something
grabber ?
no, it's just somewhat popular here in Denmark
Oh
and i couldn't get it to expand unlike other url shortener services
not sure if it uses a different approach or something
How can i get mt server's guild id?
@surreal sage in the bot or?
Lol
@earnest phoenix well the expander I used says it's just a Google link
Oh yeah your server has to be on https://top.gg/servers @surreal sage that's easy you just have to add their server list bot to your server
Then it will show as a server you can edit
ik
what expander are you using ?
because your example code is returning " this url can't be expanded" on my side
Hmm
@earnest phoenix https://urlex.org/
urlex.org is a URL Expander that unshortens any URL to a long URL masked by any URL-Shortener.
Hi
It's possible to detect when user join channel where the bot is and detect if channel content 1 user (Does not include the bot)
a voice channel?
Voice channel yeah
of course it is
in which library
discord.js
first check if the new member's voice channel property is defined
if it is, it means they joined in the channel
Umm
then you can grab the voice channel members property and filter out your bot
and simply count how many users there are
Mmmmh
let newUserChannel = newMember.voiceChannel
let oldUserChannel = oldMember.voiceChannel
if(oldUserChannel === undefined && newUserChannel !== undefined) {
// User Joins a voice channel
} else if(newUserChannel === undefined){
// User leaves a voice channel
}
})```
stop spoonfeeding
Mmmh
spoonfeeding does not directly mean to give fully working code
Oh
My bad then
It's like literally incomplete doesn't log or nothing so I figured it was alright
And with this how i can know how much user is in the channel ?
like cry said you would have to grab or fetch the voice channel members filter out your bot and count how many users there are
This may help 🤷🏻♂️
Ok but now mmmh, i can detect if the bot is in the channel that i join ?
has on members property
filter is for... well filtering
use has(id) for checking if x is in the collection
😁
good, you have google
?
voiceChannel#members is a collection
you can use Collection#has to find out if a certain member is in that collection
that's basically a summary of what he/she just said
let newUserChannel = newMember.voiceChannel
let oldUserChannel = oldMember.voiceChannel
if (oldUserChannel === undefined && newUserChannel !== undefined) {
const voiceChannels = newMember.guild.channels.filter(c => c.type === 'voice');
let count = 0;
for (const [id, voiceChannel] of voiceChannels) count += voiceChannel.members.size;
console.log(count);
if (count == "2") {
}
} else if (newUserChannel === undefined) {
console.log("Disconnected")
}
})```
Now i have this
ok?
With this i want detect if the bot is in channel
maybe learn a little more js then
Because english is a famous language
oh true, so you want to learn it?
and an easy way of learning some of the words is by coding?
Learn what ?
English
Trintous I want you to name a universally recognized coding language that isn't in English

😂
No worry
guild: [Guild],
user: [User],
joinedTimestamp: 1572135410299,
_roles: [Array],
serverDeaf: false,
serverMute: false,
selfMute: false,
selfDeaf: false,
voiceSessionID: 'a862195d8c3cbcb9645e5de7b5d316e2',
voiceChannelID: '630407881753362442',
speaking: false,
nickname: '▒ ▒▒▒ ▒',
lastMessageID: null,
lastMessage: null,
deleted: false
}```
My collection :d
@earnest phoenix now ? :d
I do test if channel of the bot is the channel of user ?
use
has(id)for checking if x is in the collection
you can use Collection#has to find out if a certain member is in that collection
your bot's ID as a string
if (newMember.has("601546541466910722")) { console.log.log("YEAH") }
TypeError: newMember.has is not a function
@earnest phoenix
newMember.roles.has
console.log.log() ?
Oh you want to see if the bot is in the same voice channel as a user?
O fail
newMember.voiceChannel.members.has
if (newUserChannel.has("601546541466910722")) { console.log("YEAH") }
client.on('voiceStateUpdate', (oldMember, newMember) => {
let newUserChannel = newMember.voiceChannel
let oldUserChannel = oldMember.voiceChannel
if (newUserChannel.has("601546541466910722")) {
console.log("YEAH")
}
if (oldUserChannel === undefined && newUserChannel !== undefined) {
const voiceChannels = newMember.guild.channels.filter(c => c.type === 'voice');
let count = 0;
for (const [id, voiceChannel] of voiceChannels) count += voiceChannel.members.size;
console.log(count);
if (count == "2") {
}
} else if (newUserChannel === undefined) {
console.log("Disconnected")
}
})```
@smoky spire no
What are you trying to do
Read message ...

I do test if channel of the bot is the channel of user ?
This is what you said earlier
So you say this and does not work
if (newUserChannel.has("601546541466910722")) { console.log("YEAH") }
newUserChannel.has
- do you even know what your doing
You say this ...
newUserChannel is my collection
no it's a voicechannel
I want if i join a channel when is my bot and the channel when is my bot content x users, i do x
And for this i have this
and i have a feeling that you don't know what a collection is
let newUserChannel = newMember.voiceChannel
let oldUserChannel = oldMember.voiceChannel
if (newUserChannel.include("601546541466910722")) {
console.log(newUserChannel)
}
if (oldUserChannel === undefined && newUserChannel !== undefined) {
const voiceChannels = newMember.guild.channels.filter(c => c.type === 'voice');
let count = 0;
for (const [id, voiceChannel] of voiceChannels) count += voiceChannel.members.size;
console.log(count);
if (count == "2") {
}
} else if (newUserChannel === undefined) {
console.log("Disconnected")
}
})```
or barely js at all
I say what i want ...
I want if i join a channel when is my bot and the channel when is my bot content x users, i do x
^
Hey who are here?
wdym
let overwrites = category.permOverwrites.map(permOver => {
return {
id: backupserv.references.roles.get(permOver.id).new.id,
allow: new Permissions(permOver.allow),
deny: new Permissions(permOver.deny),
};
});```
I'm trying to make a bot of backups(Xenon in js lol)
But I can't restore permissions on categories
```js
"categories":[{"idOld":"637697437871505426","name":"textuels1","position":0,"permOverwrites":[{"id":"637697434180517888"}]```
Error: RangeError: Invalid permission string or number.
I use discord.js@11.5.1
I submitted my bot recently to be approved, but didn't read the permissions = 0 part of the faq until afterwards. If a bot is relying on having permission to read text chat messages, could that cause it to fail to take arguments from a command?
if the bot alerts the command runner that it is missing permissions then we add the permissions @candid hill
Ah. I just learned about catch, so I probably missed some promises. Is your testing process automated?
Yeah, that would do it. Ah, so the crash likely wasn't from your testing then.
Who can help me?
anyone know how i would access something equivalent to this through node.js, maybe using the 'request' module?
pretty sure any http lib can do that
i wouldnt recommend request as its quite bloated
for now my main concern is how user friendly the lib is :p
but could you maybe guide me towards the right sources? or some search terms i could use?
so you just want to send an http request, and log all the response data?
well, currently i'm mostly interested in the location url
something like response.location, dunno
but pretty much yeah
isnt location a response header?
uhm, not sure
i think it is
depends on the library you are using
yeah it seems to be working
because the server doesnt give you a location header
The HTTP Location header field is returned in responses from an HTTP server under two circumstances:
To ask a web browser to load a different web page (URL redirection). In this circumstance, the Location header should be sent with an HTTP status code of 3xx. It is passed as...
oh weird im getting the location header with curl too
wait, so it's just me ?
seems to be request being weird
so you were using a lib called 'curl' ?
no, curl is a command line tool https://curl.haxx.se/
oh mb
its working with another http lib im trying rn
hmm but i can see the 'google.com' embedded into something else
oh, what lib is that?
oh, it's discord bot oriented to?
its just a regular http client
so their documentation link dumps me here
not sure where to click
or is the documentation inside their discord server 
honestly, the documentation is trash. the dev is a really nice guy, so if you contact him, he will help you with it
should be on the wiki sidebar
ah thanks
wait, so is chaining = redirecting?
in that case i want it set to true right?
oh ok, so something completely different
yeah
uh, so the example code is giving a bunch of errors already
idunno i feel bad just straight up dm'ing somebody
fine ill do it then
xD
@earnest phoenix send him the errors you got
just want me to dm him? @mossy vine
yeah
we got it working c:
what you're looking for is called "seam carving" or simply "content-aware scaling"
its not something that can easily be done with js
Is the Discord.rb library still a thing?
yeah
Alright.
(node:18953) UnhandledPromiseRejectionWarning: TypeError: u.hasRole is not a function
let total = message.guild.roles.get('622722028121620500').members.map(m => message.guild.members.get(m.user.id));
total.forEach(u => {
if (u.hasRole(ppresenters)) {
presenters.push(u.id)
}
. . .
why not just make the members collection an array
rather than mapping it and then trying to get each one from the guild again
and is GuildMember#hasRole() even a method?
wait what version of d.js are you using
@earnest phoenix in fact that might be useless
both mapping and converting to an array
forEach is already in Map
that's why i asked why is he mapping it
but you could convert the collection to an array of guild members to use forEach()
yes, but there's no need to do that as forEach is inherited with map.
By the way, hasRole is not a property in stable or master. Take a look at the Collection/GuildMemberRolesStore class.
oh ok 👍
not sure if he was on a older version of d.js where/if that property existed
what's the point of https://oliy.is-just-a.dev/ckwl0t_1976.png
you already have the members
oh I didnt read what lite said
so in kotlin should i be checking a List instance for no objects by .size, .isNull(), or isNullOrEmpty()?
to be fair
Probably isNullOrEmpty
Seems the most logical to me
Then again I dont use jvm much so
id think so too, maybe there is some overhead with using it but idk
Yeah
At the installing discord.js step, i hit npm init -y, it created no new files, is that ok?
hey whats up with the server button on the bots? mine hasnt updated in quite a while
poof
```request.post(https://discordbots.org/api/bots/${client.user.id}/stats)
.set('Authorization', 'dblTokenHere')
.send({ server_count: client.guilds.size })
.end();```
I'm not gonna give you my full code for it but that's the basics
After the end you can either do a console.log or a message.channel.send
Ok ya ya
@balmy lantern if you need more help you are free to DM or ping me I just don't want to get in trouble for spoon feeding
what is the primary difference between fold and sort methods on a List instance in kotlin?
from what i see so far it's that fold has an initializer while sort does not
axios > node-fetch > request
I have the right to make a clone order for server owners?
i cant find the error here, is there a hotkey that finds it or something?
nvm
How can I see 3 days after the current time
const math = require('math-expression-evaluator')
var s = (new Date(Date.now()) + '0000-00-03');
let c= math.eval(s)
message.channel.send(c)

Error
[object Object]
why are you evaling it in the first place
(new Date(Date.now()) + '0000-00-03') has already given s a value
const math = require('math-expression-evaluator')
math.eval(new Date(Date.now()) + '+ 0000-00-03');
?
you cant do math like that
a date object will be converted to a string if you do that
Well, how can I add 3 days to the current time?
the "0000-00-03" string will simply be appended to the end of the converted time string
the Date object can only do math operations based on timestamps
so you need to add 3 days in miliseconds to the original date
or use a library that is built for date and time operations like that
but the easiest way is to simply do new Date(Date.now() + 3daysinmiliseconds)
thanks
1 second is 1000ms, 1 minute is 60s, 1 hour is 60m, one day is 24h
3 days = 1000 * 60 * 60 * 24 * 3
👌
whats the best node.js package for a music bot?
it was made by the main developer of d.js
ah ok
I'm waiting that like 1 week for my bot to be approval and no one test it yet how much time should I wait
it can take a while, depending on how many bots are in queue and how much time mods have to work on them
sometimes it takes 2-3 days, other times it takes a week or even more
Great explanation
and got the same answer
yep
I am trying to make a command which can be executed by typing any strings in an array. The only issue, it doesn't work for some reason and I can't find out why
^
it's just cleaner
in my opinion
because I can just list the commands like
requestOrbImage(); (a command)
or
exampleCommand();
can you just attempt to answer my question
^No
The issue you're having is that you're using Array.slice() while probably not knowing what it actually does
It returns an array
yes, I figured that out
beforehand I used [0,1,2] and it didn't work
so I posted a question on stackoverflow
some man suggested slice
..
yes
👀
I couldn't find anything
lol

how is that supposed to help me
Read what the includes() method does
What
People cant help if you aren't willing to learn
But yeah includes
Is a good method
To do things
you really should stop using functions like that, but be my guest.
and yes, the answer to executing the same command from multiple keywords is using array.includes()
how should I use functions
the event listener is the base, the source or all commands
there should only be one event listener, listening to all messages, and then analyzing each message, and firing a relevant function
so the listener should execute functions, not the function execute listeners
because listeners are permanent, they will keep running forever
if you execute a function which creates a listener, the listener will not stop when the function finishes
If you want it to be clean, you can use a command handler
and when you need that function again, it will create a new listener again
and then you will slowly be filling up your memory with endless listeners
multiplying your ram and cpu usage, until your bot crashes
So, how would I use .Includes() to be anything in an entire array?
let array = [1,2,3,4,5];
array.includes(3) // true
array.includes(7) // false```
thats what you asked, unless you want to check if one of multiple items exist in an array
The parameter you pass to it is whatever you're checking
for example, if I used that in an if statement like (if array.includes(2) ) { execute message }
that would be a single thing
that would execute it
I think you're not understanding things because tim used numbers
the number you enter isn't an index
or an item in the array
let array = ["keyword1","keyword2"];
array.includes("keyword1") // true
array.includes("keyword3") // false```
it's if "hi" is in " hi how are you"
but how would you do something like products.includes("apples" or "pears"){ fjsiekhesafessg}
so you want to check if one of multiple items exist in an array
thats a different thing
for that you need to use a combination of array.some() and array.includes()
array.some() takes a function to test each item in the array
and it returns true if one of the tests passes
that will make it always return true, so no
let array = ["one","two","three"];
let itemsToCheck = ["one","five"];
itemsToCheck.some(item => array.includes(item)) // true because one of the itemsToCheck exists in array
how would i put my token in .env?
@fallow spire where are you hosting your bot in?
glitch.com but heroku soon. thats why im asking for that
hm cuz in Tutorial it said use .env
anyway glitch.com uses a shell file, so it would look something like this
token=yourtokenhere
and you can refer to it in another file by process.env.token
so no Botconfig File?
@fallow spire you can use a bot config file
what's the point of putting anything inside an environment variable if the project is private anyway
i need help
I created a small command for levels in my bot
and I want to know how I could use a command to see the ones with the highest level
use keyv with mysql as a database
This is my code when someone sends a msg
well
it is very long
if (message.author.bot) return;
let messagenumber = await keyv.get("messagenumber" + message.author.id);
let messagelevel = await keyv.get("messagelevel" + message.author.id);
let messagedif = await keyv.get("messagedif" + message.author.id);
if (!messagenumber) {
messagenumber = 0;
}
if (!messagedif) {
await keyv.set("messagedif" + message.author.id, 15);
}
if (!messagelevel) {
await keyv.set("messagelevel" + message.author.id, 0);
}
let nmessagenumber = messagenumber + 1;
await keyv.set("messagenumber" + message.author.id, nmessagenumber);
if (nmessagenumber >= messagedif) {
var nmessagedif = messagedif * 2;
var nlevel = messagelevel + 1;
var role;
var obtainrole;
const embed = new Discord.RichEmbed()
.setAuthor(
`Felicidades ${message.author.username}!`,
message.author.avatarURL
)
.setTitle(`Subiste al nivel ${nlevel}!`)
.setDescription(obtainrole)
.setThumbnail(message.author.avatarURL)
.setColor("GREEN");
message.channel.send(embed);
await keyv.set("messagedif" + message.author.id, nmessagedif);
await keyv.set("messagelevel" + message.author.id, nlevel);
}
try to trim it
heroku support env @fallow spire
if they see any error, it is because I cut it badly :v
i use heroku :v
@distant plank you need to load all entries and then sort them
how
from keyv's documentation, they use a Map as the default storage for the in-memory side
so it should be compatible with all js Map methods
hi, so
Yknow how they're now the custom status feature
when will that be a thing in the regular discord API?
or is it already there?
if there is, it should be part of presences, so check that
@quartz kindle Can you give me a little idea or example?
@quartz kindle ^
like in discord.py
idk
like get rid of the "playing" or "streaming" prefix
google yields no good answers
you cant
hhhh
@trail reef seems like until this is merged, all lib developers are on hold https://github.com/discordapp/discord-api-docs/issues/1160


