#development

1 messages · Page 920 of 1

queen needle
#
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)
  }```
#

still says i cant send a empty message

quartz kindle
#

did you notice that i removed the .then((res) => res.body) part?

turbid bough
#

uuuh

quartz kindle
#

the reason is that
.then((res) => res.body).then(res => console.log(res)) is exactly the same as .then((res) => console.log(res.body))

turbid bough
#

bearer code lol

hardy vector
#

tim i followed example

#

still no work 😦

quartz kindle
#

so if you use res => res.body and then use fish.body is the same as doing res.body.body which is undefined

queen needle
#
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

quartz kindle
#

yes

queen needle
#

still says empty message

quartz kindle
#

console.log(fish) then

queen needle
hardy vector
quartz kindle
hardy vector
#

k i changed and now this

quartz kindle
#

body is returning a buffer

#

does superagent have an option to set the response type?

queen needle
#

i dont think so

quartz kindle
queen needle
#

but

quartz kindle
queen needle
#

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 ... >```
pale vessel
#

send the buffer directly?

#

(make an attachment)

quartz kindle
#

well you can try sending fish.body.toString()

#

if that is an image, then yes, you should send it as an attachment

queen needle
#

how?

quartz kindle
#

.send({files:[{attachment:fish.body,name:"image.png"}]})

#

assuming its a png file

queen needle
#

its supposed to be gif

quartz kindle
#

wait are you still on v11?

queen needle
#

yes

quartz kindle
#

you know that v11 will stop working in a few months right?

queen needle
#

yeah

#

i want to switch soon but i have to fix a lot

#
 message.channel.send("", {
      files: [
       "image.gif"
      ]
    });```
quartz kindle
#

because in v12 you can chose the file type of the avatar URL, i dont remember what type it returns by default on v11

queen needle
#

well i have to switch a lot

#
 ENOENT: no such file or directory, stat '/app/image.gif'```
#

just updated to v12

quartz kindle
#

anyway yeah

#

.send({files:[{attachment:fish.body,name:"image.gif"}]})

queen needle
#

thatll work ing v12?

quartz kindle
#

yes

queen needle
#

okay

#

quick question though

#

in v12 did it change to Discord.MessageEmbed?

quartz kindle
#

yes

queen needle
#
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

earnest phoenix
quartz kindle
#

what does it send then?

queen needle
#

nothing

quartz kindle
#

any error?

queen needle
#

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

slender mountain
#

how are you fetching the channel

queen needle
#
    r => r.name === args.join(" ")
  );```
slender mountain
#

cache.find isnt a thing

#

you can remove the .cache

queen needle
#
fields.flat is not a function```
#

all of my embeds get that error

quartz kindle
#

cache.find is a thing lol

#

its correct in v12

queen needle
#

oh

quartz kindle
#

the fields.flat error is because you have an outdated node

#

v12 requires node.js v12 or later

slender mountain
#

sry I was thinking cache.fetch

#

@queen needle did you try logging fetchedChannel?

queen needle
#

dchannel works

#

but i cant figure out wheree to update node

#

im using glitch

quartz kindle
#

package.json > engines

queen needle
#

i dont see that?

quartz kindle
#

show your package.json

queen needle
marble juniper
#

you should have that

quartz kindle
#

if yours doesnt have it, just add it yourself

queen needle
#

goes after dependicies

marble juniper
#

yes

queen needle
#

"engines": {
"node": "14.2.0"
}

#

so that

quartz kindle
#

you can just use 14.x

#

it will automatically use the lastest 14

queen needle
#

i still get the same thing

quartz kindle
#

try restarting your project

queen needle
#

could it be because i have a .glitgnore

#

and from the terminal

quartz kindle
#

you have package.json in your gitignore?

queen needle
#

no

#

but i have a glitgnore in my project

#

and i get the same error

quartz kindle
#

then it shouldnt matter lol

queen needle
#

i just refreshed my project from the terminal

quartz kindle
#

console.log(process.version)

#

check what it logs

queen needle
#

where

quartz kindle
#

anywhere

#

like ready event, or any command

queen needle
#

undefined

#

i spelt it wrong

#

nvm

#

10.15.3

quartz kindle
#

yeah its using v10

#

show your package.json again

queen needle
#

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

earnest phoenix
hasty lotus
#

@earnest phoenix your commands are not async

#

in your external command file do this :

