#development
1 messages ยท Page 956 of 1
return {
name: 'advice',
description: 'gives a random life advice',
category: 'none',
run: async (client, kayn, REGIONS, config, message, args, con, guilds) => {
request
.get('http://api.adviceslip.com/advice')
.end((err, res) => {
if (!err && res.status === 200) {
try {
JSON.parse(res.text)
} catch (e) {
return message.reply('An API Error Occurred :(');
}
const advice = JSON.parse(res.text)
message.channel.send(advice.slip.advice)
} else {
console.error(`REST call failed: ${err}, status code: ${res.status}`)
}
});
},
};
}```
ill give it a shot
@river terrace why all of this lol
then thats why its not working
you cant copy things that dont exist and expect them to work, all of those only work if they are stuctured to work like that elsewhere
none of that code is self contained, it all depends on other code
ohhhhhh
man that makes so much sense
holy crap
why are u so good at explaining things
lol
i litterally dont know what i would do without you tim
you are a freaking legend
you make everything so easy to understand
its so awesome
remember the command handler? go to your main file, find the code that executes the run function
uh huh
something like commandFiles.get(cmd).run()
show that line
ive seen it before
ok
i think i found it
const xpCooldown = new Set()
function runCommand(cmd, message, args) {
try {
commands.get(cmd).run(message, args)
} catch(e) {
console.log(e)
}
try {
if (!message.member) return
if (!userExists(message.member)) return
setTimeout(() => {
try {
if (!xpCooldown.has(message.member.user.id)) {
updateXp(message.member, getXp(message.member) + 1)
xpCooldown.add(message.member.user.id)
setTimeout(() => {
try {
xpCooldown.delete(message.member.user.id)
} catch {}
}, 45000)
}
} catch {}
}, 10000)
} catch {}
}```
is it somewhere in there?
i think its on line 6
@quartz kindle
there are a total of 5 instances where it says commands.get(cmd).run
no
i mean yes
anyway
you see where it says: commands.get(cmd).run(message, args)
the run function is executed with two arguments: message and args
thats basically the entry point, the sender
and this run: async (client, kayn, REGIONS, config, message, args, con, guilds) => { is the exit point, the receiver
the arguments are passed by order, not by name
which means that
.run(something) sends the something
run: async (something) => { receives the something
ofc
ok tim
i think i get it?
OHHHH
so i need to add a .run(something) to my main file and then that something needs to be one of the arguements defined in the new command
right?
such as message
or kayn
no, it means that you cannot add things that dont exist to your commands
so basically in your command, what you think is client is actually a message
so i should change client to message?
and what you think is kayn is actually args
ohhhhhh
ohh
so what if i do this....
run: async (message, args) => {
would that solve the issue?
or would i need to do something else too
yes, that is the correct way to use your command handler
ayeee ok so if i go do that it should work?
yes it should
yussss
thanks so much tim
imma implant this into my brain
TIMMMM
IT WORKED
WOOOOOOOOOO
thanks man
ur a legend
does anyone know why i've got this error :
TypeError: Cannot read property 'id' of undefined``` While trying to read member.guild.id in a guildMemberAdd event ?
It means the member doesn't have an Id value, which probably means something is screwed up earlier in the process
no
not member.ud
Like it's not reading a member at all
member.guild.id
the guild is undefined which shouldn't be the case
Yeah srry
which d.js version are you on
I'm confused
11.6.4
update to v12 ig
you're going to have to anyways
i know
What do ido
w/askali is u gay
but i'm not here to hear ppl telling me "oh update"
...

oh
i'm here to get help with my pb
you're using an outdated version, you cannot come in here and expect that people won't tell you to update
I need help with my server
this is not the place for it
@hasty lotus I have the same problem. And only with this server no other does it
My way around is a try catch
Also djs v11 wayyy better than v12 change my mind
well in a couple months it wont matter
it's 3 months right?
isn't it in october?
Yeah v11 wont support intents, so you'll be switching regardless of whether it's better or not
Yeah early october
idk, I thought it was september
so 4 months
Is message.channel.startTyping() api abuse?
@earnest phoenix was ur bot ever on?
can we go to a vc so i can share my screen cuz im super confused
No i cant vc rn
You need to make one first
for App Whitelist it says pending invite
And then host it which is different for different coding languages
Ignore app whitelist
I wish i can run the command
huh???
do i go to that
Nvm theres a cmd where it shows this msg link but only mods can run it
It's a message link
Goes to #502193464054644737
It shows you a message where it says how to make a bot
So i guess yes if u want
where do i go to code the bot
pick a programming language and start some coding course
how do i find one
try codecademy.com or sololearn.com
how do i code on codecademy.com or on sololearn.com
I hope you don't think codecadamy is a hosting website
Websites provided are for learning how to code, you will be instructed on them what to do
how do i host my bot @split hazel
You should first be learning how to code
the websites i mentioned are for learning how to code
@quartz kindle would you suggest chai and mocha to unit test or do you have other suggestions
no idea, i have never done unit testing lmao

I'll look into it thanks
yep
mocha is fine from my experience
I just want to look for what works best, so I'd test the ones that I see recommended
Jest is pretty popular and nice to use from my experience
haven't used mocha except once a long time ago though so I can't say
#development message
Well, first time i made a discord(.js) bot, I never knew js and just went on lol
test in production :^)
for discord.py, is anyone getting this warning
Unclosed client sessionclient_session: <aiohttp.client.ClientSession object at 0x7f689ac50240>
i am running a task on loop in the background. everytime i terminate the bot, i get this warning
once i run the bot again, the task i was running beforehand continues alongside the newly started task loop
so each time i run, it does the same task +1 more times
for example, if i had a task that posts a message every hour to a log channel, and then run and terminate the bot 7 times, it will post 7 messages every hour
i am running the bot as following
some_other_task.start()
bot.run(token)
where would i put that though?
i'm terminating the script with just ctrl+c, so i'd imagine any processes that are running would get killed?
Im not a python dev, just showing what the docs say
and this kind of just started suddenly, i've been running it like this for months with no problems
Not sure, doesnt even make sense that it'd continue running
this also only happens in production, which is very frusturating
i suspect it has something to do with tmux
const MessageEmbed = require("discord.js");
module.exports = {
name: 'advice',
description: 'gives a random life advice',
category: 'none',
run: async (message, args) => {
request
.get('http://api.adviceslip.com/advice')
.end((err, res) => {
if (!err && res.status === 200) {
try {
JSON.parse(res.text)
} catch (e) {
return message.reply('An API Error Occurred :(');
}
const advice = JSON.parse(res.text)
const embed = new MessageEmbed()
.setColor("YOUR_COLOR")
.setDescription(`**${advice.slip.advice}**`)
.setTimestamp()
.setFooter(message.member.displayName, message.member.user.displayAvatarURL());
message.channel.send(embed)
} else {
console.error(`REST call failed: ${err}, status code: ${res.status}`)
}
});
},
};```
got this lovely advice command
written in javascript
but
it throws an error
says that const embed = new MessageEmbed() is not a constructor
please @ me when u see this and let me know what all i did wrong
@river terrace it should be const {MessageEmbed} = require('discord.js'); using {} allows you to call on what you need. If you don't use it, then you are calling on the entire package.
Ok ty
Np
hello
can anyone help me?
I need help with a bot
i am making with python
it wont work!!!
no errors
just wont work
it includes, ban, kick , and mute
Sorry my magic globe broke so I can't see ur code
sorry about that
Lol
it's over 2000 characters
Oh just send me 1 cmd like kick cmd
Ur started it up and stuff like tht correct
Not tht I see I use js not py but when I began to it looked similar I'm no expert but I believe there's none
@earnest phoenix yes but u have to run the bot
how?
For it to go online
its online
Hmmm
one command work
It is
the first one
"Official Zombia Bot"
it works
the rest
ban, kick, mute wont work
Did u copy & paste ?
like did u go on the internet and search cmds up and cop and paste
Cuz sometimes the internet doesn't give the most updated
i copied the YT
What date were they made?
Yuh I switch js so many times lmao as a beginner
bruh
Not really depends what ur running
im on glitch
U can change the version
Oh
do you know what rewrite is
I've heard of it
I dont really know
I know what type script is but rewrite nah
Can say nunnin bout tht
If I have an array of objects, how would I delete the entire object instead of the properties?
i dont use python
oh
also python for glitch isnt well supported
if you use glitch, you should use node.js
const math = require('math.js');
const Discord = require('discord.js');
module.exports.run = async (bot, message, args) => {
const helpembed = new Discord.MessageEmbed()
.setColor("#B30000")
.setTitle("โ Too few arguments given. Missing a ``calulation value.``")
.addField("**Usage**", "``calculate <calculation value>``")
.setTimestamp()
.setFooter(message.member.displayName, message.member.user.displayAvatarURL());
const lolembed = new Discord.MessageEmbed()
.setColor("#B30000")
.setTitle("โ Too few arguments given. Invalid ``calculation value``.")
.addField("**Usage**", "``calculate <calculation value>``")
.setTimestamp()
.setFooter(message.member.displayName, message.member.user.displayAvatarURL());
if(!args[0] || args[0 === "help"]) return message.channel.send(helpembed);
let resp;
try {
resp = math.eval(args.join(" "));
}catch (e) {
return message.channel.send(lolembed);
}
const embed = new Discord.MessageEmbed()
.setColor("#C8A3FF")
.setTitle("Math Calculation")
.addField('Input', `\`\`\`js\n${args.join(' ')}\`\`\``)
.addField('Output', `\`\`\`js\n${resp}\`\`\``)
.setTimestamp()
.setFooter(message.member.displayName, message.member.user.displayAvatarURL());
message.channel.send(embed);
}
module.exports.config = {
name: "calculate",
aliases: ["cal", "calc", "calculator"]
}```
hey so that's a calculate command but it doesn't give the calculation result, it returns the second embed and i don't get errors, anyone can help?
i dont know node.js
i didnt really read over any of the code but this args[0 === "help"] isnt valid
I need help
does anybody have the discord.js 11.5.1 code where you can generate a code and you can use it to get premium
Anyone here?
yeah
@dusky marsh that is obviously invalid
yeah? i wasnt asking if it was
Nah I mentioned that you can obviously see what's wrong
You are basically doing args[false]
Oh wait you weren't the one asking lol
get premium what
hover over the red circle
495 lines in what seems to be 1 commands file thats cursed
var config = JSON.parse(fs.readFileSync("./config.json", "utf8"))
function save(){
fs.writeFile('./config.json', JSON.stringify(config, null, 2), (err) => {
if (err) console.log(err)
})
}
//in command
config.prefix = input
save()```
```{"prefix" : "!", "colorEmbed" : "", "logsChannel" : ""}```when i change the prefix everything deletes in the json
๐ฉ
Ah yes
var config = JSON.parse(fs.readFileSync("./config.json", "utf8"))
wtf
xd
hello
can anyone help pls
i used this guide to use and setup free hosting
everything was okay
but my bot still isnt online
hey
please help someone
hey helo
just dont use fr$$ hosts
never used heroku ๐ฅบ
me too
rx what do u use
but u can find a chip vps
Use Google cloud free one
i dont know how
then https://google.com/search?q=github+student+pack
or this, u get digital ocean and azure credit
i am new to programing
but i cant
you are not working on a big project
i live in pakistan where there is no electricity for hours!
can u help me to use glitch please
glitch only for js, repl.it is for actually like for almost every known programming language
i have a github,heroku and glitch account
just create an account
i use js
create a new project
node.js project btw
can u send a screenshot
hello-express
not important you can do whatever you want
i like default project names
me too
ok thanks but i did it
๐
is there a tools button?
i heard that glitch auto saves every keyword
that is not good
THERE IS A TOOLS BUTTON
yes
no its not
why
because ueverytime it saves it logins the bot and discord api changes the token for every 1000 login per day
i heared in a guide
Finally, we need to Disable some auto-save features. Glitch automatically saves the file, quite literally, on every keypress you make. And restarts it. This is not only slightly visually annoying, but also damaging to bots โ the Discord API will reset your botโs token if you login 1000 times in a day. That means, if you type 1000 characters in your code, as it is. QUITE an issue.
Create a new file in the project, and call it โwatch.jsonโ.
Paste in the following code in it:
{
โinstall": {
"include": [
"^package\.json$",
"^\.env$"
]
},
"restart": {
"exclude": [
"^public/",
"^dist/"
],
"include": [
"\.js$",
"\.json"
]
},
"throttle": 900000
}
This number, โ900000โ, means that every 15 minutes, if any files have changed, the bot will restart. Now there is a caveat here, which is that this also means any change you do in the bot will not take effect (will not reboot) until, up to, 15 minutes. But hey. Itโs free, letโs not look a gift horse in the mouth!
so I have this code which prevent a user for creating a tag with a name similar to a command name/aliases https://cdn.lumap.me/92r5wd3j.png . When i try to create a ta created help, for example, it returns me the error message about command names, but the tag is still created after. why?
sorrry about spam im not spamming
ok what files do i need to import from github
does glitch support lavalink?
ur bot project
no no what files
all files
so I have this code which prevent a user for creating a tag with a name similar to a command name/aliases https://cdn.lumap.me/92r5wd3j.png . When i try to create a ta created help, for example, it returns me the error message about command names, but the tag is still created after. why?
@tight plinth args[0].toLowerCase() ?
ok
oof
wait a bit rx
k
for of
Oh yeah fuck
i didnt import nodemodules
do i need them
@golden condor can u pls mind your language
Scuse me
excused?
No no no, excuse me what?
do i need them
@earnest phoenix no
if you are working on a glitch project
glitch uses pnpm
^
ok that means that i dont need index.js , package.json and Procfile
no u need
what do i dont need
ok, if you imported everything
you dont need to delete anything
just install packages
using console
and pnpm
ok i imported only index , package and Procfile
ok what command
pnpm install discord.js
?
for what
in discordjs, how can I use ffmpeg with ytdl-core to add filters to music?
for check your packages mate

total 15
check logs
how
add ur bots token
should i run the cmmand again
to check agian
no
uh ok
TypeError: date.getTime is not a function (JS) (line 3)
What wrong?
is there a token file or smth
no
or did u add ur bot's token in index.js
yes
mm
the command is const token
and
const token = 'NzE2OT........................................................................'
Yo does anyone here know how to use tensorflow
no i dont
idk
did u add bot.login(token) or smth
bot.login(token);
mm
Also don't leak the token
hey i didnt leak
i just got some letters
Ik I'm just saying
ok bt for what
{
"name": "discord-bot",
"version": "1.1.2",
"description": "JUST FOR TESTING",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "MUHAMMAD RAFFAY",
"license": "ISC",
"dependencies": {
}
}
i changed some things
{
"name": "CODELyon",
"version": "1.1.2",
"description": "A BOT TO CHEER YOU UP",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "MUHAMMAD RAFFAY",
"license": "ISC",
"dependencies": {
}
}
What is the bot supposed to do

It has no dependencies which is probably incorrect
A store server is running. All store manipulations are delegated to it.
โWARNโ discord.js: prism-media@1.2.2 requires a peer of ffmpeg-static@^2.4.0 || ^3.0.0 but none was installed.
โWARNโ discord.js: prism-media@1.2.2 requires a peer of @discordjs/opus@^0.1.0 but none was installed.
โWARNโ discord.js: prism-media@1.2.2 requires a peer of node-opus@^0.3.1 but none was installed.
โWARNโ discord.js: prism-media@1.2.2 requires a peer of opusscript@^0.0.6 but none was installed.
โWARNโ discord.js: ws@7.3.0 requires a peer of bufferutil@^4.0.1 but none was installed.
โWARNโ discord.js: ws@7.3.0 requires a peer of utf-8-validate@^5.0.2 but none was installed.
โWARNโ discord.js@12.2.0 requires a peer of bufferutil@^4.0.1 but none was installed.
โWARNโ discord.js@12.2.0 requires a peer of erlpack@discordapp/erlpack but none was installed.
โWARNโ discord.js@12.2.0 requires a peer of libsodium-wrappers@^0.7.6 but none was installed.
โWARNโ discord.js@12.2.0 requires a peer of sodium@^3.0.2 but none was installed.
โWARNโ discord.js@12.2.0 requires a peer of utf-8-validate@^5.0.2 but none was installed.
โWARNโ discord.js@12.2.0 requires a peer of zlib-sync@^0.1.6 but none was installed.
this comes when trying to install
Lots of missing dependencies
blob
i dont know, what should be the dependencies
so now he is helping me cool
COOL
Apparently
COOL
Try getting all the dependencies listed
not cool
Which are you using
first of all what is a dependencie
It's a lib that your script is dependent on
ok
what should i add
All of the things listed as missing
???
Idk if there is more then that you posted
what is that supposed to meeN
I DONT UNDERSTAND
can u speed up a bit (just asking)
ffmpeg-static@^2.4.0 || ^3.0.0
@discordjs/opus@^0.1.0
โnode-opus@^0.3.1
โopusscript@^0.0.6
bufferutil@^4.0.1
โutf-8-validate@^5.0.2
erlpack@discordapp/erlpack
libsodium-wrappers@^0.7.6
โsodium@^3.0.2
zlib-sync@^0.1.6
wow
That should be all the dependencies you're missing in the text you send
If you install those then those warnings should go away
{
"name": "discord-bot",
"version": "1.0.0",
"description": "JUST FOR TESTING",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "MUHAMMAD RAFFAY",
"license": "ISC",
"dependencies": {
"discord.js": "^12.2.0"
ffmpeg-static@^2.4.0 || ^3.0.0
@discordjs/opus@^0.1.0
โnode-opus@^0.3.1
โopusscript@^0.0.6
bufferutil@^4.0.1
โutf-8-validate@^5.0.2
erlpack@discordapp/erlpack
libsodium-wrappers@^0.7.6
โsodium@^3.0.2
zlib-sync@^0.1.6 }
}
Yeah and also you need to install them
ONE BY ONE
I think you can do a multi install
using npm
ok
yeah just add a space between packages
Then it will install them all
can u tell how cause errors appear
Yeah
It's trying to use libs that aren't there and it will fail because of that
Hey does anyone here know how to fox the npm librarys
wdym
At line:1 char:22
- ffmpeg-static@^2.4.0 || ^3.0.0 @discordjs/opus@^0.1.0 โnode-opus@^0.3 ...
-
~~
The token '||' is not a valid statement separator in this version.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : InvalidEndOfLin
type node .
You i am
or install pm2
Right
show error
in discordjs, how can I use ffmpeg with ytdl-core to add filters to music? I've seen packages like discord-ytdl-core and prism-media which can do it but i'm not sure how it works and how to change filters mid stream
npm install pm2
Just give me ainite fir my laptop to start
your token is incorrect
That's one
But its not thats the thing
regenerate it
Also get a promise rejection handler
Whats that?
It handeds promise rejection
And how
blob
Which part of the common wrrors am i looking at?
in discordjs, how can I use ffmpeg with ytdl-core to add filters to music? I've seen packages like discord-ytdl-core and prism-media which can do it but i'm not sure how it works and how to change filters mid stream [ping me if you can help out thaks in advance]
i will regen the token and try that. ive done it a few tmes before but i will try it again anyway
Yeah
Like this
npm i ffmpeg-static @discordjs/opus node-opus opusscript bufferutil utf-8-validate erlpack@discordapp/erlpack libsodium-wrapper โsodium zlib-sync
That should install
get rid of node-opus
can someone help me
get rid of node-opus
@pale vessel why
just ask
node-opus is deprecated, @discordjs/opus is enough
Aight
Nooe didnt work to regen
nice token
hm?
Pls get a promise rejection handler
how do i do that?
const DBL = require("dblapi.js");
const dbl = new DBL('eyJhbGdSJdsnajdDJDciOiJIUz233egESwiaWF0IjoxNTkxMTkxNzAyfQ.1g5UJNv70sPfDosr203d_pjtoXPb5-2dsahdhds-dsadhdhn', client);
dbl.on('posted', () => {
dbl.postStats(client.guilds.cache.size, client.Id, client.total);
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(Oops! ${e});
})
wait a minute
where do i put that in my bot?
can u help?
@sacred oyster delete this and regenerate your dbl token

i realized lol
ok
still not good to post tokens though
heres the real one
no thanks
blob how to i get a promise rejection handler?
use .catch or await and try catch
const DBL = require("dblapi.js");
const dbl = new DBL('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjcxMzc0MTA2OTEwMzM5ODk2MyIsImJvdCI6whyNTkxdoMTkxNzAyouyfQ.wantUJNv70sPfDtoosr2know03STOPd_pjtoXPb5-2jGrn-cdoiiq8n', client);
dbl.on('posted', () => {
dbl.postStats(client.guilds.cache.size, client.Id, client.total);
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(Oops! ${e});
})
hellp
client.Id?
process.on('unhandledRejection', error => {
console.error('Unhandled promise rejection:', error);
});
bad practice
thats how you handle promise rejections
can u help pls
after client.on('ready')
seperate
ok above or below?
below
kk
will try that and then send in a picture
Is that giod?
I am going to regen token after
const DBL = require("dblapi.js");
const dbl = new DBL('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjcxMzc0MTA2OTEwMzM5ODk2MyIsImJvdCI6whyNTkxdoMTkxNzAyouyfQ.wantUJNv70sPfDtoosr2know03STOPd_pjtoXPb5-2jGrn-cdoiiq8n', client);dbl.on('posted', () => {
dbl.postStats(client.guilds.cache.size, client.Id, client.total);
console.log('Server count posted!');
})dbl.on('error', e => {
console.log(Oops! ${e});
})
passing client will already handle server stats
Wait have i to put this un too?
yeah
dbl.on('posted', () => {
dbl.postStats(client.guilds.cache.size, client.Id, client.total);
console.log('Server count posted!');
})
that should be taken care of by passing client in new DBL
oj
oh
so
so i do not need to add this dbl.postStats(client.guilds.cache.size, client.Id, client.total);?
its not just this bot either. every bot i make is doing this
i created a new one and still did it
at least the promise rejection is now handled
yeah
are you sure you are using the right token
oh yeah there is less errors now lol hadnt realised
idk. i only have one bot so im assuming so
i deleted all my other ones
no you have a client secret and a token
they are quite similar
but make sure your using the token
am i allowed to swear?
yes
dont take this the wrong way and i dont mean this. but go fuck of
no i was using secret
lemme get the token
yeah it was looking kinda short
@earnest phoenix still doesnt work
i got the token now one sec
yeahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh. woohooooooooooo it works now
thanks blob your the best man
np man
also
doesnt work
ok thanks
in discordjs, how can I use ffmpeg with ytdl-core to add filters to music? I've seen packages like discord-ytdl-core and prism-media which can do it but i'm not sure how it works and how to change filters mid stream [ping me if you can help out thaks in advance]
or self host
how do i self host?
in discordjs, how can I use ffmpeg with ytdl-core to add filters to music? I've seen packages like discord-ytdl-core and prism-media which can do it but i'm not sure how it works and how to change filters mid stream [ping me if you can help out thaks in advance]
we still dont know
how do i self host?
install pm2 add the process and leave ur pc running
oh ok
doesnt work @earnest phoenix
i will proboably just use heroku tn. but when i get back to school i will load it onto the schools server lol
fluster is the token still good
yes
thx for the help blob will proboably be back in a few minutes when i break my bot again bye fn
cause this is the only line im using
const dbl = new DBL(token, client);
and that works
rlly?
yes
also what are u using here to view this
https://cdn.discordapp.com/attachments/272764566411149314/718015841269973096/unknown.png
heroku
didnt break it yet. just a question
how do i get my bot to say
that its playing .
sorry playing .help
client.user.setActivity('.help', {type: 'PLAYING' });
should this work?
kk. where do i put that?
const DBL = require("dblapi.js");
const dbl = new DBL(topggtoken, client);
inside a client ready event
that should work
ok thank you
thank you so much guys
np man
How do I create a uptime?
client.uptime
its in ms tho
so you might want something like this
function msToTime(ms){
days = Math.floor(ms / 86400000); // 24*60*60*1000
daysms = ms % 86400000; // 24*60*60*1000
hours = Math.floor(daysms / 3600000); // 60*60*1000
hoursms = ms % 3600000; // 60*60*1000
minutes = Math.floor(hoursms / 60000); // 60*1000
minutesms = ms % 60000; // 60*1000
sec = Math.floor(minutesms / 1000);
let str = "";
if (days) str = str + days + "d";
if (hours) str = str + hours + "h";
if (minutes) str = str + minutes + "m";
if (sec) str = str + sec + "s";
return str;
}
Ok
!invite
tensorflow discord bot 
You have no idea how much of a pain it it
it is* todo for bots or large scale stuff
and have it not cost and arm and a leg to run
tensorflow discord bot :ThonkDumb:
yeah im trying to make it say stupid shit when you dm it
im currently using dialogflow but i dont like making intents because there isnt any
so it will respond to almost all question with that is doesnt know
thats gonna want a thicc model to go off
true and i have no experience with making ai
How nice they don't accept PayPal payments
hi! i'm trying to add the Reddit API to my bot, but I don't understand how to find the right url. I only found stuff like that : /api/v1/me/karma. Does that mean https://reddit.com/api/v1/me/karma ? Then where do I put the client secret of the reddit app to auth the bot?
you put client secret in the headers
ok
@turbid bough then am I right about the url syntax?
you are
thank you
I've already got these types of errors before with JSON files. What does that mean? ```
Unhandled promise rejection: FetchError: invalid json response body at https://www.reddit.com/r/dankmemes/hot reason: Unexpected token < in JSON at position 0
var config = JSON.parse(fs.readFileSync("./config.json", "utf8"))
function save(){
fs.writeFile('./config.json', JSON.stringify(config, null, 2), (err) => {
if (err) console.log(err)
})
}
//in command
config.prefix = input
save()```
```{"prefix" : "!", "colorEmbed" : "", "logsChannel" : ""}```when i change the prefix everything deletes in the json
a2b, it means that the response isn't JSON
even with that? ```js
fetch('https://reddit.com/r/dankmemes/hot')
.then(res => res.json()) // <--
.then(body => console.log(body))
a get request to https://www.reddit.com/r/dankmemes/hot would yield a HTML string, not JSON
then how should I do?
append /api/v1/me/karma to it
so you interact with the Api
I am not familiar with how reddit's API works
append
/api/v1/me/karmato it
@cinder patio what does that mean?
I figured it out add .json at the end of the 'https://reddit.com/r/dankmemes/hot/'
That will return JSON and not HTML
that's what i use for my meme command lol
cool. (because this doesn't seems like it can be usable by the bot ๐ )
it is lol
:0
it seems like it's the html with .text()
can you show your updated code
This: ```js
fetch('https://reddit.com/r/dankmemes/hot.json')
.then(res => res.json())
.then(body => console.log(body))
Returns this : ```json
{
kind: 'Listing',
data: {
modhash: '',
dist: 27,
children: [
[Object], [Object], [Object],
[Object], [Object], [Object],
[Object], [Object], [Object],
[Object], [Object], [Object],
[Object], [Object], [Object],
[Object], [Object], [Object],
[Object], [Object], [Object],
[Object], [Object], [Object],
[Object], [Object], [Object]
],
after: 't3_gw0pys',
before: null
}
}
btw how can I insert my modhash with headers? Idk how to use them even if I tried
yup, console.log body.data.children maybe those are the posts
yes I think so
"Header-Name": "Header-Value"
}});```
to add headers
thanks 
I also have another problem (this has nothing to do with reddit) : discord.js's Intellisense (on VSCode) doesn't work anymore. Do you know why/ how to fix that please?
Memes
if that can help, I deleted the .vscode file in my workplace a few days ago, but idk if it's related
i think it's just some ssh config stuff
(about reddit again) / how am I supposed to find the picture in that mess ?
oops
excuse me
there isn't any pic
objectobjectobjectobjectobjectobjectobjectobjectobjectobjectobject
smol brain
c l p a
โซ
I resend it:
if got another issue: with this code : ```js
fetch('https://reddit.com/r/dankmemes/random.json', {headers: { "X-Modhash": "token here" }})
.then(res => res.json())
.then(body => console.log(body))
i got this, and `[Array]`s are empty. why? thats weird. ```json
[
{
kind: 'Listing',
data: {
modhash: '',
dist: 1,
children: [Array],
after: null,
before: null
}
},
{
kind: 'Listing',
data: {
modhash: '',
dist: null,
children: [Array],
after: null,
before: null
}
}
]
are they actually empty tho
Why doesn't my reaction collector stop even when I emit the 'end' event on it?
@mossy vine yes they are
so logging body[0].data.children is an empty array?
yes lemme show u
@opaque seal cuz thats not how you stop it https://discord.js.org/#/docs/main/stable/class/ReactionCollector?scrollTo=stop
@opaque seal cuz thats not how you stop it https://discord.js.org/#/docs/main/stable/class/ReactionCollector?scrollTo=stop
@mossy vine and I know for sure that the end event is emitted because it removes all the reactions there:
update.on('end', ()=> {
msg.reactions.removeAll()
})```
why is there 2 objects? ```json
[
{
kind: 'Listing',
data: {
modhash: '',
dist: 1,
children: [Array],
after: null,
before: null
}
},
{
kind: 'Listing',
data: {
modhash: '',
dist: null,
children: [Array],
after: null,
before: null
}
}
]
what does `dist` mean?
ask the documentation
it doesn't say anything about it.
(when i search dist in the site. in the subreddit/random section, there is nothing at all)
Could not extract html5player key: https://www.youtube.com/s/player/c31b936c/player_ias.vflset/en_US/base.js
/rbd/pnpm-volume/5de0ff72-89a9-4da9-9125-fd31caae7a64/node_modules/.registry.npmjs.org/opusscript/0.0.7/node_modules/opusscript/build/opusscript_native_wasm.js:8
var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=function(status,toThrow){throw toThrow};Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_HAS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_HAS_NODE=typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string";ENVIRONMENT_IS_NODE=ENVIRONMENT_HAS_NODE&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMEN
TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received type undefined
at Url.parse (url.js:154:11)
at Object.urlParse [as parse] (url.js:148:13)
at doDownload (/rbd/pnpm-volume/5de0ff72-89a9-4da9-9125-fd31caae7a64/node_modules/.registry.npmjs.org/miniget/1.7.0/node_modules/miniget/dist/index.js:90:28)
at process._tickCallback (internal/process/next_tick.js:61:11)
ยฟWhats is?
async def on_message(message):
if message.author.bot:
return
if not message.content.startswith(prefix):
return
args = message.content.split(" ")
command = args.pop(0).replace(prefix, "").lower()
print(f'!{command} {" ".join(args)}')
if command == "ping":
await message.channel.send(f'Pong! {client.latency}ms')``` How could I make a better command handler than this (this works atm) I am new to discord.py
Are you confident that you don't need commands.Bot instead :p
what is that
The commands extension provided by discord.py
you can but it's a waiste of time
u can make a cog for a group like moderation.py
idk it's just an ideea

