#development
1 messages ยท Page 1238 of 1
Hey guys got a litte question. What do you do with custom prefixes, keep the default bot command and add the custom prefix (listen to two prefixes) or replace the default bot prefix with the custom prefix?
@rare plume replace deafult bot prefix with the custom prefix only for the selected guild
@fringe axle try installing it again
Okay
Okey thanks @earnest phoenix
Okey thanks @earnest phoenix
@rare plume what are you thanking me for XD
For your answer 
some of them are probably because of node-fetch dos vulnerability
then don't
And now?
axios/built-in http gang
uhh try the command again
node-fetch gang
axios/built-in http gang
@slender thistle built-in http sucks
But if there is no phin?
I have node-fetch
i'd use centra
shirnks code by half a line
centra is better than phin
@earnest phoenix what I have to do now?
well, phin uses centra
@fringe axle try the command again
you reinstalled the phin package
should work now
if only i didn't die
huh
smh
wait
@fringe axle you need to await phin requests
they're promises by default
Oh
you can use the unpromisified version by changing
require("phin");
to
require("phin").unpromisified;
Same
async run(message) {
let response = phin({
url: "https://nekos.life/api/v2/img/waifu",
method: "GET",
parse: "JSON"
});
const waifuEmbed = new MessageEmbed()
.setColor(`RANDOM`)
.setAuthor(`Waifus!1!1!`, message.author.displayAvatarURL())
.setImage(await response.url)
.setFooter(`A cute waifu for you ${message.author.tag}!`)
.setTimestamp();
message.channel.send(waifuEmbed)
}
}
``` That's the code
BRUH
can't reference <object>.url if the object is null
await response.url
Same error
@fringe axle remove the await on line 9 keep the await on line 2
await phin(...
how is this profile card?
|| https://cdn.discordapp.com/attachments/750091983191670805/754590906950090782/profile.png ||
const {url} = await phin({ url: "https://nekos.life/api/v2/img/waifu", parse: "json" }).then(x => x.body); 
I tried it too
let response = phin({
url: "https://nekos.life/api/v2/img/waifu",
method: "GET",
parse: "JSON"
}).then(()=>{
const waifuEmbed = new MessageEmbed()
.setColor(`RANDOM`)
.setAuthor(`Waifus!1!1!`, message.author.displayAvatarURL())
.setImage(await response.url)
.setFooter(`A cute waifu for you ${message.author.tag}!`)
.setTimestamp();
message.channel.send(waifuEmbed)
});
}```
Thanks
ask @pale vessel they'll be able to explain it to you better