module.exports = async (/*param*/) => {
//command
}```
earnest phoenix
#

alright

hasty lotus
#

add async brefore your params

#

should work

quartz kindle
#

thats not the cause of the error tho?

hasty lotus
#

yep

#

look at the end

quartz kindle
hasty lotus
#
(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.```
quartz kindle
#

that doesnt matter

hasty lotus
#

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

earnest phoenix
#

i can send the code

#

i tried your method and it didn't work

#

gave me same error

quartz kindle
#

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()

white anvil
#

tim did u see me mention u about the detritus multi machine support

#

i looked into it a bit more

quartz kindle
#

i looked at it but didnt find what i was looking for

unique nimbus
#

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

quartz kindle
#

MessageEmbed

heavy marsh
#

How can we add roles or remove roles from a user in v12?

quartz kindle
#

member.roles.add / member.roles.remove

amber fractal
#

member.roles.add()

white anvil
#

what were u after then

#

u can just specify the shard range u want each client to manage

quartz kindle
#

yes, but thats what everyone else does, its not proper multi-machine support

heavy marsh
#
member.roles.add(`Role ID`)
quartz kindle
#

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

white anvil
#

oh right

#

i can ask abt that also lol

quartz kindle
#

which is what im aiming to do with my lib

white anvil
#

i dont rlly mess with sharding systems

queen needle
#
 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

quartz kindle
#

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

amber fractal
#

isnt it guild.channels.create?

quartz kindle
#

@queen needle ^

#

go over the v11 -> v12 update guide

earnest phoenix
queen needle
#

guild is not defined

quartz kindle
#

all changes are there

hasty lotus
#

message.guild

#

if it's in a message block

amber fractal
#

it's probably server for you

hasty lotus
#

message.guild.channels.create()

earnest phoenix
#

It's in a guildmemberadd

#

and message cant be defined in there

quartz kindle
earnest phoenix
#

@hasty lotus

#

ok thx

queen needle
#
    message.guild.cache.createChannel("suggestions", { type: "text" })```
hasty lotus
#

member.guild then

queen needle
#

cant read property of createChannel

quartz kindle
#

there is no createChannel

#

and there is no guild.cache

queen needle
#

how can i create a channel?

quartz kindle
#

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 ^

amber fractal
queen needle
#

so message.create("suggestions", { type: "text" })

quartz kindle
#

what

amber fractal
#

what the hell

queen needle
#

nvm

heavy marsh
#
[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(![Cool_Animated_Blob](https://cdn.discordapp.com/emojis/686906318090403864.webp?size=128 "Cool_Animated_Blob") ${message.author} **enjoy you break!**).then(msg => { msg.delete(10000)});

amber fractal
#

delete options is now an object

#

takes timeout and reason

heavy marsh
#

msg.timeout

earnest phoenix
#

No

amber fractal
#

... no

#

delete({OPTIONS OBJECT})

earnest phoenix
#

{Option: value} is an object

quartz kindle
#
thisIsAnObject = {i am an object}
thisIsAFunctionThatTakesAnObject({i am an object})
heavy marsh
#
await message.channel.send(`![Cool_Animated_Blob](https://cdn.discordapp.com/emojis/686906318090403864.webp?size=128 "Cool_Animated_Blob") ${message.author} **enjoy you break!**`).then(msg => { msg.delete({timeout:10000})});
#

So like this?

quartz kindle
#

yes

heavy marsh
#

OOh i see

#

thanks you

sick cloud
#

what would be the easiest and most non breaking way to add a notification bubble to an <a> link like this

queen needle
#

message.channels.create?

quartz kindle
#

an :after pseudo-element

sick cloud
#

any actual guide on doing it though

quartz kindle
#

its pure css

sick cloud
#

i know

quartz kindle
#
a:after {
  content:"unicodeCircleHere";
  color: red;
  position: absolute;
  top: 0; // change these
  right: 0; // change these
}```
#

try that

sick cloud
#

that makes a circle but it appears next to it

quartz kindle
#

use top and right to control its position

sick cloud
#

in px?

quartz kindle
#

ye

sick cloud
#

can i make it smaller at all

#

oh ok font size works

quartz kindle
#

looks nice

distant plank
#

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

earnest phoenix
#

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

heavy marsh
#

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");
amber fractal
#

uh

#

why are you finding the everyone role

#

it's the id of the guild

heavy marsh
#
    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

amber fractal
#

I don't think that's how you edit overwrites.

sudden geyser
#

yeah looks quite spammy

amber fractal
#

Not even that

#

they're doing permissionOverwrites**[]**

earnest phoenix
#
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

heavy marsh
sudden geyser
#

@earnest phoenix the second argument is supposed to be an object for options.

#

In v12. In v11 it's a check for admin (boolean).

earnest phoenix
#

ok

sudden geyser
#

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."

earnest phoenix
#

oh yeah i didnt mean that 😆

#

so how would i set it up?

sudden geyser
#

Set what up exactly. Fix both logical errors?

earnest phoenix
#

Yea

sudden geyser
clear wraith
#

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```
sudden geyser
#

Are you sure eventFunc is a function.

clear wraith
#

Uhhh

#

Let me see

#

Nope.

sudden geyser
#

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.

clear wraith
#

Ohhhhhhhhhhhh, DUH.

#

Thanks.

heavy marsh
#
        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 ...

earnest phoenix
#

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 😅

sudden geyser
earnest phoenix
#

I tried most likely messed something up because it wouldn't work

slender mountain
#

Can you show what you tried?

earnest phoenix
#

yeah one second lemme get it

heavy marsh
#
[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

earnest phoenix
#
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");
            });
        }
    }