does anybody know how to toggle intellisense for a library in VSCode?
Hi
hello
does anyone know how to get just the url from yt-search?
<song>.url i guess
Should i proud of my self ?
what is this
does anyone know how can i do it like i had created setup command bot make a new log channel on it with perm everyone cannot read and the message author can read but i want that bot also read message and send message there
Javascrpit test
ah
does anyone know how can i do it like i had created setup command bot make a new log channel on it with perm everyone cannot read and the message author can read but i want that bot also read message and send message there
im trying to get a list of servers that my bot is in and get the members data in each server but the error is that cannot read forEach of undefined?
what the fuck
isnt get() like the function to get id?
no
does anyone know how can i do it like i had created setup command bot make a new log channel on it with perm everyone cannot read and the message author can read but i want that bot also read message and send message there
@prime glacier ?
{
id: message.guild.id,
deny: ['VIEW_CHANNEL'],
},
{
id: message.author.id,
allow: ['VIEW_CHANNEL'],
},
],
})```
i want to add bot perms
here, the get function is normally used to get a guild object by their id (like bot.guilds.cache.get("264445053596991498") returns the guild object of this server)
yes
kinda
not really
{ id: message.guild.id, deny: ['VIEW_CHANNEL'], }, { id: message.author.id, allow: ['VIEW_CHANNEL'], }, ], })``` i want to add bot perms
does anyone know how to do?!
id: client.user.id
id: client.user.id(botid?)
no
This test is hard :((
i believe so
if anyone want to do it :
https://www.tutorialsteacher.com/online-test/javascript-test
if theres a type when overwriting permissions, the type would be 'role'
if theres a type when overwriting permissions, the type would be 'role'
@digital ibex ok let me try
is there a way to get a list of members of all the server that my bot is in and if the member is in multiple servers how do i only keep one of them?
which lib
is there a way to get a list of members of all the server that my bot is in and if the member is in multiple servers how do i only keep one of them?
@river wing in status?
client.users.cache.size
Py or Js
@earnest phoenix { id: client.user.id, allow: ['VIEW_CHANNEL'] },how can we add multiple permission's
@digital ibex nice
add inside allow array
like how?
javascript tests or any online tests for programming languages are useless
{
id: client.user.id,
allow: ['VIEW_CHANNEL','READ_MESSAGES']
},
{
id: client.user.id,
allow: ['VIEW_CHANNEL','READ_MESSAGES']
},
?
it's not the questions that prove your knowledge and that you would get asked in an interview lol
yes
@summer torrent it gave error
RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number.
show code
type: 'text',
permissionOverwrites: [
{
id: message.guild.id,
deny: ['VIEW_CHANNEL'],
},
{
id: message.author.id,
allow: ['VIEW_CHANNEL'],
},
{
id: client.user.id,
allow: ['VIEW_CHANNEL','READ_MESSAGES']
},
],
})```
VIEW_CHANNEL and READ_MESSAGES are same thing
READ_MESSAGES was renamed to VIEW_CHANNEL
oh thanks @summer torrent
@summer torrent can i make role's like this ?
yes
can you tell me how
use role ID
message.guild.roles.create('muted', {
type: 'role',
permissionOverwrites: [
{
id: message.guild.id,
deny: ['VIEW_CHANNEL'],
},
{
id: message.author.id,
allow: ['VIEW_CHANNEL'],
},
{
id: client.user.id,
allow: ['VIEW_CHANNEL','READ_MESSAGES']
},
],
})
liek this?
@summer torrent i want to make role like it can you tell?
๐
message.guild.roles.create('Muted', {
permissionOverwrites: [
{
color: 1
},
{
deny: ['SEND_MESSAGES']
}
],
})
what are the events that require no special permission (example: "message") ?
id: role ID,
allow: [perms]
ok
@wicked pivot guildMemberAdd/Remove etc
are there no docs for that?
@prime glacier
if (!muterole) {
try {
muterole = await message.guild.createRole({
name: "Muted",
color: "#514f48",
permissions: [],
});
message.guild.channels.forEach(async (channel, id) => {
await channel.overwritePermissions(muterole, {
SEND_MESSAGES: false,
ADD_REACTIONS: false,
SEND_TTS_MESSAGES: false,
ATTACH_FILES: false,
SPEAK: false,
});
});
} catch (e) {
console.log(e.stack);
}
}
discord.js right?
here to create a mute role
let muterole = message.guild.roles.cache.find(r => r.name === "Muted")
if(!muterole) {
try{
muterole = await message.guild.roles.create({ data: {
name: "Muted",
color: "#514f48",
permissions: []
} })
or like this
yes
let muterole = message.guild.roles.cache.find(r => r.name === "Muted")
if(!muterole) {
try{
muterole = await message.guild.roles.create({ data: {
name: "Muted",
color: "#514f48",
permissions: []
} })
for v12
for v12
@earnest phoenix muterole = await message.guild.roles.create({ data: {
SyntaxError: await is only valid in async function
yes
i am using it in async
but if you dont use it in async
so remove the await
@earnest phoenix module.exports = { name: "setupmute", category: "moderation", usage: "setupmute>", description: "Setup the mute role", run: (client, message, args) => { let muterole = message.guild.roles.cache.find(r => r.name === "Muted") if(!muterole) { try{ muterole = await message.guild.roles.create({ data: { name: "Muted", color: "#514f48", permissions: [] } })
is it it?
i dont think u can just "remove the await"
@earnest phoenix
module.exports = { name: "setupmute", category: "moderation", usage: "setupmute>", description: "Setup the mute role", run: (client, message, args) => { let muterole = message.guild.roles.cache.find(r => r.name === "Muted") if(!muterole) { try{ muterole = await message.guild.roles.create({ data: { name: "Muted", color: "#514f48", permissions: [] } })
@prime glacier tryasync(client, message, args)
after that it say's SyntaxError: Missing catch or finally after try๐



