f(message.content.startsWith(prefix + 'test')){
const request = require("superagent");
let fish = await request.get("https://emilia-api.glitch.me/api/triggered") // query can be used at the end of url like `?image=URL`
.set("Authorization", "Bearer NjA2Mjc5MzI5ODQ0MDM1NTk0.oT34XsUAZwPvOAYugwaOzbzT05hgA0GxsIJ97Y71s") // authentication
.query({ image: message.author.displayAvatarURL}) // the image to be used in the meme (Also work with query parameter above).
.then((res) => res.body) // handle the Buffer somehow ¯\_(ツ)_/¯
message.channel.send(fish.body)
}```
#development
1 messages · Page 920 of 1
did you notice that i removed the .then((res) => res.body) part?
uuuh
the reason is that
.then((res) => res.body).then(res => console.log(res)) is exactly the same as .then((res) => console.log(res.body))
bearer code lol
https://hasteb.in/lejucida.js rank.js
https://hasteb.in/ikatojih.js bot .js
tim i followed example
still no work 😦
so if you use res => res.body and then use fish.body is the same as doing res.body.body which is undefined
if(message.content.startsWith(prefix + 'test')){
const request = require("superagent");
let fish = await request.get("https://emilia-api.glitch.me/api/triggered") // query can be used at the end of url like `?image=URL`
.set("Authorization", "Bearer NjA2Mjc5MzI5ODQ0MDM1NTk0.oT34XsUAZwPvOAYugwaOzbzT05hgA0GxsIJ97Y71s") // authentication
.query({ image: message.author.displayAvatarURL}) // the image to be used in the meme (Also work with query parameter above).
// handle the Buffer somehow ¯\_(ツ)_/¯
message.channel.send(fish.body)
}```
so that
yes
still says empty message
console.log(fish) then
js
https://hasteb.in/lejucida.js rank.js
https://hasteb.in/ikatojih.js bot .js
tim i followed example
still no work 😦
@queen needle
body is returning a buffer
does superagent have an option to set the response type?
i dont think so
@hardy vector
but
this is what the succes message should look like
HTTP/1.1 200 OK
<Buffer 47 49 46 38 39 61 f4 01 15 01 f7 ad 00 67 56 4a 49 41 3b fb f7 83 ff f7 b2 d8 c9 b5 74 64 4f ca ad 94 e8 d1 b7 ff f7 ac 88 6e 56 8d a7 37 b6 a0 8a ef ... >```
well you can try sending fish.body.toString()
if that is an image, then yes, you should send it as an attachment
how?
its supposed to be gif
wait are you still on v11?
yes
you know that v11 will stop working in a few months right?
yeah
i want to switch soon but i have to fix a lot
message.channel.send("", {
files: [
"image.gif"
]
});```
because in v12 you can chose the file type of the avatar URL, i dont remember what type it returns by default on v11
well i have to switch a lot
ENOENT: no such file or directory, stat '/app/image.gif'```
just updated to v12
thatll work ing v12?
yes
yes
if (message.content.startsWith(prefix + "prefix")) {
message.channel.send(
new Discord.MessageEmbed()
.setColor("#0099ff")
.setTitle("Prefix")
.setDescription(`prefix for this guild is ${prefix}`)
);
}```
that doesnt send the prefix
Pretty much everything that changed is listed at https://discordjs.guide/additional-info/changes-in-v12.html
what does it send then?
nothing
any error?
a lot because i just switched
fetchedChannel.delete().then(channel => {
message.channel.send(`${channel.name} channel was deleted`);
});```
cant read property of delete
thats for one of my commands
how are you fetching the channel
r => r.name === args.join(" ")
);```
oh
the fields.flat error is because you have an outdated node
v12 requires node.js v12 or later
sry I was thinking cache.fetch
@queen needle did you try logging fetchedChannel?
package.json > engines
i dont see that?
show your package.json
if yours doesnt have it, just add it yourself
goes after dependicies
yes
i still get the same thing
try restarting your project
you have package.json in your gitignore?
then it shouldnt matter lol
i just refreshed my project from the terminal
where
i might just have to use a new project
cause im using their start kit
and i just loaded up a new start kit and it has the correct verison
so my bot will be down for a while while i switch everything over
Hey I was working on a simple kick command for my discord.js bot and am running into some issues. I get this error when I attempt to use the command: https://pastebin.com/2S75CcyZ
I am currently using a command handler that works perfectly fine with any other command so I figure thats not the issue. My code for my kick.js is here (https://pastebin.com/9HLEph3Y)
@earnest phoenix your commands are not async
in your external command file do this :
module.exports = async (/*param*/) => {
//command
}```
alright
thats not the cause of the error tho?
the error is
(node:11244) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was
not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:11244) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
that doesnt matter
well if it works for the others cmds
if this works for the ther commands it should be fine
idk how he made his cmd handler
unhandled promise rejections always happen whenever you use promises without catching errors, making functions async wont fix that lol
unhandled promise rejections are a symptom of bad design, not the cause of the error
your error is in the file that calls commandfile.run()
tim did u see me mention u about the detritus multi machine support
i looked into it a bit more
i looked at it but didnt find what i was looking for
I haven't worked on discord.js for 6 months and I must have forgotten most updates
TypeError: RichEmbed is not a constructor
I get this error
It is most likely because its the new version
MessageEmbed
How can we add roles or remove roles from a user in v12?
member.roles.add / member.roles.remove
member.roles.add()
what were u after then
u can just specify the shard range u want each client to manage
yes, but thats what everyone else does, its not proper multi-machine support
member.roles.add(`Role ID`)
what i mean with proper multi-machine is having the sharding manager control shard connections and gateway rate limits to prevent multiple shards connecting at once
over network
which is what im aiming to do with my lib
i dont rlly mess with sharding systems
if (!sChannel) {
server
.createChannel("suggestions", { type: "text" })
.then(createdChannel => {
var id = createdChannel;
message.channel
.send(
"Your suggestion has been filled to the staff team. Thank you!"
)```
sever.createChannel is not a function
but anyways, if i knew about detritus 6 months ago, my life would have been a whole lot easier
now its too late
i already made discord.js-light and im already way too deep into the discord api to give up now
isnt it guild.channels.create?
Hi
is client.guild.name a valid function to get the guild name
guild is not defined
all changes are there
it's probably server for you
message.guild.channels.create()
then it would be member.guild.name
message.guild.cache.createChannel("suggestions", { type: "text" })```
member.guild then
cant read property of createChannel
how can i create a channel?
message - the message
.guild - the guild of the message above ^
.channels - all channels of the guild above ^
.create - create a channel in the channels above ^
https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=channels https://discord.js.org/#/docs/main/stable/class/GuildChannelManager?scrollTo=create
so message.create("suggestions", { type: "text" })
what
what the hell
nvm
[10/05/20 23:32:10.443] [ERROR] (node:11) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied options is not an object.
at Message.delete (/home/container/node_modules/discord.js/src/structures/Message.js:501:44)
at /home/container/commands/break.js:34:136
Line 34: ```js
await message.channel.send( ${message.author} **enjoy you break!**).then(msg => { msg.delete(10000)});
msg.timeout
No
{Option: value} is an object
thisIsAnObject = {i am an object}
thisIsAFunctionThatTakesAnObject({i am an object})
await message.channel.send(` ${message.author} **enjoy you break!**`).then(msg => { msg.delete({timeout:10000})});
So like this?
yes
what would be the easiest and most non breaking way to add a notification bubble to an <a> link like this
message.channels.create?
an :after pseudo-element
any actual guide on doing it though
its pure css
i know
a:after {
content:"unicodeCircleHere";
color: red;
position: absolute;
top: 0; // change these
right: 0; // change these
}```
try that
that makes a circle but it appears next to it
use top and right to control its position
in px?
ye
looks nice
Something of this code is wrong?
if(!user_cache.joined == 1 && !commandName == "join") return message.reply("No estas unido, unete con db!join")
I need it not to allow to execute commands if user_cache.joined is not equal to 1
But it does not work :c
I want to have it to where only people with certain permissions (such as kick/ban members, and admin) can use the kick and ban command on my discord.js bot
How to set permissions?
await c.permissionOverwrites[role, {
SEND_MESSAGES: false,
READ_MESSAGES: false
}];
I am confessed and no errors to use as help to correct ir
message.guild.channels.create(`training-${message.member.user.discriminator}`, "text").then(async c => {
let role = message.guild.roles.cache.find(r => r.name === "@|everyone");
message.guild.channels.create(`training-${message.member.user.discriminator}`, "text").then(async c => {
let role2 = message.guild.roles.cache.find(r => r.name === "Staff Trainer");
let role = message.guild.roles.cache.find(r => r.name === "@|everyone");
let catagory = message.guild.channels.cache.find(channel => channel.name === "▬ ⬇ Staff Training" && channel.type === "category")
await c.setParent(catagory.id);
await c.permissionOverwrites[role, {
SEND_MESSAGES: false,
READ_MESSAGES: false
}];
await c.permissionOverwrites[role2, {
SEND_MESSAGES: true,
READ_MESSAGES: true
}];
await c.permissionOverwrites[message.author, {
SEND_MESSAGES: true,
READ_MESSAGES: true
}]
Everything works but not the permissions
I don't think that's how you edit overwrites.
yeah looks quite spammy
module.exports.run = async (client, message, args) => {
if (message.content.startsWith("?kick")) {
// Easy way to get member object though mentions.
var member= message.mentions.members.first();
if (member.hasPermission('KICK_MEMBERS', 'ADMINISTRATOR')) {
member.kick().then((member) => {
// Successmessage
message.channel.send(":wave: " + member.displayName + " has been successfully kicked");
}).catch(() => {
// Failmessage
message.channel.send("Failed to kick Member");
});
}
}
}
The kick command works but when I added:
if (member.hasPermission('KICK_MEMBERS', 'ADMINISTRATOR')) {
it stopped working with no console logs or anything
So its like this?
@earnest phoenix the second argument is supposed to be an object for options.
In v12. In v11 it's a check for admin (boolean).
ok
Though did you mean to check the message sender instead of the person being kicked?
You have it set up as "If the mentioned member has permission to kick members, kick them."
Set what up exactly. Fix both logical errors?
Yea
The first one is in the docs on how to check for multiple permissions. You can pass an array of permission resolvable (https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=hasPermission).
The second one is simply a mistyping. Change it to the message author's guild member instance (aka message member)
Hey Fellas, I need some assistance here... Someone asked me for help on their bot, and they just started creating a bot, and they had this error in their index.js file, and I can't figure out what it wants.
Error:
^
TypeError: eventFunc.bind is not a function```
Are you sure eventFunc is a function.
It needs to be a function in order to use .bind
It needs to be a function no matter what because you're listening to an event.
let role2 = message.guild.roles.cache.find(r => r.name === "Staff Trainer");
let role = message.guild.roles.cache.find(r => r.name === "@everyone");
let catagory = message.guild.channels.cache.find(channel => channel.name === "▬ ⬇ Staff Training" && channel.type === "category")
await c.setParent(catagory.id);
await c.permissionOverwrites([
{
id: role.id,
deny: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGES'],
},
{
id: role2.id,
allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGES'],
},
{
id: message.author.id,
allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGES'],
},
]);
[11/05/20 00:16:14.157] [ERROR] (node:12) UnhandledPromiseRejectionWarning: TypeError: c.permissionOverwrites is not a function
How can I fix this ...
Hey I need some help with my JavaScript code. I am trying to it so that this command can only be used by people with certain permissions (2 permissions Kick Members and Admin) My code is listed here:
module.exports.run = async (client, message, args) => {
if (message.content.startsWith("?kick")) {
// Easy way to get member object though mentions.
var member= message.mentions.members.first();
member.kick().then((member) => {
// Successmessage
message.channel.send(":wave: " + member.displayName + " has been successfully kicked");
}).catch(() => {
// Failmessage
message.channel.send("Failed to kick Member");
});
}
}
I tried a few things and none seem to work, maybe I'm too dumb 😅
Did you try what I explained?
You can pass an array of permission resolvable. (https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=hasPermission).
In reference to .hasPermission()
I tried most likely messed something up because it wouldn't work
Can you show what you tried?
yeah one second lemme get it
[11/05/20 00:27:58.001] [ERROR] (node:12) UnhandledPromiseRejectionWarning: RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number.
``` - What does this mean?
let role2 = message.guild.roles.cache.find(r => r.name === "Staff Trainer");
let role = message.guild.roles.cache.find(r => r.name === "@everyone");
message.guild.channels.create(`training-${message.member.user.discriminator}`, {
type: 'text',
permissionOverwrites: [
{
id: role.id,
deny: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGES'],
},
{
id: role2.id,
allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGES'],
},
{
id: message.author.id,
allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'READ_MESSAGES'],
},
],
})
I get the error here
module.exports.run = async (client, message, args) => {
if (message.content.startsWith("?kick")) {
// Easy way to get member object though mentions.
if (message.member.hasPermission(permission ['KICK MEMBERS', 'ADMINISTRATOR']))
var member= message.mentions.members.first();
member.kick().then((member) => {
// Successmessage
message.channel.send(":wave: " + member.displayName + " has been successfully kicked");
}).catch(() => {
// Failmessage
message.channel.send("Failed to kick Member");
});
}
}
Im not sure why you have that permission in the hasPermission method
just remove that
completely or replace it?
@heavy marsh it means one of the values you passed as permission resolvable were invalid.
completely
Not quite
ok
hasPermission is a function
you need the parentheses to pass parameters to the function
like hasPermission(['KICK MEMBERS', 'ADMINISTRATOR'])
ok
gave me this
(node:17876) UnhandledPromiseRejectionWarning: RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number.
at Function.resolve (C:\Users\tydbe\Desktop\barney\node_modules\discord.js\src\util\BitField.js:150:11)
at Permissions.has (C:\Users\tydbe\Desktop\barney\node_modules\discord.js\src\util\BitField.js:45:28)
at Permissions.has (C:\Users\tydbe\Desktop\barney\node_modules\discord.js\src\util\Permissions.js:45:85)
at C:\Users\tydbe\Desktop\barney\node_modules\discord.js\src\util\BitField.js:44:56
at Array.every (<anonymous>)
at Permissions.has (C:\Users\tydbe\Desktop\barney\node_modules\discord.js\src\util\BitField.js:44:40)
at Permissions.has (C:\Users\tydbe\Desktop\barney\node_modules\discord.js\src\util\Permissions.js:45:85)
at C:\Users\tydbe\Desktop\barney\node_modules\discord.js\src\structures\GuildMember.js:268:53
at Map.some (C:\Users\tydbe\Desktop\barney\node_modules\@discordjs\collection\dist\index.js:234:17)
at GuildMember.hasPermission (C:\Users\tydbe\Desktop\barney\node_modules\discord.js\src\structures\GuildMember.js:268:29)
(node:17876) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was
not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:17876) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Hey, I need some help making my bot send a message
with
indents
instead of a bunch of separate messages
switch(args[0]){
//help command
case 'help' :
message.channel.send('Here is a list of my commands! :smile:')
message.channel.send('__Utility__:')
message.channel.send('"**a.help**" - Pulls up a list of my commands.')
message.channel.send('__Text Commands__:')
message.channel.send('"**a.hello**" - Greet me!')
message.channel.send('"**a.iloveyou**" - Send me some love! :wink:')
break;```
\n
As in \n
what is a line break
i would use a embed if you want to make it look nice
it makes it look a lot better in my opinion
Yes, I agree, embeds are nice, but idk how to make them yet.
A line break simply adds another line. \n is for a new line. So if you had Hi\nThere, it would come out as: Hi
there
const helpEmbed = new Discord.MessageEmbed()
.setColor('#0099ff')
.setTitle('Commands')
.setDescription('All of the current commands for Barney')
.addFields(
{ name: '?ping', value: 'Test Command'},
)
.addFields(
{name : '?kick', value: 'Instantly kicks any member in the server if Barney has the proper permissions [?kick @MEMBER]' }
)
.addFields(
{name : '?ban', value: 'Instantly bans any member in the server if Barney has the proper permissions [?ban @MEMBER]' }
)
.setFooter('Report any bugs found to: elon#6471')
.setTimestamp()
OH
Your message can still look nice in plain text. Depends on how you structure it.
thank you very much!
if you're using addFields, why not put them all in one function call?
@queen needle show full error
Error: Precondition Failed
at Request.callback (/rbd/pnpm-volume/551377b7-98a7-4c4a-a154-b94830d79867/node_modules/.registry.npmjs.org/superagent/5.2.2/node_modules/superagent/lib/node/index.js:871:15)
at IncomingMessage.<anonymous> (/rbd/pnpm-volume/551377b7-98a7-4c4a-a154-b94830d79867/node_modules/.registry.npmjs.org/superagent/5.2.2/node_modules/superagent/lib/node/index.js:1114:20)
at IncomingMessage.emit (events.js:201:15)
at endReadableNT (_stream_readable.js:1130:12)
at processTicksAndRejections (internal/process/task_queues.js:83:17)
(node:7561) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7561) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
why does no one read the error all the time
is it written in alien language for you or what
if (message.member.hasPermission(['KICK_MEMBERS', 'ADMINISTRATOR']));
Doesn't work and still goes ahead with the command even though the user doesn't have the perms
@earnest phoenix if your code still looks like your previous post, then you need to add a block
if(bla) {
code here
}```
How do you make an embed?
thank you!
welc
could i understand it as a beginner?
yeah super simple
okay sweet
let user = await member.client.guilds.cache.get(`611881570202025986`).fetchMember(member.id)
Should It Be Like:
let user = await member.client.guilds.cache.get(`611881570202025986`).fetchMember({user: member.id})
no
[11/05/20 00:49:34.803] [ERROR] (node:11) UnhandledPromiseRejectionWarning: TypeError: member.client.guilds.cache.get(...).fetchMember is not a function
at Request.callback (/rbd/pnpm-volume/551377b7-98a7-4c4a-a154-b94830d79867/node_modules/.registry.npmjs.org/superagent/5.2.2/node_modules/superagent/lib/node/index.js:871:15)
at IncomingMessage.<anonymous> (/rbd/pnpm-volume/551377b7-98a7-4c4a-a154-b94830d79867/node_modules/.registry.npmjs.org/superagent/5.2.2/node_modules/superagent/lib/node/index.js:1114:20)
at IncomingMessage.emit (events.js:201:15)
at endReadableNT (_stream_readable.js:1130:12)
at processTicksAndRejections (internal/process/task_queues.js:83:17)
(node:8138) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8138) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
@heavy marsh you should check the docs more often
https://discord.js.org/#/docs/main/v12/typedef/FetchMemberOptions - I was checking this
lmao
member definitely does not have a client property
i have no idea how you're even getting these
im trying to get help from my friend that has the same command
👀
member does have a client property lol
anyway director
member.guild.members.fetch()
unable to process the contained instructions?
cache is only for collection methods (get,find,filter,reduce,map,array,etc...)
NVM I am dum
bot.on("channelCreate", async(channel) => {
if(channel.guild.id !== `611881570202025986`) return
``` - is this in a wrong way?
@queen needle in v12 avatarURL returns .webp by default
probably that api doesnt support webp
so you need to avatarURL({format:"png"})
or something, check the docs
i don't get why they made it return webp by default
uh this may sound like a noob question, but how do i add buttons into my top.gg site?
i tried using the onclick event but it doesn't seem to work when i publish it
it worked in the preview
webp is generally more efficient, but due to lack of widespread support, it is indeed a questionable decision
my bot used to use webp by default and i changed it to png because it didnt work for some mobile users lol
@hot tusk javascript is not supported in the long description, only html and css is
(unless you're a certified developer)
ah i see, oof
you can use buttons with css
there are some tricks that enable you to make stuff like css-only tabbed menus
oh cool, i'll look into that
Hey, my embed won't work, any ideas?
const helpEmbed = new Discord.MessageEmbed()
.setTitle('My Commands:')
.setDescription('__Utility__:\n"**a.help**" - Pulls up a list of my commands.\n\n__Text Commands__:\n"**a.hello**" - Greet me!\n"**a.iloveyou**" - Send me some love!')
if (message.author.bot) {
helpEmbed.setColor('#aaaaaa');
}
switch(args[0]){
//send help embed
case 'help' :
channel.send(helpEmbed);```
Please @ me
@reef heath it could not work for several reasons:
args[0]is not the command name.- You could be on v11 and
MessageEmbednot being a thing. - It could be out of scope.
channel.sendmay not work or not have permission.
What have you tried that makes it not work?
what would i replace args[0] with?
well what is args defined as
uh
i'm sorry i'm a beginner
i don't think it is defined
OH
let args = message.content.substring(PREFIX.length).split(" ");```
If you dont know what args is defined as, then I would recommend coming back to developing a bot when you've learnt basic js
that^^
yes, I would still recommend that you learn basic javascript before jumping straight into bot development
how long would that take?
Depends on how fast you learn, I don't know you so I couldnt say
here is a list of good websites to learn from
JavaScript Stuff
JavaScript books, videos, and interactive courses that get recommended the most by other JavaScript beginners.
well, okay
i just didn't want to have to do it that way but i guess this was all premature
You should never jump straight into something without having a base line, coding included
learn the language you plan to code in, then make the bot
okay, will do.
my level system with my rank card is oing this lemme send code
i'll come back and WOW you all
Does anyone know what to do with
SyntaxError: Cannot use import statement outside a module
sqlite
you can use message.client.db instead
@earnest phoenix ?
is there any ideas i can implement into my discord bot
?
its based off moderation
me?
i have basic kick and ban commands that work
i have info commands
i have upadtelog and stuff
but i can never think of ideas
they're common as well
with the mute commands
would it be the best approach just to save there current role, take it away and give them the mute role?
casue if it is going to be like that
i havent been able to get roles added to members with the bot
you can just give the mute role
k
i dont think its necessary to remove their current roles
k
i havent been able to get roles working with the bot
and none of the resources have helped me of what to try
eiter there old
or it just doesnt work
well then you can debug or ask for help
mkay
is this considered api spam?
Why would you lose a command?
I know this is a bot server, but any idea how I would extend this? https://prnt.sc/segmyz
128mb one?
uhhh right click?
when I right click "extend volume" is greyed out
trial
if(message.content.startsWith(prefix + 'blackjack')){
var a = 11;
var card = [2, 3, 4, 5, 6, 7, 8, 9, 10, a];
var c1 = card[Math.floor(Math.random()*card.length)];
var c2 = card[Math.floor(Math.random()*card.length)];
var cardtotal = c1 + c2;
message.channel.send('Your cards are a ' + c1 + ' and a ' + c2 + ', with a total of ' + cardtotal + '. Do you want to hit (:thumbsup:) or stand (:thumbsdown:)?').then(sentMessage => {
sentMessage.react('👍');
sentMessage.react('👎');
});
const filter = (reaction, user) => {
return ['👍', '👎'].includes(reaction.emoji.name) && user.id === message.author.id;
};
message.awaitReactions(filter, { max: 1, time: 10000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '👍') {
message.reply('You decided to hit');
} else if (reaction.emoji.name === '👎') {
message.reply('You decided to stand');
}
})
.catch(collected => {
message.reply('You didn\'t do anything, so now the game\'s over.');
});
}```
if i hit thumbs up or thumbs down it does nothing
empty inline fields
Why make it so hard discord
or not
If I don’t then the words are to crunched together for iOS
But if I do then the words are spread apart really far on pc
if(message.content.startsWith(prefix + 'blackjack')){
let a = 11;
let card = [2, 3, 4, 5, 6, 7, 8, 9, 10, a];
let c1 = card[Math.floor(Math.random()*card.length)];
let c2 = card[Math.floor(Math.random()*card.length)];
let cardtotal = c1 + c2;
message.channel.send('Your cards are a ' + c1 + ' and a ' + c2 + ', with a total of ' + cardtotal + '. Do you want to hit (:thumbsup:) or stand (:thumbsdown:)?').then(sentMessage => {
sentMessage.react('👍');
sentMessage.react('👎');
});
db.set(`cardtotal_${message.author.id}, cardtotal`);
const filter = (reaction, user) => {
return ['👍', '👎'].includes(reaction.emoji.name) && user.id === message.author.id;
};
message.awaitReactions(filter, { max: 1, time: 10000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '👍') {
let fish = db.add(`cardtotal_${message.author.id}`, c1);
message.reply('You decided to hit');
} else if (reaction.emoji.name === '👎') {
message.reply('You stayed with a score of ' + cardtotal);
}
})
.catch(collected => {
message.reply('You didn\'t do anything, so now the game\'s over.');
});
}```
how can i send a message on reaction
channel.send()?
How do I add my bot?
you added your bot
@pale vessel when i hit thumbs up nothing happens
you added your bot
@pale vessel I have a new one. I’m done with the first one
add a new one then
Thanks
@queen needle shouldn't you be collecting the reactions of sentMessage ?, i doubt message.awaitReactions() would collect any reactions
if i change message.awaitReactions() to sentMessage.awaitReactions()
it doesnt work
because it needs to be inside .then of sentMessage
all of the await?
I would recommend you await the sending of the message you want to interact with, so you can later interact with the message again without fetching it again
that didnt make a lot of sense
but yeah
that
https://hasteb.in/nomemicu.js rank.js
https://hasteb.in/epofitef.js index.js
node:2467) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined
at Object.execute (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/commands/rank.js:10:38)
at Client.<anonymous> (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/bot.js:37:31)
at Client.emit (events.js:323:22)
at MessageCreateAction.handle (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
at WebSocketShard.onPacket (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
at WebSocketShard.onMessage (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
at WebSocket.onMessage (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:311:20)
(node:2467) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2467) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
my bot connects to the channel but plays nothing
no errors
the green light is around it but nothing comes out
mAybe read the title of the repo
would be my guess
wait im dumb
sorry nvm
:/
it's all good
why is my bot muted
all of the await?
@queen needle Inside your then function of sentMessage like flazepe said
//eg:
message.channel.send(...).then(async sentMessage => {
await sentMessage.react(..)
await sentMesasge.react(..);
sentMessage.awaitReactions(..., ...);
});
// another way
const sentMessage = await message.channel.send(..);
await sentMessage.react(..);
sentMessage.awaitReactions(...)
@hardy vector client.db is undefined, is the db property on client valid ?
Lemme just correct the example before:
// Sync method:
<channel>.send("Bonk").then(sentMsg => {
sentMsg.react(emoji)
sentMsg.react(emoji)
// ...
sentMsg.awaitReactions(...)
})
// Async method:
(async function() { // This is optional if you already have an async function
var sentMsg = await <channel>.send("REEE")
await sentMsg.react(emoji)
await sentMsg.react(emoji)
sentMsg.awaitReactions(...)
}()) // This is optional if you already have an async function
Ima say it out loud, discords syntax highlighting is crap
let sentMsg = <channel>.send("REEE") returns a promise, you didn't resolve it
also not necessary to use let/var, when you're not changing the variable's value
i forgot the await 🤦♂️
I'm trying to add muting into my bot
right not im trying to add a role which will not be able to connect to voice channels or speak in any text channel
when i do messge.member.addRole(mutedRole)
and i run my bot
i would get this error
TypeError: message.member.addRole is not a function
There's also a whole other bunch of stuff
at Client.emit (events.js:189:13)
at MessageCreateAction.handle (/home/pi/Desktop/Bot/Discord/AdminBot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/pi/Desktop/Bot/Discord/AdminBot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/pi/Desktop/Bot/Discord/AdminBot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
at WebSocketShard.onPacket (/home/pi/Desktop/Bot/Discord/AdminBot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:435:22)
at WebSocketShard.onMessage (/home/pi/Desktop/Bot/Discord/AdminBot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
at WebSocket.onMessage (/home/pi/Desktop/Bot/Discord/AdminBot/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:189:13)
at Receiver.receiverOnMessage (/home/pi/Desktop/Bot/Discord/AdminBot/node_modules/ws/lib/websocket.js:801:20)```
(im running it on a raspberry pi)
i have followed lots of articles, none have helped
are you on v12 djs ?
im not sure
i am currently reading about setting roles on the documentation
12.1.1
im trying roles.set now
okay, so since you're on v12 of djs. It is now <guildmember>.roles.add() instead of addRole()
mkay
https://discordjs.guide/additional-info/changes-in-v12.html for more informations on what funciton / method is changed
guildMember is the Member object of a member. message.member returns the guildMember object of the author
k
dont get twisted with member and user, they're different
^
TypeError: Cannot read property 'roles' of null
at Client.bot.on.message (/home/pi/Desktop/Bot/Discord/AdminBot/script.js:87:16)
at Client.emit (events.js:189:13)
at MessageCreateAction.handle (/home/pi/Desktop/Bot/Discord/AdminBot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/pi/Desktop/Bot/Discord/AdminBot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/pi/Desktop/Bot/Discord/AdminBot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
at WebSocketShard.onPacket (/home/pi/Desktop/Bot/Discord/AdminBot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:435:22)
at WebSocketShard.onMessage (/home/pi/Desktop/Bot/Discord/AdminBot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
at WebSocket.onMessage (/home/pi/Desktop/Bot/Discord/AdminBot/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:189:13)
at Receiver.receiverOnMessage (/home/pi/Desktop/Bot/Discord/AdminBot/node_modules/ws/lib/websocket.js:801:20)```
oh wait
IT WORKS
FINALLY
now i have to remember how to @ someone with bot
:|
Py?
js
nah
Ez
i use node on a daily basis
not just for disc either
but i dont know disc js
and i dont want to learn another language
mainly cause i couldnt give a fuck
i would of just learnt all of this disc js stuff for nothing
Use py I can give u code
but i literally would of just learnt all of this shit for nothin
I understood
everyone have different likings, you can't really just force someone into using another language
?
Smort
Yes
sMOrT
i havent seen tat one lol
only the stonks one
wtf did that one come from
anyway
back to dev
nah dude
args
i would of learnt disc js for nothin
how do i @ someone with discord lol
i fucking forgot
ARGS
so if i @ someone in my message
won't work
it will direct to that person
yeah but not @Name
i want it to be so when i @ someone the bot will know which one it is
how would i do it in a message.member.roles.add statement
can someone tell me
what are you trying to do actually
ok
just put the role object/id
but i want to have it like
!mute @earnest phoenixthatiwantedtomute
yeah
msg.mentions.members.first()
ping
this will give you the mentioned user's member object
msg.mentions.members.first()
@wheat jolt .
do i make a variable
msg.mentions.members.first().roles.add
that's simpler but who knows, there might be no member mentioned
so you can do if (!member) ...
yeah
so your saying message.mentions.member.first().roles.add(mutedRole) will work
yes
k
but as flazepe said, you might want to check before if it's not null
or undefined
so you can do
if (!member) ...
k
if(!member){message.reply("There needs to be a second argument to run this command")}
would work?
yes
k
but member has to be message.mentions.members.first()
how can i make it so my bot reacts with a thumbs up and thumbs down but those are the only allowed reactions
what lib
if (message.content.startsWith(prefix + "poll")) {
if (message.author.bot) return;
let question = args.join(" ");
if (!question)
return message.reply("please include a question for the poll");
message.channel
.send(
new Discord.MessageEmbed()
.setTitle(`${message.author.username}'s poll`)
.setColor("#FF0000")
.setDescription("Poll")
.addField("question", question)
)
.then(async msg => {
await msg.react("👍"), msg.react("👎");
});
}```
how can i make it so those are the only allowed reactions
and discord.js
why?
does that even work?
yes
I doubt it awaits the second promise
ok
how can i make it so those are the only allowed reactions
@queen needle wdym
just do it with discord's permissions?
the add reactions permission?
but for every server
oh
if they're not thumbs up or thumbs down
Why does eris disconnects shards every 3 hours?
wait
I found this too
oh
but clusters doesnt seems to be affected, coz my last log is from 1am tis morning
hmmmmm
Why my bot isn't sending any message when someone joined the server?
code ```js
bot.on("guildMemberAdd", (member) => {
const db = require("quick.db")
let chx = db.get(welchannel_${member.guild.id});
if(!chx) {
const chxembed = new Discord.RichEmbed()
.setDescription(":no_entry_sign: Canalul nu a putut fi gasit sau nu mai exista!");
message.channel.send(chxembed);
return;
}
const defaultmsg = new Discord.RichEmbed()
.setAuthor(${message.member.username}, message.member.displayAvatarURL)
.setTitle("Un nou membru tocmai a intrat!")
.setDescription(:wave: -> ${message.member.username} s-a alaturat serverului **_${message.guild.name}_**!\n:wave: -> Nu uita sa citesti regulamentul!\n:wave: -> Speram ca te vei distra alaturi de noi!)
.setFooter(${message.guild.name}, message.guild.displayAvatarURL);
message.chx.send(defaultmsg);
})
puteam sa jur
fmm
^
chx is a channel or just a channel id?
hey
how to send file.txt as a attachment via webhook?
is that possible?
let chx = db.get(`welchannel_${member.guild.id}`);
it doesn't work like that
is like the channelid from a guild
let chx = db.get(`welchannel_${member.guild.id}`);
let channel = member.guild.channels.get(chx);
then channel.send
__
bot.channels[.cache].get(chx).send(defaultmsg)
helo
bot.channels.get(chx).send(defaultmsg)
i had that earlier and the same thing

@earnest phoenix quick answer to your question: can you?
i can't. thats why i came here to ask
you can send a file with a webhook?
Probably
hi
you can send a file with a webhook?
@cinder patio ah yes
then why did you say it's not possible
does anyone knows discord py
because I didn't knew until now
Hello everyone, if you think of the bot missing that I made, please send a message from dm? @marble estuary
@viscid wave the person 4 messages above yours knows python. if only you didn't waste time by asking to ask :(
how to get user flags on eris
get master
docs search bar is stoopid
or use discord api
just use discord api
f
i have flags lol
because its easier to represent several flags in 1 unit of data
Im trying to do it in eris

if (message.content.startsWith(prefix + "ping")) {
if (message.author.bot) return;
message = await message.channel.send("Pinging...");
setTimeout(() => {
// Edit message 1 second later
message.edit(
new Date().getTime() - message.createdTimestamp - 1000 + " ms"
);
}, 1000);
}``` how can i make it so if they do ^ping it works but ^pingg it doesnt work
I am gonna try modify the Eris library
might as well make your own
not hard
@pale vessel hard for me smh
well sorry
might as well make your own
@pale vessel uhhhh no thanks
lol
Eris should have a reconnect event
it does?
yes
it does
Yeah but it triggers the ready event
well fuck flags
it should
Aren't flags against ToS?
no
no
how
I mean nitro ones
nitro flags arent public
You have to ask for oauth for thise
yes
Mhm
what are nitro flags
badges
ohk
create your own lib
exactly, i am doing it rn. (public lib yes if u ask)
class VoiceChannelJoin {
constructor(client) {
this.client = client;
}
run() {
this.client.on('voiceChannelJoin', async (member, channel) => {
try {
if (!this.client.db.data.get(`${member.guild.id}.logs.voice.voiceChannelJoin`)) return;
const channellog = this.client.db.chanLogs.get(`${member.guild.id}.channel.channelLogs`);
if (!channellog) return;
const embed = new MessageEmbed()
.setTitle("🔊 Un utilisateur vient de rejoindre un salon vocal :")
.addField("👤 Utilisateur :", member.tag)
.addField("🆔 Identifiant de l'utilisateur :", member.id)
.addField("🔊 Nom & ID du salon vocal :", `${channelEvent.name} - ${channelEvent.id}`)
.setColor("#800080");
(await this.client.channels.fetch(channellog)).send(embed);
} catch(e) {
console.log(e)
}
})
}
}
module.exports = VoiceChannelJoin;```
When i join a voice channel, the bot don’t send embed to a channel and i have no one error in the console. how can i do plz?
And the channellog exist^^
why using this
im getting NaN when using this function (in my lib): js get latency() { let latencies = 0; for (let s of this.connectedShards) { latencies += s.latency; } return (latencies / this.connectedShards.size); } s.latency is a number, connectedShards (and they do have latency property) is BetterMap (extended from Map, just added some functions)
my bot now has ??? for it's activity
@restive furnace if you're getting NaN then one of those is not a number, console.log them both
okay, i think got it working
uh
no?
they're the same like in any other language
it took me less than 30 seconds to find this
what do you mean????????
lol
imagine being toxic because you don't know how to do bitwise operations
:omegalul:

you don't even have to do bitwise operations
d.js makes it easy for you and has methods to check lol
lmao your nitro ran out cry i just realized
https://i.callumdev.pw/97lmn.png
https://i.callumdev.pw/gvfju.png
when you cannot figure out why there is this one stupid ","
your cur variable has it
thats just the quality of the ss i think haha
oh yeah
you can simply join them
ye thats wat av done now
my brain was processing for like a minute
https://i.callumdev.pw/qnnaw.png much better 🙂
db.set(`welchannel_${message.guild.id}`, `${message.guild.channel.id}`)
error :
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
there is no guild.channel
He clearly wants message.channel
it's like when i use /setchannel #channel to write in the database both guild id and channel id
then you want the id of the mentioned channel?
yes
use the mentions property of the message
is ok if i did this?
let channel = message.mentions.channels.first()
then
db.set(`welchannel_${message.guild.id}`, `${channel.id}`)
for example
message.mentions // all mentions in the message
message.mentions.users // list of users mentioned
message.mentions.members // list of menmbers mentioned
message.mentions.channels // list of channels mentioned
message.mentions.roles // list of roles mentioned
Assuming a channel was mentioned, then yeah Sabin.
yes, what you did is correct
ok
but now when i'm in index.js i need to get the channel id and guild id from data base, i need to define channel again ?
because channel.id is not longer available
you saved the channel id under the guild id key
now you get it from the database using the key you saved it with
welchannel_${message.guild.id}
let chx = db.get(`welchannel_${member.guild.id}`);
yes
but this doesn't get only the guild id ?
you dont get the guild id, its not saved anywhere
the guild id is they key to access the saved data
.set(key,value)
value gets stored in the database
key is just the key used to retrieve it later
oh, and member.guild.id is ok or i need message.guild.id ?
depends on the context
wdym ?
if its a message/command, you probably want message unless you're defining member
if its on a guildMemberAdd, there is no message there
so it's correct member.guild.id
yes
show code
from index.js or setchannel.js ?
index
bot.on("guildMemberAdd", (member) => {
const db = require("quick.db")
let chx = db.get(`welchannel_${member.guild.id}`);
let wlcchannel = member.guild.channels.get(chx);
if(chx === null) {
return;
}
const defaultmsg = new Discord.RichEmbed()
.setAuthor(`${message.member.username}`, message.member.displayAvatarURL)
.setTitle("**_Un nou membru tocmai a intrat!_**")
.setDescription(`:wave: -> ${message.member.username} s-a alaturat serverului **_${message.guild.name}_**!\n:wave: -> Nu uita sa citesti regulamentul!\n:wave: -> Speram ca te vei distra alaturi de noi!`)
.addField("User ID", `${message.member.id}`, "User Name", `${message.member.username}`)
.setFooter(`${message.guild.name}`, message.guild.iconURL());
wlcchannel.send(defaultmsg);
})
are you on v11 or v12?
v11
show your setchannel
const Discord = require('discord.js')
const db = require("quick.db")
module.exports.run = async (bot, message, args) => {
let permission = message.member.hasPermission("MANAGE_SERVER");
const permissionembed = new Discord.RichEmbed()
.setDescription(":no_entry_sign: **Nu ai permisiunea necesara!**");
if(!permission) return message.channel.send(permissionembed)
let channel = message.mentions.channels.first()
const specifychannel = new Discord.RichEmbed()
.setDescription(":no_entry_sign: **Specifica un canal!**\n`lt!setchannel #channel`")
if(!channel) {
message.channel.send(specifychannel)
return;
}
db.set(`welchannel_${message.guild.id}`, `${channel.id}`)
const set = new Discord.RichEmbed()
.setDescription(`:white_check_mark: **Canalul a fost setat la ${channel}!**`);
message.channel.send(set);
}
module.exports.help = {
name: "setchannel"
}
@hardy vector
client.dbis undefined, is thedbproperty on client valid ?
@stable halo yes look at index.js
looks correct, try console.log(db.all()) somewhere in your code
and see what it logs
Can you post to dbl the full server amount by only by posting the shards own amount?
do console.log(chx,wlcchannel) here
@lethal shuttle yes, if you post each server count separately from a specific shard id, top.gg will join them together
node:2467) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined
at Object.execute (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/commands/rank.js:10:38)
at Client.<anonymous> (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/bot.js:37:31)
at Client.emit (events.js:323:22)
at MessageCreateAction.handle (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
at WebSocketShard.onPacket (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
at WebSocketShard.onMessage (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
at WebSocket.onMessage (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:311:20)
(node:2467) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2467) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@quartz kindle i got nothing
https://hasteb.in/nomemicu.js rank.js
https://hasteb.in/epofitef.js index.js
rank.js:10
stop creating new clients in your command files
i already told you this 3 times lol
you added your db to the main client, and thats good, but creating a new client doesn not give you the main client that has the db, it just creates new empty disconnected client
you have to get your client through the execute function, or you can just get it from any Discord class such as message.client
@earnest phoenix did you test joining the server to see what comes up?
yes
but i thought because we do client.db.get = db in index.we have to do client.db
yes but if you do new Discord.Client() in index, and you do the same in rank, then you have 2 different clients
client.db from index will not exist in rank client
you have to get the client from index, not create a new one
all discord.js classes have a .client property to make it easy
so you can do message.client to get the client that processed the message
ok so i can remove new discord.client in rank and keep client.db stuff
this is the correct client, the one you login with in your index, and the one that has .db
you have to use the client from the message
so message.client.db.
oh
So @quartz kindle do you have any idea?
are you sure it doesnt show anything? did you put the console.log before the null check?
it should show at least undefined
i put the console.log where u told me
now this happens all i did was remove new DIscord.client from rank and put message.client.db
where the guildMemberAdd is
where ?
@earnest phoenix why is your guildMemberAdd inside a message event?
This isn't really bot related, but what is the best way of keeping track of websocket connections? I am making a multiplayer game and I want to keep track of when websockets disconnect / reconnect, I have that system in place but it does not allow for "alt accounts" (the current system keeps track of reconnection / identity via a cookie that gets set during the protocol upgrade response), if I join the game in another tab on the same window, the cookie of both the new websocket as well as any other "alt" websockets gets changed (afaik because they are on the same window, for example opening two chrome windows will fix the issue but that's too much hassle)
@hardy vector in your index you do .set("level-..."), but in your rank you do .get("levelnew-...")
@cinder patio you want to allow multiple connections from the same browser?
@earnest phoenix think about it, how could there be a message when a member joins? where would this message come from? what would the message be?
yeah, while keeping track of them individually and detect when they disconnect and then reconnect
I don't know any other way of knowing that X websocket just refreshed the page without using cookies
but then things get mixed up because there will be 2 websockets with the same "id" if 2 connections get made from the same browser
give them a csrf token or something
How can i delete all db datas?
with one code, is it possible?
hi can somebody help me i dont know how to use lavalink
any1?
help
@quartz kindle and where should i put the guildmemberadd?
@jovial nexus show code
@cinder patio try saving them in sessionStorage instead of cookies
const cmd = client.comandos.get(comando1) || client.comandos.find((c) => c.alias.includes(comando1))
sessionStorage is unique per tab afaik, and survives page refreshes, but doesnt survive tab closing / browser exiting
@earnest phoenix what database?
oh hey that's not a bad idea
Good morning all,
"Casts a spell on themselves"
"Casts a spell on theirself"

@earnest phoenix all events should be top level, they should never be one inside the other, they are completely independent and designed to work on their own
@quartz kindle quick.db
delete the database file? lol
No not its
@jovial nexus c.alias is undefined
one of your commands does not have an alias property
thanks
(node:2968) UnhandledPromiseRejectionWarning: TypeError: member.user.displayAvatarUrl is not a function
at Object.execute (/Users/sadashivappakenchannavar/Desktop/Frosty Revamp/commands/rank.js:54:52)
(node:2968) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2968) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
tim i get this now
ik that member.user.displayAvatarUrl isnt a function
const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.member;````
@quartz kindle i put it on the top, how should i define message ?
URL @hardy vector not "Url"
@earnest phoenix again... think about it, how could there be a message when a member joins? where would this message come from? what would the message be?
it doesnt make sense to have a message defined in a guildMemberAdd event
whatever you're trying to do, using a message is the wrong way to do it
if i don't defined it how sould message.guild.id work ?
message is not the only source of guild
you can get a guild from many other things
eg ?
member.guild (the guild this member belongs to)
channel.guild (the guild this channel belongs to)
everything that is part of a guild has a .guild property to reference the guild it belongs to
everything in discord.js is linked together like that
and message.member.id? is only member.id ?
yes, guildMemberAdd gives you a member
message doesnt exist, but member does
everything inside a guildMemberAdd event is done using member as the context and the starting point
Ok, tysm
because thats what the event gives you
ok, i solved this, but the bot still doesn't send any message
why ? no error, no logs
cant know without seeing current code
Thanks Tim works just fine with sessionStorage
👍
wait, i've got some errors, i solve them and then give you the code
How could I make it so when a user joins my server my bot gives them a role
what are the terms to guild.iconURL ? member.guild.iconURL doesn't work
I don't see an iconURL in guild object
hes using v11
ok
only iconURL ?
Is there any advantage to being on 11 other than code continuity?
@maiden mauve i think it's easier 😛
the other way around, being on v12 has the advantage that your bot will not stop working on october 2020