slender mountain
#

Im not sure why you have that permission in the hasPermission method

#

just remove that

earnest phoenix
#

completely or replace it?

sudden geyser
#

@heavy marsh it means one of the values you passed as permission resolvable were invalid.

slender mountain
#

completely

earnest phoenix
#

like this

        if (message.member.hasPermission['KICK MEMBERS', 'ADMINISTRATOR'])
#

?

slender mountain
#

Not quite

earnest phoenix
#

ok

slender mountain
#

hasPermission is a function

#

you need the parentheses to pass parameters to the function

#

like hasPermission(['KICK MEMBERS', 'ADMINISTRATOR'])

earnest phoenix
#

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.
slender mountain
#

oh

#

its KICK_MEMBERS not KICK MEMBERS

earnest phoenix
#

oh whoops i forgot that

#

returns same error

reef heath
#

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;```
sudden geyser
#

Use line breaks.

#

Please.

slender mountain
#

\n

sudden geyser
#

As in \n

reef heath
#

what is a line break

earnest phoenix
#

i would use a embed if you want to make it look nice

#

it makes it look a lot better in my opinion

reef heath
#

Yes, I agree, embeds are nice, but idk how to make them yet.

sudden geyser
#

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

earnest phoenix
#
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()
reef heath
#

OH

sudden geyser
#

Your message can still look nice in plain text. Depends on how you structure it.

reef heath
#

thank you very much!

earnest phoenix
#

here is the one i used

#

then just did

message.channel.send(helpEmbed)
amber fractal
#

if you're using addFields, why not put them all in one function call?

quartz kindle
#

@queen needle show full error

queen needle
#
 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.```
quartz kindle
marble juniper
#

why does no one read the error all the time

#

is it written in alien language for you or what

earnest phoenix
#
        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

quartz kindle
#

@earnest phoenix if your code still looks like your previous post, then you need to add a block

#
if(bla) {
  code here
}```
reef heath
#

How do you make an embed?

earnest phoenix
#

thats the one i used

reef heath
#

thank you!

earnest phoenix
#

welc

reef heath
#

could i understand it as a beginner?

earnest phoenix
#

yeah super simple

reef heath
#

okay sweet

heavy marsh
#
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})
quartz kindle
#

no

heavy marsh
#
[11/05/20 00:49:34.803] [ERROR] (node:11) UnhandledPromiseRejectionWarning: TypeError: member.client.guilds.cache.get(...).fetchMember is not a function
queen needle
#
    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.```
slender mountain
#

@heavy marsh you should check the docs more often

heavy marsh
quartz kindle
#

lmao

queen needle
#

i want up 10 errors

#

went*

slender mountain
#

member definitely does not have a client property

quartz kindle
#

i have no idea how you're even getting these

queen needle
#

niether do

#

i

heavy marsh
#

I just moved it to v12 as it was on v11

#

It worked fine

queen needle
#

im trying to get help from my friend that has the same command

heavy marsh
#

👀

quartz kindle
#

member does have a client property lol

#

anyway director

#

member.guild.members.fetch()

heavy marsh
#

