#development
1 messages · Page 1431 of 1
Yes!
My express server is hosted on a vps and I can't use 80 port or 443 port and so
ah, do you have a fetch event listener?
you're trying to ask a very complex question in the midst of a noob that doesn't know programming and a noob that wants to use json as a database, you're going to have a bad time trying to get an answer at this moment I think.
^^
i was about to step in but the chat is too crazy, theres already plenty of helpers here rn
Why is coding so easy?
It's not easy
Yes like all web traffic without redirect
what to do from there
Is!
What you're finding easy right now is copy/pasting code from online tutorials
this wont work
yep i saw
Saying programming is easy because your copy/pasted code works is like saying painting is easy because you finished a puzzle.
the url returns a json
You can regex the request to match the path you want and send request to your server, then await the fetch and send the response back out
depends on what your definition of easy is
Coding Knowledge depends on the developer itself, how easy it is for them to get into programming.
remove semicolon here
remove ; at line 7
Let me research about aloudflare
that breaks the chaining
I have done it so many times because of it failing that I have looked at so much tutorials.
^cloudflare workers
What to do to fix this
use something like node-fetch to send a http request to the url. then process the answer
lol do you have one of these
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
ok but you're still just shoveling code. Take the time to learn the language so you can actually make a bot, not a copy of some tutorial bot.
i mean let's be honest: Every developer copies some stuff to put into their code sometimes 
you arent developing, you're simply copy/pasting. You wont get far without knowing the language
"stuff" yes. 100% of the bot code, no.
Yeah no that's something i agree
development is just copy pasting from your brain 😳
use ` to define the string
https://js.evie.dev/simple-data-types/template-literals this will help you
please read
technically ` doesn't define a string, it defines a template literal. 😉
why concat when you can interpolate
well you can use it to define a string but yea
me wishing java had template literals 
ha
no you can use it to define a template literal 😉
that's why c# is king 
bruh just 'a' + b + 'c'
the strings are evald

A template literal is not technically a string, it's an evaluated template even if it's missing any placeholders.
Yes, I'm a sucker for precision.
i need to get some motivation to start recoding a bot written in js to c#
any recomendations for a "lib"
assembly
dsharpplus or disqord
code in jeve, tis gud langug
read the explanation page I sent you, it'll help.
but that requires reading tho....
how can i remove users reaction?
you didn't read, and you didn't change the thing you had to change.
pls read 😦
Their is a language?
then time to start
pls try 😦
then learn the basics first
i have 4 monitors so i can pull up 3 docs
just change from ' ' to ``
that and dnet isn't being maintained properly anymore
and reading errors
is that client mods? 
y e s
its glasscord
Looks like I might have to myself code the reverse proxy workers
thx
^^^
allows you to modify discord
what errors?
laughs in: .ctach(() => {})