async run(message) {
const {url} = await phin({ url: "https://nekos.life/api/v2/img/waifu", parse: "json" }).then(x => x.body);
const waifuEmbed = new MessageEmbed()
.setColor(`RANDOM`)
.setAuthor(`Waifus!1!1!`, message.author.displayAvatarURL())
.setImage(url)
.setFooter(`A cute waifu for you ${message.author.tag}!`)
.setTimestamp();
message.channel.send(waifuEmbed)
}
}
``` I tried this now. Still not working
I tried it with await too
can you mix promises and async like that in JS?
not the correct code
Nah.
why let em copy paste
i'll link the MDN docs so you can actually understand what we're tryna say cuz we all suck at explainations
And now? :0
that will explain it better than us

@vague wigeon why are you typing the whole time

:trolllaugh:
@pale vessel I needJSON stringify(urrl)?
no
that's an example
i had to stringify it because runkit shows the image
hm
we're giving you example
And .then is undefined
please read this before trying await and .then shit https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises
Hm
Nah.
@fringe axle what's the actual error
What data type did phin return?
@pale vessel tried to improve the profile card a bit and this is what i have till now
Where do you think I should put the user bio?
https://cdn.discordapp.com/attachments/750091983191670805/754590906950090782/profile.png
What data type did phin return?
@vague wigeon Promise
phin returns a json object if you parse it, otherwise res.body would return a buffer
you have to add .toString() if you don't parse it as json
phin returned undefined
@pale vessel tried to improve the profile card a bit and this is what i have till now
Where do you think I should put the user bio?
https://cdn.discordapp.com/attachments/750091983191670805/754590906950090782/profile.png
@earnest phoenix change the background
Confusion
i can quickly generate some
custom background 
Confusion
@fringe axle more like literally just copy pasting code even and you're understanding nothing
I understand it
show code again
then
why do you need to copy paste our stuff
async run(message) {
const {url} = await phin({ url: "https://nekos.life/api/v2/img/waifu", parse: "json" }).then(x => x.body);
const waifuEmbed = new MessageEmbed()
.setColor(`RANDOM`)
.setAuthor(`Waifus!1!1!`, message.author.displayAvatarURL())
.setImage(url)
.setFooter(`A cute waifu for you ${message.author.tag}!`)
.setTimestamp();
message.channel.send(waifuEmbed)
}
}
and the error is?
haha good one code, .then()
@pale vessel that wasn't intentionally a joke but ok
console.log(phin({ url: "https://nekos.life/api/v2/img/waifu", parse: "json" })) before const {url} @fringe axle
ok
Right
now console.log(phin)
why console.log the whole package
so that you actually know what the fuck phin is
oh
yeah
.then is fucked up because code asked you to use unpromisified would've returned an error otherwise

uh
remove the thing code asked you to add
Nah, I don't use unpromisified

you sure?
const phin = require("phin"); I have this
hmm
https://www.npmjs.com/package/phin see again :v
I see
.then is fucked up because code asked you to use unpromisified
@pale vessel i literally just saidyou can also use the unpromisified version
i'm retarded ok
if Unpromisified, u will use callback!?
I read and read
@pale vessel can you use a local file instead of a URL in loadImage() in canvas package
oops
Means what now?
#memes-and-media it was
try simple
const p = require('phin')
const res = await p('<your url>')
console.log(res.body)
he would need to parse the response
yes you can
@pale vessel lol forgot my express.js server can serve files so i can just send an HTTP request to myself
tell me what returned?
try simple
const p = require('phin') const res = await p('<your url>') console.log(res.body)
@vague wigeon means I need to edit my whole code?
yes
try it first
@pale vessel 
let backgroundImage = await loadImage("http://localhost/miscellaneous/profile-backgrounds/pexels-anna-shvets-3683056.jpg");
@fringe axle
const res = await phin('https://nekos.life/api/v2/img/waifu')
console.log(res.body)
ok
@fringe axle
const res = await phin('https://nekos.life/api/v2/img/waifu') console.log(res.body)
@vague wigeon Nothinh...
try console.log(phin(url))
<@&304313580025544704> 0
-atmods @earnest phoenix
@earnest phoenix
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
?
And what did you even imply with that message
there's something wring with your phin installation @fringe axle
hm
try npm uninstall phin and npm i phin
<@&304313580025544704> Pla no ban
yikes
-atmods
-ban 636227331219914753 Useless mentions to moderators and only responding with ??
Please do not mention (ping) more than one or two moderators for help, unless there is an emergency.
Here are some examples of emergencies:
- Raids / Multiple members mass spamming.
- Severe disruption of Discord's ToS (NSFW content, etc)
- Anything that requires more than 2 moderators to handle.
Banned turkishpro131#4258 (@queen storm)
-b @queen storm Clearly trolling. Pinging mods twice.
That user is already banned...
the pfp too
Lol two atmods
indeed
Keep this channel on topic 

@pale vessel
Changed the color of the font to make it easier to read and made the background better
But the dollar logo was still unviewable so I added a transparent grey back
Made it a little too dark right?
https://cdn.discordapp.com/attachments/750091983191670805/754600522207592458/profile.png
do yall think it would be a good idea to switch from a VPS to a rasberry pi so that i dont have to deal with down time and issues from only the vps and lagging from mongodb url?
Bruh... And how is it working with node-fetch?
you should make the text white
then it will blend with the background
@fringe axle node-fetch also uses promises, js const res = await fetch(url); const json = await res.json(); json.url // the url from the json payload
koya also adds a transparent black back so the text on front is easier to read
but the username doesn't have a back
Oh, okay
@earnest phoenix for the black box i mean
Still a bit hard to read
https://cdn.discordapp.com/attachments/750091983191670805/754601770373611550/profile.png
oh capitalization
make the username a little to the right
and also the localeString
it worked!
not for vale 
Da fuq
I tried to uninstall it
yeah
i like the background
maybe a blur
@pale vessel i can't directly do that in canvas so i'll edit the source image
i don't have photoshop ;-; 
Why he still needs phin?! I uninstalled it...
you totally shouldn't get cracked photoshop from m0nkrus
@vague wigeon one line console.log((await phin({ url: "https://nekos.life/api/v2/img/waifu", parse: "json" })).body.url) 
im totally not encouraging use of pirated software
reinstall :v 
I want to fully delete it
uninstall === fully delete
remove require("phin") in your code
=== datatype and value are both same
remove
require("phin")in your code
@pale vessel of course I did that
wait
@fringe axlei knew you were just copy pasting code without understanding anything
Why the fuq...
other modules need phin
install it back
Mhm. nice idea
In the node_modules
go back one folder
/vale/bot/<here>
try uninstalling it first
@pale vessel should I make the background more blurry?
try uninstalling it first
@pale vessel error
ok
@pale vessel the username looks absolutely disgusting with stroke
https://cdn.discordapp.com/attachments/750091983191670805/754606498562179092/profile.png
hmm
why did you remove fillText
@fringe axle learn to read errors
fillText -> strokeText
@fringe axle learn to read errors
@earnest phoenix hmm
try backup your bot and create new project, put code again ๐
I just want to delete this fully fkcing package
I just want to delete this fully fkcing package
@fringe axle it's not the package's fault
try backup your bot and create new project, put code again ๐
@vague wigeon Good joke. I need to add a new folder in my server, link them, and and and
Or I just want to install this dumb package
it's not the package's fault
It is because the error is in the package
no
the root is your package.json
did you even read the error
some kind of loop happening in YOUR package.json which fucks up phin's package.json
That's phin
No kidding, I think the node_module directory is broken
I tried to reinstall everything
nothing will be lost
except some discord.js cache which doesn't matter that much
No kidding, I think the node_module directory is broken
@vague wigeon * node_modules
@fringe axle delete node_modules directory
yep
I do
tested on my friend's pfp
make the avatar higher res i guess
Can background be an image url?
yes
change another background :\
i just exported my project from glitch and now its saying ```/home/juls07/echo-bot-discord-juls07/node_modules/discord.js/src/client/Client.js:41
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/juls07/echo-bot-discord-juls07/node_modules/discord.js/src/index.js:8:11)
upgrade node version
oh
catch(){} not catch{}
not my code its in discord.js
@vague wigeon catch { is a thing since node 10 or smth
oh
yeah i need to update as its nodejs 8 yikes
Thanks for that information
yeah im doing that now
Still the same error...
@fringe axle what error
is there anything above that
ok
or install it global
or install it global
@molten yarrow how? ;__;
I want to uninstall everything with phin
npm i -g
youre on windows?
Linux is the server
did you install it on linux or on your win?

did you install it on linux or on your win?
@molten yarrow linux
no one cares
why star
ynot
smh

literally just delete the node_modules folder and remove it from your package.json ??
what do you not understand about this simple instruction
Did that already...
also delete your package-lock
Oh, delete package-lock and oackage.json too?
no
package.json is your entry file for a project
you need it
delete package-lock and node_modules though
I know. I tried that already. Same error as you see

delete package-lock, delete node_modules, remove the dep from package.json and run npm i
Okay
HEllo
there node 14 is installed (i absolutely despise the people who created apt-secure)
does anyone here know vue/nuxt
Ask2ask. What's your question?
yeet
i have a component called Alert and i want to know how to pass it props
tried <Alert warning="This is the content" />
but {{ warning }} does nothing
@misty sigil
delete package-lock, delete node_modules, remove the dep from package.json and run npm i
He said me this... now my bot wont work anymore
ctrl+z
nothing can go wrong unless you failed to follow simple instructions
ctrl+z
or look in the trash folder
do you have a package.json
Of course
ah so ur package.json doesnt contain dependencies
at least thats what i see from that
He said to delete me the dependencies
Wow....
โจ reading comprehension โจ
thats like 3rd grade stuff there
anyone here ever work with nextjs and the next/router?
I have this code in my index.js
const config = require('./config.json');
and the content of my config.json is
{
"default_prefix": "?"
}
But I am getting an error: TypeError: Only absolute URLs are supported. What is causing the error?
.
?
you don't.
: (
if youre gonna make a bot at least put some investment into it
well, uh, tough luck ig
can u buy hosting with steam?
bruh what
i got $20 in steam
can someone help me with my question?
paypal?
yes
WAIT YOURE 14 AND HAVE A PAYPAL ACCOUNT?!?!
ye

theres https://witherhosting.com/ and https://contabo.com/
๐โ๐จ ๐โ๐จ
repl it goes offline
still, goes offline at times.
oof
me 2
?
absolute path means like C:/users/matthew/documents/github/bot/config.json
@carmine summit
ur name is matthew?
can bitrise.io keep my bot?
im not self hosting my bot ofc
always has been
please
where u hosting then
||repl.it||
chrome just crashed
just buy a vps
can bitrise.io keep my bot???
nah im too poor
idk
and my bot barely goes offline with that hosting
no @vague wigeon.
5 minutes offline i think average everyday
just buy a vps 
what host

honestly vps is worth it lmao
heroku
heroku sucks
so does repl
true
i got one for testing then getting another one to host my bot
repl is alright ig but
why?
IDK anything about repl
do u use github to host it on heroku
@carmine summit use path
you only get
const config = require('./config.json');
and ram and cpu is limited
it is on repl too
const config = require(__dirname + './config.json');
try something like that @carmine summit
shit i entirely forgot about __dirname
haha
const config = require(__dirname + '/config.json');
do u use github to host it on heroku
@fiery hamlet yes?
i have not used dirname in so long lmao
repl.it is a testing IDE/environment
Sure, they're not against programs running 24/7 with uptime robots, but it's still a "meh" idea
function getInfo(value) {
const endpoint = `https://en.wikipedia.org/w/api.php?action=query&list=search&prop=info&inprop=url&utf8=&format=json&origin=*&srlimit=20&srsearch=${value}`;
fetch(endpoint)
.then(response => response.json())
.then(data => {
const results = data.query.search;
return results;
})
.catch(e => console.log(e))
}
Why this return undefiened
i returned to result
but still undefiened
uhh
you have to return the fetch
otherwise the function itself is still not returning anything
return fetch(endpoint)
.then(response => response.json())
.then(data => data.query.search);
i think....
async function bla() {
let a = await fetch()
return a;
}
function bla() {
return fetch()
}
both ways work, both ways can be used as await bla() or bla().then()
Hey tim
yes
check https://top.gg/api/docs
message.channel.send(embed).then(m => {
const filter = user => user.id == message.author.id;
m.channel.awaitMessages(filter, { max: 1, time: 30000, errors: ['time'] })
I think the awaitMessage is not woking
cuz it does nothing
i console.log(collected) but it not console.logging
you're not collecting anything?
yes
i think the filter
is wrong
m.channel.awaitMessages(filter, { max: 1, time: 30000, errors: ['time'] })
.then(collected => {
you should probably await otherwise you're going to end up with a big stack of thens
yes
oh
oh no
where is the syntax error here?
Why tf this error is coming?
Why tf this error is coming?
@fringe axle I think wrong pathname
I tried so many times to reinstall my packages
which hosting service is that?
It's PM2 Logs
collected.content //undefiened
uhh this is undefieneed : /
so its in your vps?
deleted: false,
id: '754634467204792384',
type: 'DEFAULT',
system: false,
content: '1',
so its in your vps?
@quartz kindle it's on a server, yea.
whats your quick.db and better-sqlite3 version?
uh
in your package.json
try npm rebuild better-sqlite3
ok
@earnest phoenix collected is a collection
I don't know what's wrong.
// ----------- In npm package ------------- //
let coin = function nsfwCoin(type) => {
if(type === 'Normal') {
let Coins = [Heads, Tails];
var Result = Coins[Math.floor(Math.random() * Coins.length)];
return Result;
}else{
let Coins = [Heads, Tails];
var Result = Coins[Math.floor(Math.random() * Coins.length)];
return Result;
}
}
module.exports = coin;
// -------- In discord commands ---------- //
let Send = nsfwCoin(Normal);
var EmbedR = new Discord.MessageEmbed()
.setTitle('NSFW Coin')
.setImage(Send)
message.channel.send(EmbedR);
yes
@hidden cedar Normal should be a string, not a variable? unless you have let Normal = "Normal" lol
(node:9118) UnhandledPromiseRejectionWarning: Error: val is not a non-empty string or a valid number. val=null
console.log(require("ms")((new Date() - res.timestamp), { long: true }));
smh
@earnest phoenix
ADIM
nerden
biliniyo
@earnest phoenix english
turkey
-notr
No turkish here !
what name yusuf
@novel estuary
(node:9118) UnhandledPromiseRejectionWarning: Error: val is not a non-empty string or a valid number. val=nullconsole.log(require("ms")((new Date() - res.timestamp), { long: true }));smh
@earnest phoenix that only accepts strings as a parameter
so what i have to do ?
Mods help
mute them
require("ms")((new Date() - res.timestamp).toString(), { long: true })```
uhh ok
Cast it to a string
ok
@open rune will the call function be
let Send = nsfwCoin('Normal');
or
let Send = coin('Normal');
.setFooter(`${require("ms")((new Date() - res.timestamp).toString(), { long: true })} ago`)
@earnest phoenix :((
What are you trying to do
to get when that info has been updated
.setTimestamp()```
OMG
i am dumb
@hidden cedar
let Send = nsfwCoin('Normal');

Because some reason I did
let Send = nsfwCoin('Normal');
But it saying nsfwCoin not a function
Console:
(node:19647) UnhandledPromiseRejectionWarning: TypeError: nsfwCoin is not a function
nsfwCoin() what is taht
show code
coin(...param)```
You define the nsfwCoin function as coin
how do you require it
Someone tf knows?!
did the rebuild complete?
Yea
or did it error?
That worked and fixed the other error
ok wtf does != mean
not equal?
ohhhh
Your shard died before the master process client emited it's ready event @fringe axle
oh
hey why is my weather-js bot only searching for the first worrd? like $po partly cloudy. It only searches for partly .https://pastebin.com/8ggXuGbp
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.
But it worked before
Your shard died before the master process client emited it's ready event @fringe axle
@earnest phoenix it worked before...
Then it's a connection problem
Means?
let Send = coin('Normal');
Console Output:
(node:22243) UnhandledPromiseRejectionWarning: TypeError: coin is not a function
@honest perch example
!js suck = js is good
ez
its not a connection problem, the process is crashing because of the v8 error above
ok wtf does != mean
this is basic of basicโข
lol
its not a connection problem, the process is crashing because of the v8 error above
@quartz kindle What's that v8 error though
a native module crash
da fuq
native php
do you have any other native modules besides sqlite3?
Means what?
^^^ aka c++ module crash iirc
show your whole package.json
anyone that could help me with my problem?
{
"name": "wawa",
"version": "1.0.0",
"description": "Wawa - Discord Bot",
"main": "index.js",
"scripts": {
"start": "node .",
"pretest": "eslint --ignore-path .gitignore .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Vale",
"license": "ISC",
"dependencies": {
"@discordjs/opus": "^0.3.2",
"alexflipnote.js": "^1.2.3",
"asn1": "^0.2.4",
"assert-plus": "^1.0.0",
"aws-sign2": "^0.7.0",
"axios": "^0.19.2",
"better-sqlite3": "^7.1.0",
"canvacord": "^3.0.9",
"canvas": "^2.6.1",
"centra": "^2.4.2",
"cheerio": "^1.0.0-rc.3",
"common-tags": "^1.8.0",
"country-emoji": "^1.5.4",
"ctx": "^0.3.0",
"discord-giveaways": "^4.2.1",
"discord.js": "github:discordjs/discord.js",
"discord.js-commando": "github:discordjs/Commando",
"extend": "^3.0.2",
"ffmpeg-static": "^2.7.0",
"follow-redirects": "^1.12.1",
"http-signature": "^1.3.4",
"iso-639-1": "^2.1.3",
"json-stringify-safe": "^5.0.1",
"moment": "^2.27.0",
"ms": "^2.1.2",
"opusscript": "0.0.7",
"pm2": "^4.4.0",
"psl": "^1.8.0",
"quick.db": "^7.1.1",
"request": "^2.88.2",
"simple-youtube-api": "^5.2.1",
"sshpk": "^1.16.1",
"string-toolkit": "^1.0.59",
"tough-cookie": "^4.0.0",
"weather-js": "^2.0.0",
"ytdl-core": "^2.1.7"
},
"devDependencies": {
"@getify/eslint-plugin-proper-arrows": "^8.0.1",
"@getify/eslint-plugin-proper-ternary": "^3.0.1",
"babel-eslint": "^10.1.0",
"eslint": "^5.16.0",
"nodemon": "^1.19.4",
"prettier": "^1.19.1"
}
}
@fringe axle nodejs version?
12
hmm
get latest :)
did you recently move/copy your node_modules folder?
It's not related to that, quick.db and better-sqlite3 has different binaries
did you recently move/copy your node_modules folder?
@quartz kindle yes
then you need to reinstall everything
But I tried to run it in VSC. Working
npm install
then you need to reinstall everything
@quartz kindle did it already
okay
hey why is my weather-js bot only searching for the first worrd? like $po partly cloudy. It only searches for partly .https://pastebin.com/8ggXuGbp
Pastebin
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.
if it fails, delete your node_modules foler and install everything again
Bruh... my friend is rebooting the server atm. xD
@eternal osprey did you made your bot?
@eternal osprey dont split it
just to be sure you know what every line of your code does
yeah i know
let [skytext] = msg.slice(prefix.length).split(" ");
you dont need this
you dont need to split here
okay let me delete the split
also remove the []
Yes sure
anyway i g2g
@lyric valley
I am making a poll command in which the correct usage is >poll QUESTION "YES""NO"
This works perfectly fine
what i did was split the message.content by "
i fixed my problem, thanks!
is there a way i can check if the synatax is right
pleae provide your code when asking questions.
i.e i want to check if there is no problem after "
@eternal osprey yea ik wait
var doublequotesplit = message.content.split(`"`)
var Question = doublequotesplit[0].substring(6);
var pollembed = new Discord.MessageEmbed()
let CHOICE2 = doublequotesplit[3];
if(!Question){
message.channel.send(`There Was No Question Mentioned`);
let pollusage = new Discord.MessageEmbed()
.setColor(`0x32ddff`)
.setDescription(`Usage : >poll QUESTION "CHOICE A" "CHOICE B"`);
message.channel.send(pollusage);
}
else{
pollembed.setTitle(Question);
pollembed.setDescription(`:a: ${doublequotesplit[1]}\n \n :b: ${doublequotesplit[3]}`)
pollembed.setFooter("Requested by "+message.member.user.tag, message.author.displayAvatarURL({ dynamic: true })+"?size=512")
message.channel.send(pollembed).then(pollembed => {
pollembed.react('๐
ฐ');
pollembed.react('๐
ฑ');
})
}```
in this how can i check if doublequotesplit[2] is not null or spaces
like do i replace spaces with nothing
or check if its null idk
if (doublequotesplit[2] === ...)?
... ๐ค
So, you want user uses double quotes outside the choice like this: "CHOICE A"
@open rune yea see ideally doublequotesplit[2] should be null but if user makes an error in that like gives only 1 " after 1st choice
then i want to get that situation and send help msg
or something
there is a command startsWith() and endsWith()
All issues fixed. :)
@open rune didnt get ya ๐ฆ
well, I will try make one for you and let see if I can
How to change discordjs to eris no bug :))))
see all i want to do i check if user makes an error in syntax of choices
i got question covered already
Ok, hold on
ok !
Discordjs vs Eris
Why that:
0|index | TypeError: Cannot read property 'message' of undefined
0|index | at module.exports (/home/user/Astro/events/messageReactionAdd.js:4:16)
0|index | at Client.emit (events.js:315:20)
0|index | at Client.<anonymous> (/home/user/Astro/bot.js:350:9)
0|index | at runMicrotasks (<anonymous>)
0|index | at processTicksAndRejections (internal/process/task_queues.js:97:5)
MessageReactionAdd.js:
module.exports = async (client, reaction, user) => {
try {
// Don't listen to DMs or Bots
if (reaction.message.channel.type !== 'text' || user.bot) return;
Raw event:
// Listen to raw events to emit messageReactionAdd event on uncached messages
client.on('raw', async event => {
// Listen only to reactionAdd events
if(event.t !== 'MESSAGE_REACTION_ADD') return;
const { d: data } = event;
if(typeof client.channels.cache.get(data.channel_id) === 'undefined') return;
const channel = client.channels.cache.get(data.channel_id);
// if the message is already in the cache, don't re-emit the event
if (channel.messages.cache.has(data.message_id)) return;
const user = await client.users.fetch(data.user_id);
const message = await channel.messages.fetch(data.message_id);
// Custom emoji are keyed by IDs, while unicode emoji are keyed by names
const reaction = message.reactions.cache.get(data.emoji.id || data.emoji.name);
client.emit('messageReactionAdd', reaction, user);
});
D.js for ease of use, Eris for big bots and required js exp
It happens sometimes not always and I don't know why
About performance?
d.js uses lil more ram compared to eris
Not too much, redis isn't that much more performant
If you have the effort to switch from discord.js just switch language completely at this point. For example JDA it's really nice
(if he switches because of the ram cough, jvm just eats more ram)
just use djs-light then
I am using python to build a bot.
So can anyone tell me that how to use an embed colour?
For the bot
(if he switches because of the ram cough, jvm just eats more ram)
oh xD
:|
just use djs-light then
@tight plinth i see it!!
w h y s t a r
Why not?
let Send = coin('Normal');
And I tried
let Send = nsfwCoin('Normal');
coin and nsfwCoin comes back not a function
Code for new people looking #development message
Why that:
0|index | TypeError: Cannot read property 'message' of undefined 0|index | at module.exports (/home/user/Astro/events/messageReactionAdd.js:4:16) 0|index | at Client.emit (events.js:315:20) 0|index | at Client.<anonymous> (/home/user/Astro/bot.js:350:9) 0|index | at runMicrotasks (<anonymous>) 0|index | at processTicksAndRejections (internal/process/task_queues.js:97:5)MessageReactionAdd.js:
module.exports = async (client, reaction, user) => { try { // Don't listen to DMs or Bots if (reaction.message.channel.type !== 'text' || user.bot) return;Raw event:
// Listen to raw events to emit messageReactionAdd event on uncached messages client.on('raw', async event => { // Listen only to reactionAdd events if(event.t !== 'MESSAGE_REACTION_ADD') return; const { d: data } = event; if(typeof client.channels.cache.get(data.channel_id) === 'undefined') return; const channel = client.channels.cache.get(data.channel_id); // if the message is already in the cache, don't re-emit the event if (channel.messages.cache.has(data.message_id)) return; const user = await client.users.fetch(data.user_id); const message = await channel.messages.fetch(data.message_id); // Custom emoji are keyed by IDs, while unicode emoji are keyed by names const reaction = message.reactions.cache.get(data.emoji.id || data.emoji.name); client.emit('messageReactionAdd', reaction, user); });
@opaque seal just use if statement to ignore
no I think the channel was not cached so it couldn't get the message too and so the reactions, I've used resolve everywhere in the Raw event now
Nobody answered to my question
@sick fable https://cog-creators.github.io/discord-embed-sandbox/
Thanks bro
So can anyone tell me that how to use an embed colour?
@sick fable HEX/integer codes for colors
Oh
There are some built-in classmethods for discord.Embed
So what would be the function?
@sick fable just use this
{
"purple_dark": "#6a006a",
"purple_medium": "#a958a5",
"purple_light": "#c481fb",
"orange": "#ffa500",
"gold": "#daa520",
"red_dark": "#8e2430",
"red_light": "#f94343",
"blue_dark": "#3b5998",
"cyan": "#5780cd",
"blue_light": "#ace9e7",
"aqua": "#33a1ee",
"pink": "#ff9dbb",
"green_dark": "#2ac075",
"green_light": "#a1ee33",
"white": "#f9f9f6",
"cream": "#ffdab9"
}
copy and save it in a json file
Read docs to see the built-in colors
Kk bro
discord.Color specifically iirc
json
onst economy = require('../economy');
const levels = require('../levels')
const { MessageEmbed } = require('discord.js');
module.exports = {
name: 'balance',
description: 'shows ur balance',
cooldown: 5,
async execute(message, args) {
const target = message.mentions.users.first() || message.author
const targetID = target.id
const guildId = message.guild.id
const userId = target.id
const level = await levels.getLevel(guildId, userId)
const coins = await economy.getCoins(guildId, userId)
const BalanceEmbed = new MessageEmbed()
.setAuthor(`${target.tag}`, `${target.displayAvatarURL()}`)
.setDescription(`Crystals: ${coins}\nLevel: ${level}`)
.setFooter('Your balance is per-guild. don\'t ask if you have 0 crystals in one server and 10 in another server.')
.setTimestamp()
message.channel.send(BalanceEmbed)
},
};```
the `Level:` returns undefined
how to fix it
how to display items coming from python in web using flask
can anyone answer my issue
console log level
how to display items coming from python in web using flask
@earnest phoenix define "display"
You could probably use Jinja for that
I tried jinja but I am returning a list, I tried parsing via javascript but dunno
otherwise ill have to do it one by one for list elements
@cinder sandal how ur level look like ?
const economy = require('../economy');
not onst
hi guys have a question regarding premium bot... what license you are using if you are going to use it as saas? I mean development License since my code is hosted on Github
not
onst
@earnest phoenix i did a typo that i copied the code wrongly
it is const in the real code tho
console log level
@honest perch console logged it, says undefined in console
how ur level file look like ?
inside the level file?
ok
i will use hastebin
ok
the file is large in lines
ok
uh.. Reddit's API docs is melting my eyes. So im here
... What is the endpoint to get a random post from a subreddit???
otherwise ill have to do it one by one for list elements
@earnest phoenix I mean...
here is the level.js code, it is sent as a file because it's big
" ".join(your_list)
@earnest phoenix here's the code i uploaded it as a file because it's big
@carmine summit https://www.reddit.com/r/subreddit.json?sort=top&t=week
then get a random result
ReferenceError: shard is not defined in shard.respawn(), someone know?
@lyric valley do you want something like this?
if(cmd === "poll") { // change it to be your command thing
var doublequotesplit = msg.content.split(' ')
var sliceA = doublequotesplit.slice(2,3).join(' ');
var sliceB = doublequotesplit.slice(3).join(' ');
var q = doublequotesplit.slice(1,2).join(' ');
if(!doublequotesplit.length) return console.error('Required an argument');
if((sliceA.startsWith('"') && sliceA.endsWith('"')) || (sliceB.startsWith('"') && sliceB.endsWith('"'))) {
var pollembed = new Discordjs.MessageEmbed()
pollembed.setTitle(q);
//pollembed.setDescription(`:a: ${doublequotesplit[1]}\n \n :b: ${doublequotesplit[3]}`)
pollembed.setDescription("Your question is: "+q+"\nChoice A: "+sliceA+"\nChoice B: "+sliceB)
pollembed.setFooter("Requested by "+msg.member.user.tag, msg.author.displayAvatarURL({ dynamic: true })+"?size=512")
msg.channel.send(pollembed).then(pollembed => {
pollembed.react('๐
ฐ');
pollembed.react('๐
ฑ');
})
} else if (!q) {
msg.channel.send(`There Was No Question Mentioned`);
let pollusage = new Discordjs.MessageEmbed()
.setColor(`0x32ddff`)
.setDescription(`Usage : >poll QUESTION "CHOICE A" "CHOICE B"`);
msg.channel.send(pollusage);
} else {
console.error('Error: You didn\'t add "')
coll.delete("poll");
}
} else { return }
Sorry just messed up with your codes
inside the level file?
@honest perch
i see shit all
@carmine summit
https://www.reddit.com/r/subreddit.json?sort=top&t=week
@honest perch thanks
const getLevel = async (guildId, userId) => {
await mongo().then(async (mongoose) => {
try {
console.log('running findone')
const resultLVL = await profileSchema.findOne({
guildId,
userId,
})
console.log('debug mode says: result:', resultLVL)
let level = 1
if (resultLVL) {
level = resultLVL.level
return level
} else {
console.log('Debug mode says: Inserting Documents')
await new profileSchema({
guildId,
userId,
level
}).save()
return level
}
} finally {
mongoose.connection.close()
}
})
}
module.exports.getLevel = getLevel```
this is the bad piece of code
module.exports.getNeededXP = (level) => level * level * 100
module.exports.addXP = async (guildId, userId, xpToAdd, message) => {
@cinder sandal ^^
when u get level
after commandslike <mine <chop
const level = require("../level");
level.addXp()
level.getNeededXP()
so i need to use getNeededXP() or no
wdym ?
so i need to replace getLevel with getNeededXP and remove the getLevel in levels.js?
???
module.exports.getLevel = async (guildId, userId) => {
same
fix it
and delete thoose
module.exports.addXP = addXP
const Discord = require('discord.js')
module.exports = {
name: 'snipe',
execute(client, message, args){
const msg = client.snipes.get(message.channel.id)
if(!msg)return message.channel.send("There are no deleted messages")
const embed = new Discord.MessageEmbed()
.setAuthor(msg.author)
.setDescription(msg.content)
if(msg.image)embed.setImage(msg.image)
message.channel.send(embed)
}
}```
Why it dont run
what they even do
exports the function
show what u have done
where?
the level file
module.exports = function mute(time, target, muterole) {
setTimeout(() => {
if(!target.roles.cache.has(muterole.id)) return;
target.roles.remove(muterole);
return `${target.displayName} has been unmuted for ${time}`
}, require("ms")(time))
}
For example this my mute file
i use module.exports 2
i deleted them
i changed the const = addLevel ... to module.exports.getLevel
and removed module.exports.addXP = addXP
is that right?
module.exports = {
addXp: function addXp() {
//code
},
getNeedXp: function getXp() {
//code
},
getLevel: function getLevel() {
//code
}
}
u can use this @cinder sandal ^^^
u can save all function in a object
and u exports the object with functions
or u can do this
addXp.js
module.exports = function addXp() {
//code
}
getXp.js
module.exports = function getXp() {
//code
}
getLevel.js
module.exports = function getLevel() {
//code
}
Diffrent files
getLevel() is just a clone of getCoins() from economy.js
ok
Question: How can I make those timers that giveaway bots use, that update like every 12 seconds?
ms
hey! how can i see if a user is boosting?
link?
i can t find it
._.
how to get the user's level
levels.js
client.on('nitroBoost', (booster) => {
bot.channels.get('1234567890').send(`${booster} boosted the server!`)
booster.addRole(booster.guild.roles.find(a => a.name === 'Nitro Booster'))
})
const mongo = require('./mongo')
const profileSchema = require('./schemas/profile-schema')
const getNeededXP = (level) => level * level * 100
const addXP = async (guildId, userId, xpToAdd, message) => {
await mongo().then(async (mongoose) => {
try {
const resultXP = await profileSchema.findOneAndUpdate(
{
guildId,
userId,
},
{
guildId,
userId,
$inc: {
xp: xpToAdd,
},
},
{
upsert: true,
new: true,
}
)
let { xp, level } = resultXP
const needed = getNeededXP(level)
if(xp >= needed) {
++level
xp -= needed
message.reply(`:tada: | Congratulations! You are now Level ${level} with ${xp} Experience! You need more ${getNeededXP(level)} XP to level up again.`)
await profileSchema.updateOne(
{
guildId,
userId,
},
{
level,
xp,
}
)
}
} finally {
mongoose.connection.close()
}
})
}
module.exports.addXP = addXP```
._.
how do i get the Level of a user
wdym ?
u didn't defiened the level
where u get level
no where
no where, u can't just type level and u will get it
const xp = Math.floor(Math.random() * 50) + 1;
const coins = Math.floor(Math.random() * 5) + 1;
const guildId = message.guild.id
const userId = message.author.id
const newXP = await levels.addXP(guildId, userId, xp, message)
const newCoins = await economy.addCoins(guildId, userId, coins)
message.channel.send(`:evergreen_tree: | You chopped a **Tree** and got ${coins} Crystal(s) and ${xp} XP!`)```
in some of these commands u get xp
ok and ?
u have to getXp
for exmaple
every 200xp u level up
so that mean 400xp u are level 2
how can i use premiumSince?
@clear arrow https://discord.js.org/#/docs
i get undefined every time i try
idk
ew
@clear arrow 
You don't define it, it's a property of the Guild Member object
so is just premiumSince?
message.member.premiumSince```
message.member works
For example
message.guild.members.cache.get(ID) works
console.log(api.data.children.length)```
returns undefined 
aw....
yea @earnest phoenix
WHAT
yea its good it gets null
It's null if the guild member never boosted the guild
yes.
it returns a json embed too @earnest phoenix so you dont need to do anything
nice isnt it
yes
i want to make if user boosted the guild to show me the badge
It returns a MessageEmbed instance @earnest phoenix
So just get it and send it
That's it
how can i update my bot without restarting it?
btw are they geetting money from it ?
axios ?
wtf
i don't even know what is axios
console.log(api.data.children.length)``` returns undefined 
@carmine summit You sure about that
do they
Yes
axios is just node fetch
uh
Promise based HTTP client for the browser and node.js
wut?
what is the best process monitor for discord.js? (not pm2 please)
pm2
WHAT?
aaaaaaaaaaaaaaaaa
pm2 is the best
i know
0
whats the difference of axios and fetchnode??
but i dont want it
pm2
pm2?
then rip 24/7
: /
There with axios
why u install axios
._.
Systemd?
I already had it
can i change the null message?
@earnest phoenix it is for all os
why
at premiumSince?
For testing purposes
how does it work on you
why it works on you?
@carmine summit Just use one more data
but me not
@carmine summit Just use one more data
@earnest phoenix huh?
no its not
Doesn't look like it, idk
oh
api.data.data.children.length```
lemme see
i want to know the process manager that looks like thet
@earnest phoenix how can i change the null message to no?