.fetch oofs

#

No need cache

queen needle
#

unable to process the contained instructions?

quartz kindle
#

cache is only for collection methods (get,find,filter,reduce,map,array,etc...)

heavy marsh
#

NVM I am dum

#
bot.on("channelCreate", async(channel) => {

if(channel.guild.id !== `611881570202025986`) return
``` - is this in a wrong way?
quartz kindle
#

@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

pale vessel
#

i don't get why they made it return webp by default

hot tusk
#

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

quartz kindle
#

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)

hot tusk
#

ah i see, oof

quartz kindle
#

you can use buttons with css

#

there are some tricks that enable you to make stuff like css-only tabbed menus

hot tusk
#

oh cool, i'll look into that

reef heath
#

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

sudden geyser
#

@reef heath it could not work for several reasons:

  • args[0] is not the command name.
  • You could be on v11 and MessageEmbed not being a thing.
  • It could be out of scope.
  • channel.send may not work or not have permission.
#

What have you tried that makes it not work?

reef heath
#

what would i replace args[0] with?

icy crane
#

well what is args defined as

reef heath
#

uh

#

i'm sorry i'm a beginner

#

i don't think it is defined

#

OH

#
let args = message.content.substring(PREFIX.length).split(" ");```
icy crane
#

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

reef heath
#

that^^

icy crane
#

yes, I would still recommend that you learn basic javascript before jumping straight into bot development

reef heath
#

how long would that take?

icy crane
#

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

reef heath
#

well, okay

#

i just didn't want to have to do it that way but i guess this was all premature

icy crane
#

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

reef heath
#

okay, will do.

hardy vector
reef heath
#

i'll come back and WOW you all

hardy vector
#

index.js

gloomy imp
#

Does anyone know what to do with
SyntaxError: Cannot use import statement outside a module

hardy vector
#

for my db?

pale vessel
#

sqlite

topaz fjord
#

@hardy vector uh

#

why are you creating a new db/client in rank.js

pale vessel
#

you can use message.client.db instead

earnest phoenix
#

@earnest phoenix ?

royal laurel
#

is there any ideas i can implement into my discord bot

#

?

#

its based off moderation

pale vessel
#

...or is it?

#

what commands do you have

royal laurel
#

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

stable halo
#

mute commands

#

blacklisting a user from using the bot commands, lock a channel

royal laurel
#

kk

#

those are cool ideas

stable halo
#

they're common as well

royal laurel
#

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

stable halo
#

you can just give the mute role

royal laurel
#

k

stable halo
#

i dont think its necessary to remove their current roles

royal laurel
#

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

stable halo
#

well then you can debug or ask for help

royal laurel
#

mkay

hollow prawn
queen needle
#

i just finished switching all my commands from v11 to v12

#

only lost 4 commands

sudden geyser
#

Why would you lose a command?

pale vessel
#

rest in piece 4 commands

#

you will be remembered

mystic violet
#

128mb one?

pale vessel
#

uhhh right click?

mystic violet
#

when I right click "extend volume" is greyed out

pale vessel
#

oh

#

use a partition manager

mystic violet
#

ok thanks 🙂

#

Ill try EaseUS Partition master

#

haha

#

thats funny

#

its paid

#

;-;

pale vessel
#

trial

queen needle
#
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

uneven monolith
#

iOS

pale vessel
#

empty inline fields

uneven monolith
#

Why make it so hard discord

pale vessel
#

or not

uneven monolith
#

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

queen needle
#
 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

pale vessel
#

channel.send()?

candid granite
#

How do I add my bot?

pale vessel
#

you added your bot

queen needle
#

@pale vessel when i hit thumbs up nothing happens

candid granite
#

you added your bot
@pale vessel I have a new one. I’m done with the first one

pale vessel
#

add a new one then

candid granite
#

Thanks

stable halo
#

@queen needle shouldn't you be collecting the reactions of sentMessage ?, i doubt message.awaitReactions() would collect any reactions

queen needle
#

if i change message.awaitReactions() to sentMessage.awaitReactions()

#

it doesnt work

pale vessel
#

because it needs to be inside .then of sentMessage

queen needle
#

all of the await?

icy crane
#

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

hardy vector
#

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.

earnest phoenix
#

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

candid granite
#

why is my bot muted

stable halo
#

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 ?

earnest phoenix
#

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

stable halo
#

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

earnest phoenix
#

i forgot the await 🤦‍♂️

royal laurel
#

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

stable halo
#

are you on v12 djs ?

royal laurel
#

im not sure

stable halo
#

write npm ls discord.js on your terminal

#

it'll return the version of your djs

royal laurel
#

i am currently reading about setting roles on the documentation

#

12.1.1

#

im trying roles.set now

stable halo
#

okay, so since you're on v12 of djs. It is now <guildmember>.roles.add() instead of addRole()

royal laurel
#

mkay

stable halo
royal laurel
#

is the guildMember thing built in or do i use my member

#

one

stable halo
#

guildMember is the Member object of a member. message.member returns the guildMember object of the author

royal laurel
#

k

stable halo
#

dont get twisted with member and user, they're different

royal laurel
#
               ^

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

#

:|

chilly lion
#

Py?

royal laurel
#

js

chilly lion
#

Gay js

#

Use py

royal laurel
#

nah

chilly lion
#

Ez

royal laurel
#

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

chilly lion
#

Damn

#

But

#

U can only learn

#

Not python

#

But its would be little bit hard

royal laurel
#

yes

#

my point

#

and plus

chilly lion
#

That's why I cant learn js

#

:D

royal laurel
#

i would of just learnt all of this disc js stuff for nothing

chilly lion
#

U can make dankmemer and get monr8

#

Monei

royal laurel
#

but see

#

i dot want ot make a bot like tat

#

i make moderation bot

chilly lion
#

Use py I can give u code

royal laurel
#

but i literally would of just learnt all of this shit for nothin

chilly lion
#

I understood

stable halo
#

everyone have different likings, you can't really just force someone into using another language

royal laurel
#

i know a little bit of python

#

but barely any

#

i know up to switch statements lol

chilly lion
#

@stable halo was googling it 3 minutes

#

"Smort words online no sms no registration"

stable halo
#

?

royal laurel
#

Smort

chilly lion
#

Yes

royal laurel
#

sMOrT

chilly lion
royal laurel
#

i havent seen tat one lol

#

only the stonks one

#

wtf did that one come from

#

anyway

#

back to dev

chilly lion
royal laurel
#

i need to rememebr how to @ someone with disc

#

JS

#

NOT PY

chilly lion
#

python plz

#

argds

royal laurel
#

nah dude

chilly lion
#

args

royal laurel
#

i would of learnt disc js for nothin

#

how do i @ someone with discord lol

#

i fucking forgot

chilly lion
#

ARGS

royal laurel
#

?

#

i cant find how to lol

#

can someone tell me very quick?

pale vessel
#

<@id>

#

or the user/member object inside template literals (`${user}`)

royal laurel
#

so if i @ someone in my message

pale vessel
#

won't work

royal laurel
#

it will direct to that person

pale vessel
#

yeah but not @Name

royal laurel
#

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

wheat jolt
#

what are you trying to do actually

royal laurel
#

ok

pale vessel
#

just put the role object/id

royal laurel
#

i am trying to add a muted role

#

it works for the person that typed the command

wheat jolt
#

just put the role object/id
@pale vessel .

#

sorry for ping

royal laurel
#

but i want to have it like

pale vessel
#

check for mention

#

and then resolve the id to a member

royal laurel
#

!mute @earnest phoenixthatiwantedtomute

pale vessel
#

yeah

royal laurel
#

ahh

#

fuck

wheat jolt
#

msg.mentions.members.first()

royal laurel
#

ping

wheat jolt
#

this will give you the mentioned user's member object

royal laurel
#

how would i implement it in the message.member.roles.add()

#

like

#

which part

wheat jolt
#

msg.mentions.members.first()
@wheat jolt .

royal laurel
#

do i make a variable

pale vessel
#

sure

#

member = that

#

and member.roles

wheat jolt
#

msg.mentions.members.first().roles.add

pale vessel
#

that's simpler but who knows, there might be no member mentioned

#

so you can do if (!member) ...

wheat jolt
#

yeah

royal laurel
#

so your saying message.mentions.member.first().roles.add(mutedRole) will work

wheat jolt
#

yes

royal laurel
#

k

#

ill try it out

wheat jolt
#

members

#

not member

royal laurel
#

k

wheat jolt
#

and mutedRole has to be a role resolvable

#

id, or the role's object

royal laurel
#

yeha

#

i have mutedrole as a var

#

also

#

it fianlly works

#

thank you

wheat jolt
#

but as flazepe said, you might want to check before if it's not null

#

or undefined

#

so you can do if (!member) ...

royal laurel
#

k

#
if(!member){message.reply("There needs to be a second argument to run this command")}
#

would work?

wheat jolt
#

yes

royal laurel
#

k

wheat jolt
#

but member has to be message.mentions.members.first()

royal laurel
#

k

#

thank you guys for helping

#

i got it finally

#

working

queen needle
#

how can i make it so my bot reacts with a thumbs up and thumbs down but those are the only allowed reactions

wheat jolt
#

what lib

queen needle
#
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

wheat jolt
#

uhm?

queen needle
#

why?

wheat jolt
#

does that even work?

queen needle
#

yes

cinder patio
#

I doubt it awaits the second promise

wheat jolt
#

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?

queen needle
#

but for every server

wheat jolt
#

you can't do anything

#

just listen for reacts

#

and removing them

queen needle
#

oh

wheat jolt
#

if they're not thumbs up or thumbs down

tight plinth
#

Why does eris disconnects shards every 3 hours?

pale vessel
#

wait

tight plinth
tight plinth
#

oh

#

but clusters doesnt seems to be affected, coz my last log is from 1am tis morning

#

hmmmmm

earnest phoenix
#

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);

})