well
to make it transparent
any electron app
yeah
i made teams use it too lol
how can i remove users reaction from message?
but can be used for discord
it's not too bad, just Request and fetch()
you can supply a url as a string to Request
i said it
i don't think cloudflare workers support axios lmao
node-fetch >
axios best, sorry
axios good
Is there any free cloudflare app which does it for free ? 😜
http(s) > bloat ||like axios, sorry||
Except portzilla
there is only portzilla
isn't node-fetch ultimate barebones wrapper around the native methods
i believe in you @old cliff
ig
aren't all libs ultimately wrappers around native methods
true
aren't all libs based on Another lib which is based on another
Not me xD
that's what i dislike about node patterns, install 1 npm package and that single package also installs 10 of its own dependencies
that's all package managers LOL
lol
not really
.net's nuget for example
now i wonder if you could create a cascading npm package that just overflows node on install
no need to install the dependencies if you ship the dependencies yourself
🧠
ah I don't use .net
then start there
in .net it's "do it yourself instead of relying on other packages"
make a package which relys on a package which relys on a package which relys on a package and so on
i know. but then there is the question how many packages did you need
Someone do a dev challenge where you use a package for everything possible
even vanilla js
no. we already pointed you to docs and resources to fix your problem. If you arent going to put effort, why should we? Go find a tutor or somewhere else to ask for spoonfed code, here its against the rules. Vampires are not welcome
there are litterally npm packages for converting a string to lowercase
there are npm packages that just do Number < Number and Number> Number
oh and btw question
node is braindead in some aspects
running js on a server
well js in general
"is THERE PACKAGE That DOES IT fOR ME??"
Im making a bot which does a lot of image processing and it uses an already trained model to determine if an image sent by a user is in the positive category or negative one
basically image classification
and im like
any way I could reduce cpu usage
its not node that is braindead, is half of the community that makes bloated and shit packages for lazy devs, who in turn also make their own shitty packages without a pint of knowledge of js
tensorflow-gpu 
like idk process an image one by one or something
grab some money and get a Server with dedicated GPU
or just downscale the image itself
downscale might be good
nah its already trained
Packages are a good thing. It's that a lot of people use them in a way that's seen as a bad way.
so its gotta be cpu
get a better cpu
there's npm packages for tensorflow-gpu i thought
if you cant beat it brutefoce it
Some of them have C bindings though, which is definitely beneficial. But yeah many packages are just unnecessary
im just planning to make it use less cpu power
if you ever used create-react-app you'd know what is truly bloat
Using custom tensorflow vs using an api such as https://wit.ai ?
api will be limiting you at some point
But its easier than training a custom tensorflow thingy
I thought about making a queue array for each discord channel and making the bot just go through the array of images 1 after 1
ive trained a ML model myself sure its for text clasification but its not that bad
Idk how to use tensor 😩
I'll use wit for the time being for my cursed dm ai-chat feature
had the idea to create a Moderation bot that uses AI to determine if a user should be warned, kicked or banned
ME TOO
but i still suck at c# and collecting data for training the model is annoying
I'll use Google perspective api for checking toxic messages
And flirting messages
And other type of shit messages
To make a kids robolox server secure yay lol
can someone help me build the command "ttt" dm me if yes
Ttt ?
Oh diy
I am using D.js - v12
const got = require('got');
let streamlink = args[0];
try {
let audiotypes = ["audio/aac","audio/mpeg","audio/opus"]
let check;
try {
check = await got(streamlink,{method:"HEAD"});
} catch(e) {
message.channel.send(` **Stream link unable to be played!**`);
return;
}
if(audiotypes.includes(check.headers["content-type"])) {
//Do Stuff
I am trying to get if the audio link is playable, but some times this method is not 100% effective.
Does anyone else have any other ways to do it?
Or copy code from any github repo and convert it to be usable in discord.js
kk
have you checked why it can't be playable sometimes?
[ Command used ] xxx (xxx) - dx!stream http://stream.coronafm.nl:8002/live
PCancelable [Promise] {
_cancelHandlers: [ [Function (anonymous)], [Function (anonymous)] ],
_isPending: true,
_isCanceled: false,
_rejectOnCancel: false,
_reject: [Function (anonymous)],
_promise: Promise { <pending> },
on: [Function (anonymous)],
json: [Function (anonymous)],
buffer: [Function (anonymous)],
text: [Function (anonymous)]
}
(node:40) UnhandledPromiseRejectionWarning: RequestError: Parse Error: Expected HTTP/
Just did a console.log
Egg!
How tooo remove reaction from embed please help??
run it async
atleast its a possible issue since its pending
?
Removing reactions from messages, since embeds are just messages. The answer depends on your library.
it already is await
ohh
discord js.
I mean IDK sometimes it work some times it tells me error
Ok so what are you missing?
you could try a different http lib
although idk why got would be giving you problems
You have to start from https://discord.js.org/#/docs/main/stable/class/Message?scrollTo=reactions
Then you go to .cache which gives you a collection of reactions, which you can get() or find() from. Once you have that, you can use remove() on it.
i mean you're only using it to check if the content-type is audio right?
hold on
let streamlink = args[0];
try {
let audiotypes = ["audio/aac","audio/mpeg","audio/opus"]
let check;
try {
check = await got(streamlink,{method:"HEAD"});
} catch(e) {
message.channel.send(` **Stream link unable to be played!**`);
return;
}
if(audiotypes.includes(check.headers["content-type"])) {
let connection;
oh wait
it's cause you're using HEAD
http://stream.coronafm.nl:8002/live this specific endpoint doesn't handle HEAD
ooh
You guys know any nice api or place from where I could get music to play on my bot since YouTube banned my server ip.
you might have to do a GET and close it after you get headers
youtube has an API
It banned my server ip
an example please
ask your provider for a new IP since the old one is banned
The whole network is banned from yt
buy an ipv6 block and route it
buy into the query for a ipv4 and use it
you can scale music bots without that
you'll have to look through the got docs
I don't use got
but this could take a year
thats one of the main reasons why music bots are a nightmare.
small bots are fine, but scaling it isnt something that can be done easily
Oh wait I could directly play audio without ytdl cause I can use yt api v3 to get direct link to audio / video files
you'll need to route traffic and ratelimit it yourself
the Google API is horrendous to work with
How tf are groovy and rythm built ?
the only google api i've struggled with was the gmail one for subscriptions
Like from where do they get music ?
with over 140 thousand ipv'6s, thats all i can publically say
they use the YT and Spotify API
I'll consider using Spotify api to get yt links of songs to play music from using external links data
i make a large circle around Music bots, they are a pain in the ass to work with
Yeah
But they do nice stuff
So imma make a different bot dedicated to only music and not use that in my main
i dont need them. got spotify premium and if i want someone else to listen to the song im listen to ive got Discord nitro
well yeah
other millions of bots have music
and yet nobody's using them
because monopoly bots like rythm, ayana and groovy kill your recognition
Like plasma kills my main bots
how would i get this to work? Settings is never used and guild.settings is always classified as any, Settings is a typedef
mhm
wait have you tried
@typedef {import('./src/managers/SettingsManager').Settings} Settings
yes
is it a different error?
already did
Guya
Guys
Help
My code
const activities_list = [
"*help ✨ ",
"${bot.users.cache.size} человек на Shard",
"${bot.guilds.cache.size} + серверов на shard",
"Mashiro"
];
bot.on('ready', () => {
setInterval(() => {
const index = Math.floor(Math.random() * (activities_list.length - 1) + 1);
bot.user.setActivity(activities_list[index], { type: 'WATCHING' });
}, 10000);
});```
inb4 template litearls
Why i have status Watching ${bot.users.cache.size} ......
your strings aren't defined with `
^
You probably don't have the intent for the guild count i think
I might be completely wrong though
Users too 0
ok no intent
Well no shit
You are filling the string when the gateway isn't even connected yet
?
Really
How i can fix it so?
your strings are evaluated before the bot gets the ready event
I understood
Create the strings in the ready event
I have it
bot.on('ready', () => {
ACTUALLY create the array in your ready event
it won't update if your server count changes though
About that
How i can do every users and other update?
New event or what?
Create the array in the interval
re-evaluate the strings every time you change your status
How can I have flask show a div in html?
Now it looks like this?
bot.on('ready', () => {
setInterval(() => {
const activities_list = [
"*help ✨ ",
`${bot.users.cache.size} человек на Shard`,
`${bot.guilds.cache.size} серверов на shard`,
"Mashiro"
];
const index = Math.floor(Math.random() * (activities_list.length - 1) + 1);
bot.user.setActivity(activities_list[index], { type: 'WATCHING' });
}, 10000);
});```
Like you click a button, send post to flask, flask sends back to show div
Ye, it works
Thx
LOL @lusty quest
So I was following a tutorial for making an economy bot and did exactly as they said but when I did the node . and then ran the ping command in my server it came back false. If you want me to send the client.js and ping.js files i can.
hey i need a windows/freedos expert to dm me
Is there no other get method to use to get the audiotypes
How to do that exactly
try to find an event that's fired at some point after you get the headers and close the connection when you get that event
How do i add a background to my bots homepage on the website?
If you're referring to your bot page
thank you
does somebody have made snipe command with slappey ?
noop
gotta get back to work
f
that's an a
GOT is bad
const response = await got(`http://stream.coronafm.nl:8002/live`);
console.log(response.body);
``` = I got nothing.
it's awaiting for the server to finish the connection
which it never will cause it's a stream
maybe in treble 😮
can you configure got to have event handlers?
what clef is that
lol i mean you can make it whatever note you want just by changing the clef
const dbl = new DBL('my bot dbl token', { webhookPort: 5000, webhookAuth: 'My authorization' });
dbl.webhook.on('ready', hook => {
console.log(`Webhook on`);
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
});```
help
this isn't working
are you not getting the vote event?
hey guys, when trying to install canvas with
npm i canvas```
I've got this error :
canvas@2.6.1 install /home/paul/Téléchargements/it-hub-bot/node_modules/canvas
node-pre-gyp install --fallback-to-build
sh: 1: node-pre-gyp: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! canvas@2.6.1 install: node-pre-gyp install --fallback-to-build
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the canvas@2.6.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.```I had it installed a few minutes ago, i just deleted the node_modules folders, and now it doesn't install anymore :/
just deleted the node_modules
I cry
have you tried npm install?
note : i don't have any issue reinstalling my other packages
yep :/
try using yarn then
yeah, that too
same error
if (bot.user.presence.status === 'idle'
``` i am trying to get my own bot status cuz i need it for a command but it doesn't seem to work.
the console log says the bot is offline but it isn't
this isn't V12
you have to enable intents
Hello, I'm trying to revoke the OAuth2 token with Postman, but it gives me this error every time. But the content type is x-www-form-urlencoded and the token is correct. Could you help me please?
nope
and also
i had it installed on my vps
and when i tried to use it
it returned me this error
(node:10798) UnhandledPromiseRejectionWarning: Error: Server responded with 404
so, maybe the error comes from canvas ? Meybe they have a server issue and will be fixed in some times, I'll try later
the package should be on npm unless the canvas package has some install script that uses their own servers
is it possible for my bot to get the ping lag for members in a voice channel?
no
shucks
it is not same for everyone by the way
i wanted to get it by member
it is not possible
@verbal sequoia i made it for you
that's what i thought. thanks @summer torrent
:+1:
i have a bot with three commands. Could someone quick code in that only people with an ID can execute these commands?
you know?
it can be done
are you js or python
or anything other
js
okay sound
just compare ids
let ids = ["406765477910544405"]
if(!ids.includes(message.author.id)) return;
send it and ill tweak it by what you want if you want
here
danger
kk
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
index.js
pls just, that all the commands: !add, !edit and !delete can just execute people with the roleID: 274660717305790465
just compare ids. No one will give you code
pls say "You can´t execute that command"
@polar glacier don't spoonfeed 
can I somehow make it to send as much as it can in one message and then send a new one if there's more guilds?
var count = 0;
<client>.guilds.cache.forEach(g=>message.channel.send(${++count}. ${g.name} - ${g.memberCount}))
how could i do something like this https://gyazo.com/98b5d42bf72a44b1e5c253ebbc51fada
you're probably going to hit a rate limit with this code
not probably, will
check out css animations
you'll probably need keyframes
ok
how could you change the pfp of the bot profile pic though?
that's what I was really looking for
you'll need css animations then
it has nothing to do with animation
you want a different pfp than what your bot has on discord?
yea
i don't think you can do that
well then can you add animation to it?
probably
I think you actually can do this if you want
as long as the new profile pic also follows the rules on top.gg
how would you go about that then
you'll have to use css to hide the old pfp then add a new element for the new one
yea that's what im confused about
short documentation on how you can do it
If you're looping over a large array and you're doing things with each element, when you're finished with an element would it be smart to remove it from the array or is there any point
Hey guys
who can give a good guide on how to find and fix memory leaks on Discord.js code
const { channel } = message.member.voice;
if (!channel) return message.channel.send('I\'m sorry but you need to be in a voice channel to play music!');
const serverQueue = message.client.queue.get(message.guild.id);
if (!serverQueue || serverQueue.songs.length === 0) return message.channel.send('There is nothing playing');
serverQueue.songs.slice(1);
if (serverQueue[0]) message.channel.send(new $().setDescription(`🎶 Now playing: **[${serverQueue.songs[0].title}](${serverQueue.songs[0].url})**`));
else message.client.queue.delete(message.guild.id);
``` i have this skip command, but serverQueue just becomes undefinef
pushing to heroku gives me this error:
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 126
remote: npm ERR! node-cron@2.0.3 postinstall: `opencollective-postinstall`
remote: npm ERR! Exit status 126
remote: npm ERR!
remote: npm ERR! Failed at the node-cron@2.0.3 postinstall script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:```
how do i fix this?
@silver lintel evo ?
if u could teach me how to do this https://gyazo.com/98b5d42bf72a44b1e5c253ebbc51fada
@sterile ridge how to gg role bot developer ?
if u have ur bot accpeted by top.gg u can have this role

fck bro I admire u <33
okay, but now i am.
it has to do with opencollective
idk why
it cant run its post install script, it doesn't have permissions to because heroku restricts that
because heroku doesn't give you an actual server
hence why i said this
how can I cache all members with discord.js, so my bot isnt showing 12 users when there is over 100 thousand 😄
damn
maybe reconsider that decision if you're using node
who?
node is horrible with garbage management and your ram is going to explode
callum
Ye, I am aware, just need a proper guild and members cache because the new changes has my api showing all sort of numbers that are off, I need the true numbers lol
cant you use the new properties that got introduced with intents
idk if djs implements them
reee idk lol
you able to direct me to something that helps me out with these new properties?
yeah give me a sec
why my bot not a run
I have coded it, but once in terminal I typed node . Bot not running
debug it 🤷♂️
can we see code.
Or, alternatively, as I said last time you ask, take the logical first step of learning javascript before trying to write a bot.
and any errors
yes. this.
i cannot stress this enough
yea
show it then
i dont want your token.
this
const { channel } = message.member.voice;
if (!channel) return message.channel.send('I\'m sorry but you need to be in a voice channel to play music!');
const serverQueue = message.client.queue.get(message.guild.id);
if (!serverQueue || serverQueue.songs.length === 0) return message.channel.send('There is nothing playing');
serverQueue.songs.slice(1);
if (serverQueue[0]) message.channel.send(new $().setDescription(`🎶 Now playing: **[${serverQueue.songs[0].title}](${serverQueue.songs[0].url})**`));
else message.client.queue.delete(message.guild.id);
``` i have this skip command, but serverQueue just becomes undefinef
i first time use a visual studio code
you never login
below it is a token
you tell your code
"hey create a bot, subscribe to this event, ok bye now"
you get it from discord.com/developer
discord bot devs be like alright guys I've never taken a biology class before but I'm gonna try to cure cancer now
Guys they are smart enough to not show the token, because we said we don't want to see token. smh
bot.login('token')
AHBKABH LMAOO
did yo do that?
I've written it bot.login ('my token')
hmm k
where a bug?
theres a space, its supposed to be bot.login('token')
The space isn't relevant.
Javascript doesn't give a single flying fuck about extra spaces in code 😄
what does javascript care about 🤔
good question
typescript ❤️
Hello, I want to ask a question
hi
Hey
sora can I have a question
🤦
sometimes i wonder how people managed to create a bot
lol
I've got a question
Stop saying you have a question and ask your question.
client.on('guildCreate', guild => {
let prefix = await db.get(prefix_${message.guild.id});
if(prefix === null) prefix = default_prefix;
const channel = guild.channels.cache.find(channel => channel.type === 'text' && channel.permissionsFor(guild.me).has('SEND_MESSAGES'))
const embedpro = new Discord.MessageEmbed()
.setTitle('Thanks For Adding Axira!')
.setDescription('Note : The Bot Is Still In Development So It May Have Bugs')
.addField(Current Prefix : \${prefix}`, Change It With `${prefix}setprefix`) .addField(To See List Of Commands Type : `${prefix}help``, 'Support Server : Join')
channel.send(embedpro)
})
I'm getting the error : await is only valid in async function
So I add async before guild and I get an error : message is not defined
Help I'm bad at js
let prefix = await db.get(prefix_${message.guild.id});
if(prefix === null) prefix = default_prefix;
const channel = guild.channels.cache.find(channel => channel.type === 'text' && channel.permissionsFor(guild.me).has('SEND_MESSAGES'))
const embedpro = new Discord.MessageEmbed()
.setTitle('Thanks For Adding Axira!')
.setDescription('Note : The Bot Is Still In Development So It May Have Bugs')
.addField(Current Prefix : \${prefix}`, Change It With `${prefix}setprefix`)
.addField(To See List Of Commands Type : `${prefix}help``, 'Support Server : [Join]()')
channel.send(embedpro)
})```
client.on('guildCreate', async guild => {
Function must be async.
I added async before guild and I got error : message is not defined
well a message can't appear out of thin air
That would imply someone knows how async/await works and what a "Function" is.
A
Which clearly they don't.
Hello, I'm trying to revoke the OAuth2 token with Postman, but it gives me this error every time. But the content type is x-www-form-urlencoded and the token is correct. Could you help me please?
wait no
lmao
oh wait. yes I See it
I guess
@umbral zealot how can I link voting using my own server's webhook ?
im pretty sure the param is only supposed to be token as per RFC 7009
Check the title in #topgg-api for links to the docs which have examples of code
this should help you
what does that matter
code for avatar display
// Create an event listener for messages
client.on('message', message => {
// If the message is "what is my avatar"
if (message.content === 'what is my avatar') {
// Send the user's avatar URL
message.reply(message.author.displayAvatarURL());
}
});```
code is irrelevant to tools you're using
visual studio code is a editor code
Glitch.com and VSCode are now languages
no hosting app
lol
Discord bots aren't web apps though
i need to stop helping people who use heroku because 9/10 they turn out to be morons lol
i wish more people had complicated and proper questions
True
yea
no
That's not even code
lul
You just need to know the formatting
oh i know
well
no
(click here)[URL]
You're using Bot designer
?
yaya
@hollow sedge isn't it reversed? I usually put in [Text](Link)
big sigh
:)
Maybe
I'm dizzy using Visual Studio Code
I'm dumb
Bruh
lol
lol
Basic idea though
hmm wait
yeah visual studio is a editor code
VSC can still run your bot
Glitch is so bad
wait
Well yeah but it'll be slow
a
It depends
Also it's code editor not editor code
text editor even better
if you have a microwave as your pc
I mean for testing
vsc just runs a terminal process
I lost like 3 braincells just reading above holy fuck
it isn't anything special lol
Yeah
glhf cry
why i type node . in terminal,bot is not running
I bet they're not even in the same folder as the bot
How do i disable something on quick.db?
what?
Wdym? Like delete?
wdym by "disable"?
what to both of these questions
lol
idk what that is
Like disable ecobomy
-_-
can you explain the wall of text
No like the screenshot's url disappears
just send something alongside the url @earnest phoenix i.e. just a dot
discord automatically hides the link
and I don't want that 😃
what are you even trying to show with that image
i am confused on what you're trying to do but it looks like cry understands
Bru
alright imma head out now
@earnest phoenix u pinged wrong person
oh
my bad lol
Lmao
you both have white avys
tbh I would've done the same
not always
because you sent that link before the change that hides it
so, yes always
i hate when people try to be smart
why do people have their own sites just to store random images
wth is fortnite.ro
Who cares
wrong place to ask
lol the urls are hilarious
that url is in discord's cache
so
it won't hide it
images from links behave as embeds
if they're in cache, they're going to use old behaviour
same lol
If u want to make it so it doesn't hide link just add a dot or some text
Next to it
you're either using client mods or you're not on desktop
you mean like create an embed or not?
I am on desktop, not using any mods
I do
👋
dot
dot
hm
send the url of the pic that's in the screenshot
but in ``
so i don't cache it
Man that's a lotta headers
aa
But, I guess, #blamecloudflare
lol
Nah I don't think so
me too
nope
both of them have content-length
if you want it to stay persistent
just send something alongside the url
a dot
or a zero width space
that makes sense
Oh got this entire time I was the one who misunderstood the question 
The one that was answered like 25 minutes ago lol
well
also why are you saying this lol
why not
for anyone that needs it:
https://htmlcheatsheet.com/
@tight scaffold what is that
a cheat sheet for html stuff, used for bot description, etc
So the following code is suppose to check if anyone in the server gets a role updated but it only checks when the bot itself gets their roles updated. How would I make it so he can see when anyone gets a role change? (Yes, he can see a channel with everyone in the server.)
client.on('guildMemberUpdate', (oldMember, newMember) => {
// If the role(s) are present on the old member object but no longer on the new one (i.e role(s) were removed)
const removedRoles = oldMember.roles.cache.filter(role => !newMember.roles.cache.has(role.id));
if (removedRoles.size > 0) console.log(`The roles ${removedRoles.map(r => r.name)} were removed from ${oldMember.displayName}.`);
// If the role(s) are present on the new member object but are not on the old one (i.e role(s) were added)
const addedRoles = newMember.roles.cache.filter(role => !oldMember.roles.cache.has(role.id));
if (addedRoles.size > 0) console.log(`The roles ${addedRoles.map(r => r.name)} were added to ${oldMember.displayName}.`);
});```
Yes this is from discord.js docs.
That's literally the code to check when someone has a new role or a role removed. What do you mean by "role change" other than this?
ok thx
Yes, but it only finds it when its done to the bot itself
not to anyone else
wait wait
Then it means you don't have the MEMBER_UPDATE intents enabled, or requested when you define the bot.
Ohhh let me check that rq
👍
how do I fetch a certain guild with the ID
discord.js?
yeah
hmm
Use <Client>.guilds.cache.get(...)
how can i make a command that only people with the manager server permission can use
What library are you using?
is there a way of checking if mongo db array.length = 2?
well, players react to a embed, adds to a queue in the db, if that db =2, i want to grab two players @hollow sedge
just get the array then and check it in whatever language you're using
const queue1Config = await QueueConfig.findOneAndUpdate({guildId: reaction.message.guild.id}, {"$push": {"playerqueue": user}})
well that pushes them
how do i grab two users then?
use Math.random()?
didnt know you could with db?
im confused on what you're asking
can you give me the code to grab two users from playerqueue?
I told you
Get the queue from MongoDB
Work with it in whatever language you're using
but how do u get it?
function getValues(nameKey, myArray, findValue){
if(!myArray[0]) return;
for (var i=0; i < myArray.length; i++) {
if (myArray[i].id === nameKey) {
return myArray[i].findValue
}
}
}```
it works if I actually do myArray[i].gold
Use .findOne()
Lol
anyway so how do I pass in parameter
return myArray[i].findValue
findValue is a parameter but it doesn't work unless i have the actual name there
idek
What even is myArray
an array with nested objects
findValue is not a JS method
findValue is a parameter
function's parameter?
function getValues(nameKey, myArray, findValue){
if(!myArray[0]) return;
for (var i=0; i < myArray.length; i++) {
if (myArray[i].id === nameKey) {
return myArray[i].findValue
}
}
}
//lottery stats
[{"id":"249803675143241728","gold":"0","common":"0","uncommon":"0","sr"","ur":"2","raidpasses":"5","exp":"4","stamina":"2","rar:"0","ur":"0","raidpasses":"0","exp":"0","stamina":"0","rare":"0"}]
let value = "gold"
console.log(getValues(message.author.id, lotteryStats, value)
Ok I see
so now if I do
return myArray[i].findValue ==> undefined return myArray[i].gold --> 0
oh
Works like a dict instead of an object in that sense
Don't really know if that's the proper explanation
Nah
Help me
ey
How do I make a machine learning script that gets better and better at making discord bots
:(
Is this not simple
import tensorflow
data = {}
tensorflow.makeDiscordBot(data)
Should be something like that
tensorflow?
TensorFlow was originally developed by researchers and engineers working on the Google Brain team within Google's Machine Intelligence Research organization
nice
I'm currently having issues with a return function, and I have no idea why when I put return; it doesn't return and stop doing what was requested. This is happening mainly in my blacklist check:
//Server Blacklist
await botdb.queryPromise(`SELECT * FROM server WHERE serverid = ${message.guild.id}`).then(async function(results){
if(results[0].delmessages === 1) { await message.delete().catch(() => {}); };
if(results[0].blacklist === 1) {
return await message.channel.send(`Hey <@${message.author.id}>! This server is blacklisted from using my commands! Visit my support server to get an appeal done! \nLink: `);
return;
}
else {
//
};
return;
}).catch(console.error);
//User Blacklist Check
await botdb.queryPromise(`SELECT * FROM users WHERE userid = ${message.author.id}`).then(async function(results){
if(results[0].delmessages === 1) { await message.delete().catch(() => {}); };
if(results[0].blacklist === 1) {
return await message.channel.send(`Hey <@${message.author.id}>! You're blacklisted from using my commands! Please visit my support server to get an appeal done!\nLink: `);
return;
}
else {
//
};
}).catch(console.error);
I added a return everywhere I could that wouldn't cause an error and even doubled down.
It continues to run a command, it does send both messages, but it doesn't stop anything from happening.
What mongoose is for mongodb, is there anything similiar for firestore?
if i have a value between 0 and 1, such as 1, 0.863 or 0.4, how can i turn that into a % value in js
i don't do math
how do you still not know this
i literally remember this from a few months ago lol
¯_(ツ)_/¯
i dont use it enough to learn it
stuff doesn't stick in my head unless i use it a lot
neither do i but come on
that's common sense
even if you don't know there's still a ton of resources online for you to learn about it
fair enough then
your bot is missing permissions to do what its trying to do
It's just sending message
then it doesnt have permissions to send a message
Ok I enforced unhandled promise and it was fixed
No errors but no message is being sent
You're handling it, so it won't break and wont do anything
U need to send a message, that ur bot dont have permission to do the stuff
I figured the user used the command in a channel where my bot can see message but can't send message
u can dm the user, or react a thumbs down
or just don't do anything at all if you're missing message perms
you save yourself a request
i mean you can do what curiousbasant said but you'd need to check for reaction perms and there's about a 50% chance a dm will fail
@rocky hearth kind of rude thanks, i didn't get taught it in school
LOL, I dont mean that
I just used a catch block and did nothing.
Not even consoled the error
?
the person you gave the example to copypasted, -1+1 is there lol
yea ik
continuing this, hit too many 401s, 403s (missing permissions) or 429s, you will get api banned for an hour which means no interaction whatsoever
continue this behavior and your bot will be terminated from discord
so it's really not a smart decision to ignore permission errors
a big weeb bot did that and got api banned within minutes of that change
api bans are annoying. got my bot locked out for 24 Hours bcs i reconnected automaticly if the Bot crashed, but without any delay and max attempts to reconnect. this where a Big mistake
if you use pm2 you can config a restart delay and make the restart delay increase by itself too
I think
i know, but i solved it within my code. i just give PM2 a max amount of restarts.
can anyone help?
Can we add something similar to <hr> in embeds
I tried ~~- -~~ but it takes hell lot characters
All I want is something like this
- -
bot.on('guildMemberAdd', member => {
member.guild.channels.get('channelID').send("Welcome");
});
I got it on StackOverFlow
i dont think there is a buildin method for this
That hurts more than the time I rewrote my code written 2 years ago did
- Are you importing
datetimeitself it orfrom datetime import datetime? - What's
Fore? - Can't you just use one
printor format one big f-string?
idk my frnd sent me this code
Yes
@drowsy sentinel i guess the guy above is promoting his server
does anyone know python selenium here?
Selenium is a pretty straightforward python module
yeah ik, i just need help with something
Yes?
extracting certain contents from current url
like a div?
Should i just try hosting it on my website? :/
Take a look at this : https://selenium-python.readthedocs.io/getting-started.html#simple-usage
What you're trying to do here is basic
ok
Oh wait
You're trying to retrieve content from the url itself
And not the html
You don't need selenium for that 🤔
It's just simple string manipulation
You can use regex for that @quaint peak
Or some libs that extracts the parameters from an url
im using it in selenium tho LOL
are let variables declared in a case statement also accessable in the next case statement ? cause I am getting an error that variable fields has already been defined.
no
then why am I getting that error ?
let me test something