wheat jolt
#

puteam sa jur

earnest phoenix
#

fmm

tight plinth
#

message.chx.send

#

no

wheat jolt
#

^

tight plinth
#

chx is a channel or just a channel id?

earnest phoenix
#

hey

#

how to send file.txt as a attachment via webhook?
is that possible?

#
 let chx = db.get(`welchannel_${member.guild.id}`); 
wheat jolt
#

it doesn't work like that

tight plinth
#

yes, but this doesnt help me knowing what is chx in itself

#

how do you configure it

earnest phoenix
#

is like the channelid from a guild

tight plinth
#

oh

#

ok

#

you need to do smth like

wheat jolt
#
 let chx = db.get(`welchannel_${member.guild.id}`); 
 let channel = member.guild.channels.get(chx);
#

then channel.send

earnest phoenix
#

__

tight plinth
#

bot.channels[.cache].get(chx).send(defaultmsg)

earnest phoenix
#

helo

#
bot.channels.get(chx).send(defaultmsg)
#

i had that earlier and the same thing

wheat jolt
tight plinth
#

@earnest phoenix quick answer to your question: can you?

earnest phoenix
#

i can't. thats why i came here to ask

wheat jolt
#

no

#

you can't

#

it's not possible

cinder patio
#

you can send a file with a webhook?

modest maple
#

Probably

viscid wave
#

hi

wheat jolt
#

you can send a file with a webhook?
@cinder patio ah yes

cinder patio
#

then why did you say it's not possible

viscid wave
#

does anyone knows discord py

wheat jolt
#

because I didn't knew until now

earnest phoenix
#

Hello everyone, if you think of the bot missing that I made, please send a message from dm? @marble estuary

pale vessel
#

@viscid wave the person 4 messages above yours knows python. if only you didn't waste time by asking to ask :(

tight plinth
#

how to get user flags on eris

pale vessel
#

get master

tight plinth
#

docs search bar is stoopid

pale vessel
#

or use discord api

white anvil
#

@tight plinth you can’t

#

you need to use dev branch, it’s not documented yet

pale vessel
#

just use discord api

tight plinth
#

f

pale vessel
#

i have flags lol

grizzled raven
#

create your own lib

tight plinth
#

I'll use dev

#

why are flags numbers aaaaaaaaaaa

mossy vine
#

because its easier to represent several flags in 1 unit of data

tight plinth
#

but its hard to manipulate them aaaaa

#

(personally my brain is too small to do it)

frail ocean
#

I agree, but depends on your library

#

some are lovely and have it built in.

tight plinth
#

Im trying to do it in eris

pale vessel
#

just

#

make an object

#

not hard

#

and make a loop and use bitwise and operator

grizzled raven
queen needle
#
 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
golden condor
#

I am gonna try modify the Eris library

pale vessel
#

might as well make your own

tight plinth
#

not hard
@pale vessel hard for me smh

pale vessel
#

well sorry

golden condor
#

might as well make your own
@pale vessel uhhhh no thanks

pale vessel
#

lol

golden condor
#

Eris should have a reconnect event

pale vessel
#

it does?

golden condor
#

Like d.js

#

Does it

pale vessel
#

yes

tight plinth
#

it does

pale vessel
#

just read docs

#

smh

golden condor
#

Yeah but it triggers the ready event

tight plinth
#

well fuck flags

pale vessel
#

it should

golden condor
#

Aren't flags against ToS?

pale vessel
#

no

tight plinth
#

no

pale vessel
#

how

golden condor
#

I mean nitro ones

pale vessel
#

yeah

#

they're not public

#

only for user accounts

tight plinth
#

nitro flags arent public

golden condor
#

You have to ask for oauth for thise

pale vessel
#

yes

frail ocean
#

Mhm

grizzled raven
#

what are nitro flags

tight plinth
#

badges

frail ocean
#

Nitro, Nitro Classic and no Nitro.

#

Aka "premium level"

grizzled raven
#

ohk

restive furnace
#

create your own lib
exactly, i am doing it rn. (public lib yes if u ask)

earnest phoenix
#

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^^
tight plinth
#

why using this

earnest phoenix
restive furnace
#

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)

hasty valve
#

my bot now has ??? for it's activity

quartz kindle
#

@restive furnace if you're getting NaN then one of those is not a number, console.log them both

restive furnace
#

okay, lemme try

#

s.latency is - undefined... that explains it.

restive furnace
#

okay, i think got it working

earnest phoenix
#

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????????

modest maple
#

lol

earnest phoenix
#

imagine being toxic because you don't know how to do bitwise operations

#

:omegalul:

knotty steeple
earnest phoenix
#

you don't even have to do bitwise operations

#

d.js makes it easy for you and has methods to check lol

pale vessel
#

lmao your nitro ran out cry i just realized

earnest phoenix
#

:(

snow urchin
earnest phoenix
#

your cur variable has it

snow urchin
#

it dnt

#

its just a number

earnest phoenix
#

oh

#

yeah

#

that char doesn't seem like a regular comma

snow urchin
#

thats just the quality of the ss i think haha

pale vessel
#

because it's map lmao

#

it returns an array

snow urchin
#

oh ye LMAO

#

idiot i am

earnest phoenix
#

oh yeah

pale vessel
#

you can simply join them

snow urchin
#

ye thats wat av done now

pale vessel
#

my brain was processing for like a minute

snow urchin
earnest phoenix
#
    db.set(`welchannel_${message.guild.id}`, `${message.guild.channel.id}`) 

error :

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined

at message.guild.channel.id

quartz kindle
#

there is no guild.channel

knotty steeple
#

thats not valid

#

what channel are u getting

glad charm
#

He clearly wants message.channel

earnest phoenix
#

it's like when i use /setchannel #channel to write in the database both guild id and channel id

quartz kindle
#

then you want the id of the mentioned channel?

earnest phoenix
#

yes

quartz kindle
#

use the mentions property of the message

earnest phoenix
#

is ok if i did this?

let channel = message.mentions.channels.first()

then

db.set(`welchannel_${message.guild.id}`, `${channel.id}`)

quartz kindle
#

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
glad charm
#

Assuming a channel was mentioned, then yeah Sabin.

quartz kindle
#

yes, what you did is correct

earnest phoenix
#

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 ?

quartz kindle
#

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}

earnest phoenix
#
  let chx = db.get(`welchannel_${member.guild.id}`); 
quartz kindle
#

yes

earnest phoenix
#

but this doesn't get only the guild id ?

quartz kindle
#

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

earnest phoenix
quartz kindle
#

depends on the context

earnest phoenix
#

wdym ?

quartz kindle
#

if its a message/command, you probably want message unless you're defining member

#

if its on a guildMemberAdd, there is no message there

earnest phoenix
quartz kindle
#

yes

earnest phoenix
#

It still don't send any message to the specific channel

#

when someone join

quartz kindle
#

show code

earnest phoenix
#

from index.js or setchannel.js ?

quartz kindle
#

index

earnest phoenix
#
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);  
  })
quartz kindle
#

are you on v11 or v12?

earnest phoenix
#

v11

quartz kindle
#

show your setchannel

earnest phoenix
#
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
#

@hardy vector client.db is undefined, is the db property on client valid ?
@stable halo yes look at index.js

quartz kindle
#

looks correct, try console.log(db.all()) somewhere in your code

#

and see what it logs

earnest phoenix
#
    data: '"709122923293573120"' } ]```
#

i got this

lethal shuttle
#

Can you post to dbl the full server amount by only by posting the shards own amount?

quartz kindle
#

@lethal shuttle yes, if you post each server count separately from a specific shard id, top.gg will join them together

hardy vector
#

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.

earnest phoenix
#

@quartz kindle i got nothing

hardy vector
quartz kindle
#

dude....

#

didnt we go over this already?

hasty sparrow
#

rank.js:10

quartz kindle
#

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?

earnest phoenix
#

yes

hardy vector
#

but i thought because we do client.db.get = db in index.we have to do client.db

quartz kindle
#

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

hardy vector
#

ok so i can remove new discord.client in rank and keep client.db stuff

quartz kindle
#

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.

hardy vector
#

oh

earnest phoenix
#

So @quartz kindle do you have any idea?

quartz kindle
#

are you sure it doesnt show anything? did you put the console.log before the null check?

#

it should show at least undefined

earnest phoenix
#

i put the console.log where u told me

quartz kindle
#

show your full code then

#

the entire file

hardy vector
quartz kindle
#

where the guildMemberAdd is

earnest phoenix
#

ok

#

the entire index.js ?

quartz kindle
#

yes

#

@hardy vector you're setting it as level and getting it as levelnew

hardy vector
#

where ?

quartz kindle
#

@earnest phoenix why is your guildMemberAdd inside a message event?

cinder patio
#

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)

quartz kindle
#

@hardy vector in your index you do .set("level-..."), but in your rank you do .get("levelnew-...")

earnest phoenix
#

because i need message to be defined and that was my only idea

#

=))

quartz kindle
#

@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?

cinder patio
#

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

quartz kindle
#

give them a csrf token or something

earnest phoenix
#

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?

jovial nexus
earnest phoenix
#

@quartz kindle and where should i put the guildmemberadd?

#

@jovial nexus show code

quartz kindle
#

@cinder patio try saving them in sessionStorage instead of cookies

jovial nexus
#
      const cmd = client.comandos.get(comando1) || client.comandos.find((c) => c.alias.includes(comando1))
quartz kindle
#

sessionStorage is unique per tab afaik, and survives page refreshes, but doesnt survive tab closing / browser exiting

#

@earnest phoenix what database?

cinder patio
#

oh hey that's not a bad idea

maiden mauve
#

Good morning all,
"Casts a spell on themselves"
"Casts a spell on theirself"
Thonk

quartz kindle
#

@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

earnest phoenix
#

@quartz kindle quick.db

quartz kindle
#

delete the database file? lol

earnest phoenix
#

No not its

quartz kindle
#

@jovial nexus c.alias is undefined

#

one of your commands does not have an alias property

jovial nexus
#

ahhhh

#

thx

earnest phoenix
#

i want to use lavalink but i dont know how to use it

#

learn then

hardy vector
#

there are so many vids on that

#

ansonthedev

#

vultrex development

earnest phoenix
#

thanks

hardy vector
#

(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;````
earnest phoenix
#

@quartz kindle i put it on the top, how should i define message ?

#

URL @hardy vector not "Url"

quartz kindle
#

@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

earnest phoenix
quartz kindle
#

message is not the only source of guild

#

you can get a guild from many other things

earnest phoenix
#

eg ?

quartz kindle
#

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

earnest phoenix
quartz kindle
#

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

earnest phoenix
#

Ok, tysm

quartz kindle
#

because thats what the event gives you

earnest phoenix
#

ok, i solved this, but the bot still doesn't send any message

#

why ? no error, no logs

quartz kindle
#

cant know without seeing current code

cinder patio
#

Thanks Tim works just fine with sessionStorage

quartz kindle
#

👍

earnest phoenix
#

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

quartz kindle
#

iconURL should work

#

@earnest phoenix use the guildMemberAdd event

maiden mauve
#

I don't see an iconURL in guild object

quartz kindle
#

hes using v11

earnest phoenix
#

ok

maiden mauve
#

oh its a method

#

disregard me then

#

😉

earnest phoenix
#

only iconURL ?

maiden mauve
#

Is there any advantage to being on 11 other than code continuity?

earnest phoenix
#

@maiden mauve i think it's easier 😛

quartz kindle
#

the other way around, being on v12 has the advantage that your bot will not stop working on october 2020