#development

1 messages · Page 867 of 1

earnest phoenix
#

@earnest phoenix please reply fast i need to post my question too so would like to end ur fast

#

i fix it

#

sorry

#

for waste your time

#

Idk why i get this error at all

dire abyss
#

something wrong with permission overwrites

cinder patio
earnest phoenix
#

@cinder patio gotta look that

cinder patio
#

Also, you can provide permission overwrites in the options argument of the create method

earnest phoenix
#

wdum

cinder patio
#
.create(name, {
   type: "text",
   permissionOverwrites: [...]
});```
earnest phoenix
#

Uh i see

#

but doens't look bether visualy

#

Also thx for help it worked 😉

cinder patio
#

ok sure but that way you are making less requests to discord so the code is generally faster and more efficient

earnest phoenix
#

Ok so its like

#
.create(name, {
   type: "text",
   permissionOverwrites: [  {
     id: message.author.id,
     allow: ['VIEW_CHANNEL'],
  },
  {
      id:guild.id,
      deny: ['VIEW_CHANNEL'],
  }]
});```
cinder patio
#

yup

earnest phoenix
#

Perfect then

unique patio
#

Help me write a command for a bot on Python
That-would at the mention of ovner, the bot removed the mention

#

I can't think of it)

tight plinth
#

@unique patio I can't code on py but here is how u can do :
-bot.on_message
-if msg.content == '<@ownerid>' msg.delete()

#

But even with that owner will still got the notif

#

If he gets pinged

earnest phoenix
#

If the essage is not only pinging

#

it won't work

#

bether doing like

#

msg.contains("<@" + ownerid + ">")

tight plinth
#

Msg.content.contains ?

earnest phoenix
#

cuz rn if i say @tight plinth won't be detecter

#

Yes as i remember

tight plinth
#

I can't code in py @earnest phoenix

earnest phoenix
#

Its nodejs

#

😂

#

hey

unique patio
#

@tight plinth But the person who made the ping will not know that the owner received the notification, and will no longer ping 😂

tight plinth
#

It will

#

Spam

unique patio
#

If it spams , I'll ban it 🙂

tight plinth
#

What if you cant

#

Coz ur not admin/mod

unique patio
#

Well, if I am on a server where I am not an admin, then the server is important to me, and important servers will not be pinged just like that

modest maple
#

wut

tight plinth
#

Watt

modest maple
#

where is the logic behind that Think_mega_Spin

earnest phoenix
#

please

tight plinth
#

Why do you want your bot to do it anyways

unique patio
#

She's gone

tight plinth
#

Whatt

unique patio
#

I don't really understand what you want from me 😂

tight plinth
#

Not doing that

nocturne grove
#
const collector = new Discord.ReactionCollector(reactionRolesMessage, filter);
collector.on('collect', (reaction, user) => {
    console.log('lol');
});
collector.on('remove', (reaction, user) => {
    console.log('lol2');
});``` why does 'collect' work but 'remove' doesn't? I'm just following the docs: https://discord.js.org/#/docs/main/stable/class/ReactionCollector?scrollTo=e-remove
hollow granite
#

I think i had this same problem awhile ago, but I got it to work. You have to add on option for the reactionCollector called dispose
https://discord.js.org/#/docs/main/stable/typedef/CollectorOptions

#

maybe something like this would work

const collector = new Discord.ReactionCollector(reactionRolesMessage, filter, { dispose: true});
summer torrent
#

is value ? true : false working on nullable values?

quartz kindle
#

yes

summer torrent
#

if value is null, which one will it be? true or false ?

cinder patio
#

false

tight plinth
#

false

#

0=false=null=undefined

cinder patio
#

(and also empty strings)

nocturne grove
#

@hollow granite thank you!

royal portal
#

does anyone know how to return if you mention someone or your message starts with <@

earnest phoenix
spare goblet
#

message.guild.roles.cache.find()

summer torrent
#

@royal portal which lib

spare goblet
#

if(message.mentions.users.first()) return;

summer torrent
#

in discord.js, Message object has a mentions method

spare goblet
#

it's not a method, it's a property

summer torrent
earnest phoenix
royal portal
#

discord.js

spare goblet
#

member.roles.add()

#

don't ping ty

earnest phoenix
#

sorry'p

summer torrent
earnest phoenix
#

Alright will look about that pain in the as

spare goblet
#

member.roles is somehow not defined

#

and that is because

#

member is not a user object

#

let { member } = message;
member.roles.add(role)

#

message.author returns a user object, you need a member object, which is message.member

earnest phoenix
#

Uhh i see

#

works well thex

earnest phoenix
#

How can i force my invitation url to be condom like and be used only one time ?

#

just found on doc

#

bruh

vestal patrol
#
client.on('guildMemberAdd', member => {
  var role = member.guild.roles.cache.find(role => role.name === 'verify');
  member.roles.add(role);
  const rando_imgs = [
    'https://cdn.discordapp.com/attachments/648627056246259738/689454008427085851/Sayori_Illustration.png',
    'https://cdn.discordapp.com/attachments/648627056246259738/689454069361672257/paint-stripe-png-16.png',
    'https://cdn.discordapp.com/attachments/648627056246259738/689454107236630635/Untitled-434554.png',
    'https://cdn.discordapp.com/attachments/648627056246259738/689457427447283808/Untitled-434554-Recovered-Recovered.png',
    'https://cdn.discordapp.com/attachments/648627056246259738/689458587461746725/midoriya_izuku__render__444_by_fania98_dd75ho3-pre.png',
  ];
  const embed = new Discord.MessageEmbed()
    .setTitle(` Welcome to ${member.guild.name} `)
    .setColor(0xffb700)
    .setThumbnail(`${member.user.displayAvatarURL}`)
    .setDescription(`Welcome ${member} to **${member.guild.name}** dont forget to read the rules and enjoy the server`)
    .setImage(rando_imgs[Math.round(Math.random() * (rando_imgs.length - 1))])
    .setFooter(`© ${member.guild.name} 2020 - 2021` )
    .setTimestamp()
  
      member.guild.channels.cache.find(ch => ch.name === "welcome").send(embed);
});

client.login(token);
``` its not sending the embed but it is giving me the role what did i do wrong
cinder patio
#

you aren't sending the embed

#

oh wait you are

#

are you getting any errors?

elder vine
#

You should firstly, check if the role exists, then add it.

#

Same with the channel, if the channel exists, then send the message.

earnest phoenix
#
const Discord = require("discord.js");
const quickdb = require("quick.db")
const Guild_data = new quickdb.table("lang")

exports.run = async (bot, message, args) => {

let server = message.guild.id;
if(!message.member.hasPermission("MANAGE_GUILD")) return message.channel.send("**🇫🇷 Vous devez avoir la permission `MANAGE_GUILD` afin d'effectuer cette commande.\n\n🇺🇸 You must have permission `MANAGE_GUILD` to do this command.**")

if(!args[0] || args[0] !== "fr" || args[0] !== "en") {
return message.channel.send("**🇫🇷 Langues disponibles / 🇺🇸 Available languages :\n\n↪️ `f.setlang fr` : Selectionne la langue française / Select french language.\n↪️ `f.setlang en` : Selectionne la langue anglaise / Select english language.**")
} 

Guild_Data.set(`${server}.lang`, args[0]);
if(args[0] === "fr") {
message.channel.send("**![confirmed](https://cdn.discordapp.com/emojis/574293341324443678.webp?size=128 "confirmed") La langue par défaut est maintenant `🇫🇷 Français`.**")
} else if(args[0] === "en") {
message.channel.send("**![confirmed](https://cdn.discordapp.com/emojis/574293341324443678.webp?size=128 "confirmed") The default language is now `🇺🇸 English`.**")
}
}


exports.help = {
name: "setlang"
}```
#

when I make the command f.setlang fr or f.setlang en the bot puts me that the message of the available languages

elder vine
#

Can you change it to `js ?

#

on the top

earnest phoenix
#

ues

elder vine
#

ty

earnest phoenix
#

good

elder vine
#

What you should do is this:

royal portal
#

can anyone help me from yesterday? :/

#

when I unban someone and I do -unban user then

elder vine
#

if (args[0] === "fr") {
//code
} else if (args[0] === "en") {
//code}
} else {
//code
}

royal portal
#

it says

#

user id is not snowflake

#

how do I make it ignore the mentions in unban

summer torrent
#

lemme check your code

earnest phoenix
#

Ok thx

elder vine
#

Which line Bloxys?

#

No problem :)

royal portal
#

well

#

i think its the

#

return part

#

on //

#

// check if banneduser

#

the mentions.user.size

#

I want it to return if the person mentions user

elder vine
#

Which line in the code?

#

22?

royal portal
#

yes

#

i want it only to check userid not the mention

elder vine
summer torrent
royal portal
#

what about it

summer torrent
#

just do message.mentions.users.size === 0

earnest phoenix
#
const quickdb = require("quick.db")
const Guild_data = new quickdb.table("lang")

exports.run = async (bot, message, args) => {

let server = message.guild.id;
if(!message.member.hasPermission("MANAGE_GUILD")) return message.channel.send("**🇫🇷 Vous devez avoir la permission `MANAGE_GUILD` afin d'effectuer cette commande.\n\n🇺🇸 You must have permission `MANAGE_GUILD` to do this command.**")

if(args[0] === "fr") {
Guild_Data.set(`${server}.lang`, args[0]);
return message.channel.send("**![confirmed](https://cdn.discordapp.com/emojis/574293341324443678.webp?size=128 "confirmed") La langue par défaut est maintenant `🇫🇷 Français`.**")
} else if(args[0] === "en") {
Guild_Data.set(`${server}.lang`, args[0]);
return message.channel.send("**![confirmed](https://cdn.discordapp.com/emojis/574293341324443678.webp?size=128 "confirmed") The default language is now `🇺🇸 English`.**")
} else {
return message.channel.send("**🇫🇷 Langues disponibles / 🇺🇸 Available languages :\n\n↪️ `f.setlang fr` : Selectionne la langue française / Select french language.\n↪️ `f.setlang en` : Selectionne la langue anglaise / Select english language.**")
}
}


exports.help = {
name: "setlang"
}```
#

leny32 is good?

elder vine
#

Should be, try and see.

earnest phoenix
#

k thx

royal portal
#

stukk

#

still

#

same error

#

invalid form body

#

it works its just the error

#

:/

blazing portal
#

@royal portal what exactly do you want? you want your unban command to not unban if there are mentioned users?

royal portal
#

yeah

blazing portal
#

well, NMW has already told you the line. You're double negating, so remove both "!"

#

like he said, message.mentions.users.size === 0

royal portal
#

i did

blazing portal
#

and what exactly is happening now?

royal portal
#

i'm going to check

#

still

#

discordapierror

#

invalid form body

#

value user id is not snowflake

summer torrent
#

show error location

royal portal
#

how would i know that

summer torrent
#

check error message

royal portal
#

it only shows requesthandler

#

not the line in bot.js

summer torrent
#

send screenshot

royal portal
#

-.

summer torrent
#

or console.log(err.stack)

royal portal
#

0|kitty | DiscordAPIError: Invalid Form Body
0|kitty | user_id: Value "@bright radish" is not snowflake.
0|kitty | at RequestHandler.execute (/home/pi/Desktop/Other/DiscordBot/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
0|kitty | at processTicksAndRejections (internal/process/task_queues.js:97:5) {
0|kitty | name: 'DiscordAPIError',
0|kitty | message: 'Invalid Form Body\n' +
0|kitty | 'user_id: Value "@bright radish" is not snowflake.',
0|kitty | method: 'get',
0|kitty | path: '/users/@bright radish',
0|kitty | code: 50035,
0|kitty | httpStatus: 400
0|kitty | }

summer torrent
#

or console.log(err.stack)
@summer torrent

quartz kindle
#

this is the cause of the error: client.users.fetch(args[0])

royal portal
#

what should I replace it with?

#

.get?

quartz kindle
#

so you need to move this if(message.mentions.users.size) return; to before that line

#

and change it to that, not the !... === 0 way

royal portal
wet cypress
#

What is wrong

summer torrent
#

we can't help you for bot makers

royal portal
#

would it be like that?

#

I moved it like Tim said

summer torrent
#

just try it and see

royal portal
#

still

#

same thing

#

discordapi

nocturne grove
#

Hi. I did some stupid things with my bot that's hosted on Heroku (I will soon get another host for it, don't worry). It doesn't start anymore after I push it to Github. Automatic deployment is still on and I saw I deleted the Procfile yesterday, but I recovered that. Does Heroku require other files as well? I guess I have to configure the starter file somewhere on their website too, but I can't find it.

wide wharf
#
client.on('message', message => {
if (message.content.startsWith('mb!avatar') {
if (!message.mentions.users.size) {
return message.channel.send(`Your avatar: ${message.author.displayAvatarURL}`);
}
const avatarList = message.mentions.users.map(user => {
return `${user.username}\'s avatar: ${user.displayAvatarURL}`;
});
message.channel.send(avatarList);
})});
```^^ My **code**

/home/container $ node app.js
/home/container/app.js:1222
if (message.content.startsWith('mb!avatar') {
SyntaxError: Unexpected token {
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)

earnest phoenix
#

you didn't end your if()

royal portal
#

anyone help?

nocturne grove
#

yeah it's not right

charred crater
#

I need a cool help command js . Can someone give me?

earnest phoenix
#

make it yourself

#

we don't spoonfeed here

summer torrent
#

"cool"

royal portal
#

I might need to rewrite my code

#

still getting same errors

quartz kindle
#

please do

#

you can start with learning more about promises

#

because this await users.fetch(id).then().catch(console.error) kinda makes no sense

#

and this makes even less sense js try { message.guild.members.unban(bannedMember).then().catch(console.error); logsChannel.send(embed).then().catch(console.error); } catch(e) { console.log(e.message) }

wide wharf
#
client.on('message', message => {
if (message.content.startsWith('mb!avatar') {
if (!message.mentions.users.size) {
return message.channel.send(`Your avatar: ${message.author.displayAvatarURL}`);
}
const avatarList = message.mentions.users.map(user => {
return `${user.username}\'s avatar: ${user.displayAvatarURL}`;
});
message.channel.send(avatarList);
})});
```^^ My **code**

/home/container $ node app.js
/home/container/app.js:1222
if (message.content.startsWith('mb!avatar') {
SyntaxError: Unexpected token {
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:656:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)

@earnest phoenix I did, I think... oliythink
or where should I place the extra )

@quartz kindle Can you help me please 🥺

royal portal
#

well im just gonna scrap ban and unban

earnest phoenix
#

you just have to end your if statement

quartz kindle
earnest phoenix
#

proper syntax is the basics of js

wide wharf
#

Oooh thankyuuu

#

@quartz kindle

nocturne grove
#

Hi. I did some stupid things with my bot that's hosted on Heroku (I will soon get another host for it, don't worry). It doesn't start anymore after I push it to Github. Automatic deployment is still on and I saw I deleted the Procfile yesterday, but I recovered that. Does Heroku require other files as well? I guess I have to configure the starter file somewhere on their website too, but I can't find it.
nvm I'm dumb 😂

true ravine
#

Have you chosen a library yet?

summer torrent
#

which language do you use

valid holly
#

Learn how to code first ?

true ravine
#

Do you have any programming knowledge at all?

#

If not, go to somewhere like codecademy first and learn

valid holly
#

(prefixs, embeds, !ping) don't conclude "basics"

#

Those are just specific properties and features in this domain.

#

In conclusion, you need to learn computing basics or basic programming concepts.

#

To learn, in fact, and form a base you then build on more and more knowledge.

true ravine
#

If you've done roblox stuff I assume you know a bit of lua?

#

Javascript is vaguely similar to lua so it would be easiest for you to learn that

valid holly
#

^ lmao

true ravine
#

Get on codecademy and try to understand basic javascript, then get on Discord.JS Guide and look through there

#

You're welcome

#

Good luck

lyric mountain
#

Javascript is vaguely similar to lua so it would be easiest for you to learn that
As close as a chimp is to a fish, but yeah, considering only the non-typed vars and not being compiles langs they are similar

true ravine
#

Idk they kinda look similar to me

#

Anyone know what the maximum speed you can update a html tag

#

I'm trying to animate my bot stats counting up but one of the stats its still counting up when all the rest are finished so I need to do some math to calculate the step (atm I'm using 1)

#

Nvm fixed it

earnest phoenix
#

(node:7060) UnhandledPromiseRejectionWarning: TypeError: message.member.roles.find is not a function

#
if (message.content.startsWith(">>selectbot")) {
  if(!message.member.roles.find(r => r.name === "customer")) { message.channel.send("Not a customer")}

}
quartz kindle
#

what discord.js version?

balmy knoll
#

In discord.js how can I find the id of the everyone role?

earnest phoenix
#

Last one @quartz kindle

pale vessel
#

it's the guild id

earnest phoenix
#

14

pale vessel
#

last one is v12

earnest phoenix
#

12 my bad

quartz kindle
#

@earnest phoenix roles.cache.find()

earnest phoenix
#

Perfect thx

#

Is '''msg.channel.send(embed).then(msg.delete(1000))''' correct

true ravine
#

That will send an embed and then instantly delete it I think

#

I assume you want to wait 1 second before deleting it?

#

I think you have to put {timeout:1000}

#

But idk

earnest phoenix
#

But it won't delete the msg

#

I want to delete it

robust moth
quartz kindle
#

you want to delete the embed or the command?

#

make what

fallen arch
#

Is '''msg.channel.send(embed).then(msg.delete(1000))''' correct
@earnest phoenix thats not correct

#

.then(m => m.delete(1000))

#

if you're using v12, there are options

earnest phoenix
#

Oh yes

fallen arch
#

m.delete({ timeout: 10000 })

earnest phoenix
#

That for 12

fallen arch
#

yea

earnest phoenix
#

msg.channel.send(embed) (msg.delete({ timeout: 10000 }))

#

Like that

fallen arch
#

no

#

.then(msg => msg.delete())

earnest phoenix
#

K

pale vessel
#

or await

earnest phoenix
#

Thx

pale vessel
#
const sentMsg = await msg.channel.send(embed);

sentMsg.delete({ timeout: 10000 });
earnest phoenix
#

Hey how do I gets started learning to make a bot that screenshots a window then sends it to mail or discord?

#

10000 is 10s right

pale vessel
#

yes

earnest phoenix
#

Is 10s gud

#

Or reduce it

pale vessel
#

reduce

earnest phoenix
#

K

pale vessel
#

well, depends on the embed

#

if it's short, i'd say reduce

earnest phoenix
#

K thx

lyric mountain
#

Hey how do I gets started learning to make a bot that screenshots a window then sends it to mail or discord?
@earnest phoenix you can't, unless you want to sc your own window

earnest phoenix
#

huh

lyric mountain
#

How can I make it??? Any hint
@robust moth how can you make what? the prefix?

earnest phoenix
#

so you are saying this cant be done?

quartz kindle
#

which window do you want to screenshot?

earnest phoenix
#

a game

lyric mountain
#

yep, bots normally run in virtual servers, so they can't actually see a "screen"

quartz kindle
#

the only way to do that is to run the bot inside the same machine where the game is running

#

or to run a program that does it and then sends it to the bot

earnest phoenix
#

doesnt need to be a discord bot just a bot that screenshot and sends image

lyric mountain
#

as I said, UNLESS you are running the bot on your own machine, in this case it wouldn't be a bot but a sc application

#

damn, tim is too ninja

quartz kindle
#

you need to look into screen capturing solutions and software

#

and screen capturing APIs if you're developing on your own code

earnest phoenix
#

Ok how do i get started on making this

#

where do I go

quartz kindle
#

which language do you know?

earnest phoenix
#

None

quartz kindle
#

then im sorry, but that is most likely too advanced for a beginner

lyric mountain
#

with java it's mostly straightforward

#

but still, as tim said, too much for a beginner

earnest phoenix
#

Ok thanks for time i will learn java

#

or just use ffmpeg

#

ffmpeg allows screen capture

quartz kindle
#

or you could use something like shareX, which apparently has a CLI you could interface with

lyric mountain
#

yeah, there are good solutions on the internet

#

but since he asked for "how to make" I suggested that

earnest phoenix
#

Can it automatically capture a screenshot at given interval?

crimson vapor
#

I think most people here havnt attempted something like this

true ravine
#

Before I waste my time, if I send data from one nodejs server to another (with a self signed cert) and then forward the data from the second nodejs server to my website, will it appear as a secure connection on the webpage? (I'm using aws for my bot and glitch for my site, hence the bodge)

#

Wait idk if that would even work to begin with lol

quartz kindle
#

shareX can do that @earnest phoenix

crimson vapor
#

you can create your own shareX uploader that posts it where you want

earnest phoenix
#

Woah

#

Ill try this

#

Thank you very much

true ravine
#

Glitch said a port was already in use so I did this and it still refuses to work

#

Conclusion: Glitch bad

elder vine
#

Which port were u using?

#

Glitch uses port 3000, if I'm correct.

zenith orchid
#

Because: free

summer torrent
#

glitch only allows 3000

true ravine
#

Tried 3000 as my first attempt, then 8000, then 8080

elder vine
#

You should consider getting a VPS, you can get one for like $3/month.

true ravine
#

I have one, this is a test

#

I have an AWS EC2 thingy

#

I use that for my bot

elder vine
#

Oh, ok.

true ravine
#

The while loop is still going and has tried over 120k ports lol

summer torrent
true ravine
#

Thanks

elder vine
#

Port 25565, someone trying to host a minecraft server on glitch? XD

true ravine
#

Very cool

summer torrent
true ravine
#

Flex than 512mb of ram for a mc server

#

Damn

elder vine
#

oh no, xD

true ravine
#

Wait if only port 3000 is exposed does that mean I can't have an inbound and outbound connection?

elder vine
#

Why would you use glitch to host the project anyways?

#

Can't you setup another project on the VPS?

true ravine
#

Right so I have my bot, I need to get some data to my website (which is on glitch until I have money for domains) but my website now appears as insecure because the connection between the vps and glitch is on a self-signed cert

#

So I was trying to pull that data to a glitch nodejs server and then forward it on to my site so it all appears secure

elder vine
#

Use cloudflare?

true ravine
#

For what?

elder vine
#

If you're using a website

true ravine
#

Yeah

#

What would cloudflare be for tho?

elder vine
#

If you want a SSL Certificate

true ravine
#

Oh I get you now

elder vine
#

https (secure)

true ravine
#

Yeah

#

Whenever I go to the page it says https so I'd use cloudflare to make it secure?

elder vine
#

Cloudflare should work, yes.

true ravine
#

Thank you very much

#

I'll try that

elder vine
#

No problem :)

vagrant tree
#

does anyone know if there is a reddit api

amber fractal
summer torrent
#

yes

vagrant tree
#

is there a discord guild for it?

summer torrent
#

for what? reddit?

vagrant tree
#

the reddit api praw

vivid mortar
#

i tried adding a server (that is on top.gg/servers) to my bot page using the ID but its not showing on the site

#

did i do something wrong?

nocturne dagger
#

that would be #general this is for programming development

tight plinth
#

^

old tangle
#

How to get a role?

tight plinth
#

wrong channel

summer torrent
#

which role

finite bough
#
var role = message.mentions.roles.first() || message.guild.roles.get(args[1]) || message.guild.roles.get(r => r.name === args[1])
#

is this correct?

#

did

#

didnt work

#

logged args[1]

earnest phoenix
#

then it isn't correct

finite bough
#

no problem

#

LOL

#

any idea what i did wrong

#

nvm discord being gay

clever storm
#

@fossil oxide Youre still accepting hand written applications yeah?

#

For certification

summer torrent
#

@bitter sundial ^ 👀

vivid mortar
#

im not the best at css but i cant seem to change the color of this, ive tried doing color="" and adding it to css, and i tried making a class too but i guess im doing something wrong

#

for some reason color="" worked with other lines but not that

sinful belfry
#

You shouldn't need speech marks.

#

Just do color: #FFFFFF or any other colour you want.

vivid mortar
#

yeah that wont work

#

isn this code tho?

sinful belfry
#

Nope, only bot development.

vivid mortar
#

alright

cinder patio
#

That needs to be inside your css tag

summer torrent
#

^

#

or <p style=""> </p>

vivid mortar
#

i had it in my css tag but it didnt seem to change

#

however i tried the thing starman told me and it worked

#

even tho for my body color="" worked

balmy knoll
#

How can I check if a user whose ID I know is connected to a specific voice channel? [Discord.js]

summer torrent
#

what is your djs version

balmy knoll
#

12

plucky heart
#
      console.log(`User with ID ${vote.user} just voted!`);
        let embed = new Discord.RichEmbed()
            .setColor(`#5780cd`)
            .setAuthor(`<@${vote.user}> Upvote !`)
            .setTimestamp()
            .addField(`User ${vote.user} With ID ${vote.user} Just Upvote For my Bot `, `He UpVote in https://top.gg/bot/688364176305029132 `)
            .addField(`We Have ${vote.count} UpVotes `, `Thanks You Soo Much`)

let guild = Client.guilds.cache.get(`698495495236223026`)
Client.channels.cache.get(698648416825245777).send(embed) 
});```

```(node:7584) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined```
What's wrong?
summer torrent
#
Client.channels.cache.get(698648416825245777).send(embed)```
channel ID must be a string
plucky heart
#

Ah, okay

heavy marsh
#

I am using discord.js v12.1.1
I am trying to get an invite from a guild the bot is on.
https://hasteb.in/ebetudow.coffeescript

But it keeps on saying the bot is not in that guild when it is in it....
Can some one help?

turbid bough
#

to give someone roles, you would need to have manage roles right?

slender thistle
#

Correct

#

Also remember role hierarchy

plucky heart
#
      console.log(`User with ID ${vote.user} just voted!`);
        let embed = new Discord.RichEmbed()
            .setColor(`#5780cd`)
            .setAuthor(`<@${vote.user}> Upvote !`)
            .setTimestamp()
            .addField(`User ${vote.user} With ID ${vote.user} Just Upvote For my Bot `, `He UpVote in https://top.gg/bot/688364176305029132 `)
            .addField(`We Have ${vote.count} UpVotes `, `Thanks You Soo Much`)

let guild = Client.guilds.cache.get(`698495495236223026`);
Client.channels.cache.get(`698648416825245777`).send(embed);
});```

```(node:7724) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined```
balmy knoll
#

How do I disconnect a user from a voice channel in discord.js?

spare goblet
#

@plucky heart which ver are you on

plucky heart
#

npm discord.js --version
6.13.7

heavy marsh
#

Then you dont need .cache if I am correct

true ravine
#

I'm surprised v6 would still work

#

I assumed they'd stop you using very old versions

summer torrent
#

@balmy knoll setVoiceChannel(null)

quartz kindle
#

thats the npm version

earnest phoenix
#

v6 doesnt work

quartz kindle
#

not discord.js version

earnest phoenix
#

^^

quartz kindle
#

to get a package version you use npm ls discord.js

#

@plucky heart .cache only exists in v12, not in v11

#

you're probably using v11, as you're using RichEmbed, which only exists in v11

balmy knoll
#

@summer torrent Thanks. How can I check if the user whose ID I know is connected to a specific voice channel?

summer torrent
#

what is your discord js version

#

@balmy knoll

plucky heart
#

I updated to discord.js@12.1.1 and console shows

                                              ^

TypeError: member.guild.roles.find is not a function
summer torrent
#

roles.cache.find

balmy knoll
#

@summer torrent 12.1.1

summer torrent
#
<GuildMember>.voice.channel```
balmy knoll
#

@summer torrent And this return me the channel ID?

summer torrent
#

channel object

balmy knoll
#

Ok

#

Thanks a lot

summer torrent
#

np

balmy knoll
#

@summer torrent I have got this error: TypeError: Cannot read property 'channel' of undefined

summer torrent
#

maybe your "member" is not connected to any voice channel

balmy knoll
#

@summer torrent No, i'm testing it and i'm connected

summer torrent
#

show your code

quartz kindle
#

@plucky heart if you updated to v12 then there are a LOT of things you will need to change

balmy knoll
#

Yes

#

@summer torrent

            if (user.voice.channel.id == "698608221275029590")
            {
                // Manageable User Check
                if(!user.manageable)
                {
                    // Unable to kick the user
                    var unableEmbed = new Discord.MessageEmbed()
                    .setColor("RED")
                    .setDescription(
                    `:exclamation: **Non riesco ad espellere <@${user.id}> dal canale vocale.**`
                    );
                    message.channel.send(unableEmbed);
                } else {
                    // Kick the user
                    user.setVoiceChannel(null);
                    message.react("✅");
                }
            } else {
                message.channel.send(notconnectedEmbed);
            }
summer torrent
#

what is "user"

balmy knoll
#

(Sorry for the message, i'm italian)

#

@summer torrent const user = message.mentions.users.first();

quartz kindle
#

users dont have voice, members do

summer torrent
#
<GuildMember>.voice.channel```
#

change that to members.first()

balmy knoll
#

@summer torrent Wait... I don't understand. Where have i to replace user with member?

summer torrent
#

@summer torrent const user = message.mentions.users.first();
@balmy knoll

#

replace users with members

#

User object don't have voice

balmy knoll
#

I try

#

Ok, i tried it. It works

plucky heart
#
                    ^

TypeError: fn.bind is not a function```
what?
summer torrent
#

update node js

quartz kindle
#

discord.js v12 requires node.js v12 or higher

heavy marsh
#

I am using discord.js - v12.1.1
I am trying to get an invite from a guild the bot is on.
https://hasteb.in/ebetudow.coffeescript

But it keeps on saying the bot is not in that guild when it is in it....

plucky heart
#

I updated the node js and still the same

summer torrent
#

updated to which version

quartz kindle
#

@heavy marsh you are declaring invitechannels inside broadcastEval, then trying to use it outside of it

#

that wont work

plucky heart
#
+ node.js@0.0.1-security
added 1 package and audited 12225 packages in 5.092s

5 packages are looking for funding
  run `npm fund` for details
quartz kindle
#

no...

#

node.js is not a package

plucky heart
#

oh

quartz kindle
#

node.js is the environment

heavy marsh
#

ooh ...

quartz kindle
#

where the program runs in

#

do node -v

plucky heart
#

Oh, im stupid

#

v13.11.0

summer torrent
quartz kindle
#

then its already updated

plucky heart
#

but the console still shows

                    ^

TypeError: fn.bind is not a function```
heavy marsh
quartz kindle
#

your error is likely caused by trying to use .find("key","value") which was deprecated a long time ago and is not supported, and finally removed recently

plucky heart
#

What to do with this error?

quartz kindle
#

everything you need is there

balmy knoll
#

@summer torrentHelp me again 😄. I use user.setVoiceChannel(null); to disconnect an user from a voice channel, but i have got an error: TypeError: user.setVoiceChannel is not a function.

summer torrent
#

lemme check docs

amber fractal
summer torrent
#

<GuildMember>.voice.setChannel

balmy knoll
#

@summer torrent @amber fractal Thanks

summer torrent
#

np

ocean sky
#

Hi who can help me set my DC server API kay?

elder vine
#

What key?

ocean sky
#

Just Discord server API

quartz kindle
ocean sky
#

I need because i runned RUst game server and i want connect

elder vine
#

Webhooks?

ocean sky
#

No just webhooks,plugin want api kay nad guild id and much more

#

all have but api no

#

Tim i visited yes

quartz kindle
#

everything you need to know is there

#

including how to get your api key

ocean sky
#

i chack again

quartz kindle
ocean sky
#

Okay Try follow and make

#

Ty

elder vine
#

Oh, you mean a bot api key.

ocean sky
#

Yes 😄

elder vine
#

I was like, "what sever api key, this I need to know" xD

ocean sky
#

😄

earnest phoenix
#

am i just fucked if a feature i want to implement requires a new permission?

#

or can i prompt existing servers to update the bot perms?

elder vine
#

You can just ask if they have a missing permission.

#

just add to the needed command to make a if the bot doesn't have enough permission; and ask them to add the permission.

earnest phoenix
#

what do you mean by ask?

#

can you prompt a popup or something

#

or are you talking about automating a dm to the server owner asking them to reinvite the bot?

elder vine
#

No.

#

For what reason is the permission required?

earnest phoenix
#

was more a general question

#

not thinking of a specific permission

elder vine
#

Well, you could always ask users for updating the permission if they have role/ permission which can do so.

#

So no, you're not doomed.

quartz kindle
#

just check for the permission when the feature is used, and if it doesnt have, show an error saying that it requires it

earnest phoenix
#

hmm okay

#

then they'll manually have to set it

elder vine
#

Yes.

robust moth
summer torrent
#

we can't understand anything from video

elder vine
#

What's the issue?

gilded plankBOT
#

If you want people to be able to assist you, please provide more information, such as what library and language you're using, the code in question and what you are trying to do and/or what is causing the error.

crimson vapor
#

which sweaty mod did that?

nocturne dagger
#

🙂

summer torrent
#

Ted

crimson vapor
#

you are trying too hard

#

no need to simp for mod

knotty steeple
#

lul he is doing his job

viral spade
#

will my vps provider ban me soon like this?
CPU is jumping between 50 % and 200% for both containers

topaz fjord
#

gets mad at mod for doing his/her job

#

classic dbl

robust moth
#

@summer torrent when I mention my bot in server 1 then bot reply prefix bdr(default "bdr") but when I mention my bot in server 2 then first time reply prefix bdr (default"m") and second time reply prefix m

topaz fjord
#

reveal yourself shivaco

elder vine
#

What's the code Mr. Who?

robust moth
#

@elder vine

  let user = message.mentions.users.first();
  let bot = message.client.user;
  
  //let client = message.client
 // console.log(user, bot, client);
  if (user === bot) {
  let embed = new discord.MessageEmbed()
	.setColor("RANDOM")
	.setTitle(`ℹ️ My Current Prefix Is \`[${message.client.prefix}]\`\n Use \`[${message.client.prefix}help]\` To See All Commands`)
    return message.channel.send(embed).catch(console.error)
  }
};```
elder vine
#

Does it use custom prefix?

robust moth
#

@elder vine yes

crimson vapor
#

because you are using message.client.prefix, it will be the same prefix for every guild

elder vine
#

client.prefix.get("guildid").prefix maybe?

#

I don't know how you've stored it.

frigid sierra
#

does discord.js cache guilds like that?

crimson vapor
#

that would work if you never reset the bot

#

what do you mean cache guilds like that?

elder vine
#

No, if you store it in a Collection (array) you could do that. But it wont save after restart of bot

frigid sierra
#

yeah, you need some type of database system to store configuration for guilds

crimson vapor
#

yeah

frigid sierra
#

i wouldn't assume it returns the same object when you call get unless it literally caches every guild object it sees

crimson vapor
#

if you are only storing preifx, you could use a json because it would be small

elder vine
#

Or just get right in the use of something like MongoDB - which is free as well.

robust moth
frigid sierra
#

if you're just doing prefixes or other small amounts of data, i'd recommend some simple protocol like JSON for saving basic config

elder vine
#

Oh, you use json

viral spade
#

will my vps provider ban me soon like this?
CPU is jumping between 50 % and 200% for both containers

robust moth
#

@elder vine yeap

crimson vapor
#

no, dont do that Mr. Who

elder vine
#

It depends on your provider @viral spade - but they shouldn't, however they will most likely ask you to upgrade your VPS.

modest maple
#

I would only use JSON if its static data

crimson vapor
#

you are loading client.prefixes every message

#

waste of memory

viral spade
#

@elder vine ok, but does it mean this cpu will not be able to handle more servers?

knotty steeple
#

dont use json for anything beside static data

#

i would use sqlite if i only store prefixes

crimson vapor
#

you can read the file and only store the value for the guildid

knotty steeple
#

idk about light minimal nosql dbs

robust moth
#

@knotty steeple it's tested

knotty steeple
#

what is

#

json is bad as a dynamic db

elder vine
#

How many servers is it in?

#

Have you sharded? Are many people using it? Linck01

crimson vapor
#

if you only need to store less than 100 prefixes, you should be fine

frigid sierra
#

@knotty steeple it's fine if you're just storing a few really simple config options

robust moth
#

@elder vine 3

crimson vapor
#

but I do agree with everyone as it should only be used for more static data

knotty steeple
#

i cant agree with that GWvictoriaBolb

frigid sierra
#

it's not entirely worth setting up an entire database if you're just going to store custom prefixes by server

crimson vapor
#

yeah

modest maple
#

in general no

elder vine
#

What's the issue @jovial finch ?

knotty steeple
#

thats why i said sqlite

#

which is just a file

modest maple
#

JSON is Not for dynamic data and shouldnt be used for it

#

a simple sqlite db takes seconds to make

viral spade
#

@elder vine The bot is in 14k servers.

knotty steeple
#

yea it does

#

its not like mysql installing it to the os itself

elder vine
#

Well, then you maybe should look to upgrade your CPU.

#

Which VPS provider are you currently using?

viral spade
#

contabo

elder vine
#

How much you currently paying monthly, if I may ask?

viral spade
#

30

elder vine
#

And how much are you running on, like CPU power and RAM etc.?

frigid sierra
#

i'm personally against SQL so i wouldn't use it, but if it's that easy to set it up, then might as well use it

viral spade
#

i was think about getting a dedicated 45 euro/month hetzner

knotty steeple
#

whats ur specs

elder vine
#

Yea, specs for the VPS.

viral spade
#

i am running 10core 64gb

#

on contabo

elder vine
#

Then you might just gotta look for some improvements in the code.

quartz kindle
#

how many shards?

elder vine
#

Is the bot very CPU intensive itself, per guild?

viral spade
#

too many shards for the amount servers. i just increased to 25

elder vine
#

How many shards per server?

viral spade
#

yes it is cpu intensive

crimson vapor
#

what does the bot do?

viral spade
#

i keep it between like 700 and 1000 guilds per shard

quartz kindle
#

do you need presence updates?

viral spade
#

yesi need, it does statistics

quartz kindle
#

well rip

elder vine
#

Is it needed tho?

quartz kindle
#

which library?

viral spade
#

discord.js

quartz kindle
#

did you install zlib-sync?

viral spade
#

no doesnt say anything to me

knotty steeple
#

whats that do

quartz kindle
#

install zlib-sync

viral spade
#

node module?

quartz kindle
#

yes

viral spade
#

ok let me read about it a sec

quartz kindle
#

you might also want erlpack, bufferutil and utf-8-validate

#

all those libraries increase performance by offloading heavy-computing operations to native C code instead of javascript

#

especially zlib-sync

#

you can expect about 50% less cpu usage after installing those

viral spade
#

interesting

crimson vapor
#

ooo

viral spade
#

i dont understand how to "attach" the module to my bot

quartz kindle
#

discord.js looks for it automatically, and uses a fallback if not found

viral spade
#

oh nice

elder vine
#

Oh, cool.

summer torrent
#

sodium is so big

#

~9 MB

viral spade
#

So how can i know how loaded my cpu really is? i mean those values ranging over 200% dont really tell me at what % am actually at

quartz kindle
#

you need to monitor cpu usage over time

#

idk what kind of containers you're using, but stuff like pm2 can monitor a process's cpu usage

#

also stuff like top/htop

knotty steeple
#

well time to get those packages

viral spade
#

i think pm2 on top of containers is overkill, no?

knotty steeple
#

native c code for performance 😩 👌

quartz kindle
#

probably

#

there's probably something specific for monitoring the containers

summer torrent
#

pm2 monit

viral spade
#

well what i showed you is the docker stats command

craggy cave
#

pm2 is good even with python.

quartz kindle
#

does it update in real time?

craggy cave
#

yes

quartz kindle
#

or just shows you a snapshot?

viral spade
#

yes approx once per sec

craggy cave
#

real time and there's also a web browser for you remotely if you wish to control it.

quartz kindle
#

then i guess you will just see how far does it jump up and down lol

#

you said between 50% and 150% right?

viral spade
#

sometimes its 300%

quartz kindle
#

jeez lmao

#

well, i think there will be enough of a difference to be noticeable

viral spade
#

average is definately above 100%

quartz kindle
#

the average numbers you'll see

#

other than that, you'd probably need to use a proper resource monitoring system

#

with graphs and shit

viral spade
#

do you think will this problem also be reduced by a dedicated machine?

#

like compared in the power/cost relation

quartz kindle
#

well, the good old "throw more hardware at it" will probably work, but its not really the most effective way

viral spade
#

i mean thats why i said in terms of power/cost

amber fractal
#

Nah vertical scaling best scaling mmLol

quartz kindle
#

in the long run, working on optimizing performance will give you better results

viral spade
#

these optimization i can do in any case, ayn time

quartz kindle
#

although the biggest performance cost is by far presence packets lol

#

does your bot do music/audio?

elder vine
#

I think it's an activity bot.

viral spade
quartz kindle
#

you could use intents to disable stuff you dont need, such as typing updates, but that wont make too much of a difference i guess, presence updates are 10 times more frequent

#

but give zlib-sync a try and see how it goes

viral spade
#

So my thinking is:
I have a 30€/m 64gb machine, while the bot needs 20gb (this can also be reduced, i know) for its current 14k servers.

so, in any case, however big i upgrade my hardware, i will have not enough cpu power and too much memory. Even with 50% less cpu power needed, the relation between cpu and memory usage does still not fit the vps.

So i was wondering if a dedicated 45€/m 64gb machine will give me a better cost per server, because of more fitting relation between cpu and ram for my program?

trim nexus
#

sorry, is that 20gb of ram?

viral spade
#

yes

modest maple
#

holy fuck dude

trim nexus
#

damn that's a lot for 14k servers

royal portal
#

anyone know how to make the bot send custom emojis

#

discord.js

modest maple
#

Spotify is in 52k and uses 5GB unoptimised

elder vine
#

Just use \ :emoji:

#

without space, and copy that into the message.

summer torrent
#

@royal portal just send Emoji object

modest maple
#

@royal portal all custom emojis fall under the !002_angry layout

summer torrent
#

or ^

royal portal
#

so i just type that

modest maple
royal portal
#

and it will do it

modest maple
#

yup

royal portal
#

yeah

modest maple
#

as a string

royal portal
#

a string?

quartz kindle
#

@viral spade you could look into high-cpu machines, but they are much more expensive

#

cpu cost is much higher than ram cost

elder vine
#

You can type \:emoji: in chat to get it.

modest maple
#

That is just insane usage tho

quartz kindle
#

a dedicated machine can also be an option if it has 24/32 cores or more

modest maple
#

like there has gotta be some major ram leaks

viral spade
#

the 14k servers use 7gb of ram after 2 hours of running. the 20gb is the amount i need to let both the bot and the database run + it should be able to run a long time and have even more ram than it needs to account for spikes. so my machine should have 20gb for my 14k servers, but the bot itself need less

quartz kindle
#

its just discord.js being discord.js

modest maple
#

why 7GB after two hours

#

that is insane

quartz kindle
#

gotta cache everything

viral spade
#

i rises to 12gb after a day or so

earnest phoenix
#

Who can give me bot infrastructure

viral spade
#

but memory is not my probel. only cpu

modest maple
#

You gotta have some massive ram leak or somthing

#

why do you need to much

royal portal
#

wait so i dont put the emoji in " " ?

modest maple
#

you do

trim nexus
#

gotta cache everything
gotta cache 'em all

quartz kindle
#

^

royal portal
#

i tried doing it

#

it just said :tick:

trim nexus
earnest phoenix
#

sa

trim nexus
#

can't say tick if you do it this way

earnest phoenix
#

hello

#

everyone

royal portal
#

thats cool

#

:animatedtick1:

#

oof

#

no nitro

trim nexus
#

sad

royal portal
#

bots get free nitro

earnest phoenix
#

u and me cry @royal portal

modest maple
#

not really

earnest phoenix
#

:/

modest maple
#

they only really get the emoji thing

viral spade
#

if i double the amount of shard for the same amount of servers, does it take considerably more cpu power or is it just a little overhead?

modest maple
#

everything else is zipp

#

@viral spade depends

viral spade
#

assuming the bot only does responsive thing on events

modest maple
#

i cant imaging taking litterally double the amount

#

but it will be noticable

royal portal
#

still doesnt work

#

.setDescription("<a:animatedtic k1:661900429432455187> Restarted.")

#

ignore the space

#

is it because it needs `?

ember atlas
#

Are there any errors? @royal portal

royal portal
#

nope

frail ocean
#

Since if I post:

#

<a:animatedtic k1:661900429432455187>

#

It isn't an emoji, right?

royal portal
#

well

#

not in the server

frail ocean
#

You need to use the client to get the emoji's, store it in a variable and then reference it in the message.

quartz kindle
#

@viral spade any number of shards above core count will increase overhead due to context swapping

#

ideally you should have core count -1 shards

modest maple
#

@quartz kindle you mean clusters?

quartz kindle
#

but in the real world nobody uses that because discord shards way too much

#

@modest maple i mean shards per cpu cores

modest maple
#

Dyno with its 3000 core server

#

xd

quartz kindle
#

exactly

modest maple
#

and ah yeh

quartz kindle
#

most large bots most likely use anywhere from 2-16 shards per core lol

#

the most efficient ones will use a combination of internal sharding with processes

royal portal
#

client.emojis.get doesnt work

frail ocean
#

What version are you using?

royal portal
#

v12

blazing portal
#

you need da cache

frail ocean
#

^

#

Isn't it something like client.emojis.cache.get

blazing portal
#

yup

frail ocean
#

Not 100% sure, still running 11.1.1 for myself.

#

Since I don't wanna transition and have to move again with all the new bot stuff in the future.

#

So whilst it's stable I'll leave my code.

royal portal
#

not working for me

#

i have const tick = client.emojis.cache.get("id")

#

and then in my message i have

#

${tick}

viral spade
#

Thank you very much tim!
But if less shards is good for performance, why is it generally sharded into 1000 guild per shard? why not exploit the process and use the (almost) full 2500?

frail ocean
#

@royal portal What is the actual message line code.

royal portal
#
if (command === "restart") {
   
   const tick = client.emojis.cache.get("661900429432455187");
  const embed = new Discord.MessageEmbed()
  .setDescription(`${tick} Restarted.`)
  .setColor(0x00AE86)
blazing portal
#

are you sending the embed?

royal portal
#

yes

#

thats just a piece of it

cinder patio
#

Tim, how does one use internal sharding with discord.js?

royal portal
#

it just sends undefined

quartz kindle
#

@viral spade for growth management, more time without having to restart to change the shard number. also large bots require shard number to be multiples of 16

turbid bough
#

i have an issue with embeds right now, where on android the mentioned users are invalid users, but when i look it up on my pc, the usernames show up

quartz kindle
#

@cinder patio define the shards you wish to run in the client options (v12 only)

turbid bough
#

same message

quartz kindle
#

nothing you can do about that

#

its discord's fault i guess

royal portal
#

Tim would I use var instead of const

quartz kindle
#

are you mentioning them as <@id> or <@!id> ?

turbid bough
#

<@id> i think

quartz kindle
#

you could try the other variant, but the result will most likely be the same

late hill
#

You see whatevers cached

quartz kindle
#

@royal portal var or const has nothing to do with it

#

if you're getting an undefined emoji, then the emoji was not found

royal portal
#

but the emoji works

quartz kindle
#

then what is undefined?

royal portal
#

the emoji

#

but im not sure why

quartz kindle
#

then it was not found

turbid bough
#

ah nvm, im using discordUser.mention

quartz kindle
#

is your bot in the server where the emoji comes from?

blazing portal
#

either it works, or its undefined 😄

#

console.log the emoji before sending the embed to see if it gets the emoji

royal portal
#

nope

#

the emoji is from here

#

a tick emoji

blazing portal
#

"nope" means it doesn't get it?

royal portal
#

yes it doesnt

viral spade
#

Tim, you said larger bots need to be a multiple of 16. may i ask where does this come from?

#

and should i increase my 25 to 32 shards?

modest maple
#

You ideally want 1000 guilds per shard

blazing portal
#

@royal portal if you are talking about this emoji tickYes then you are using the wrong id

turbid bough
#

@quartz kindle same result unfortunately

earnest phoenix
#

it doesn't matter which mention you use

#

the user isn't in the client cache

#

you can't do anything about it

royal portal
#

whats the id

#

315009125694177281

#

i tried using the animated one too

#

didnt work

quartz kindle
#

they changed it to "multiple of a fixed number we will give you"

viral spade
#

oh i see. thanks

blazing portal
#

yes that's the id, but in your code you posted you used a different one

royal portal
#

i tried both

slow cape
#

Are we allowed to ask for help

amber fractal
#

nope, not allowed.

#

ofc you are

#

just ask

blazing portal
#

Check the Channel topic.

slow cape
#
if(message.content.startsWith(`${p}mute`)) {
    if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send("You do not have manage messages.")

    let toMute = message.guild.member(message.mentions.users.first()) || message.guild.member(args[0]);
    if(!toMute) return message.channel.sendMessage("You didn't specify a user!");
    if(toMute.id === message.author.id) return message.channel.sendMessage("You can't mute yourself.");
    if(toMute.roles.highest.position >= message.member.roles.highest.position) return message.channel.sendMessage("You cannot mute a member that has a higher or same role as you.")

    let role = message.guild.roles.cache.find(r => r.name === "FrontierMuted");

     if(!role) {
       try {
           role = await message.guild.roles.create({
               name: "FrontierMuted",
               color: "#000000",
               permissions: []
           });

           message.guild.channels.cache.forEach(async (channel, id) => {
               await channel.overwritePermissions([
                {
                   id: message.author.id,
                   deny: ['SEND_MESSAGES', `ADD_REACTIONS`],
                },
              ], 'Needed to change permissions');
           })
       } catch(e) {
           console.log(e.stack)
       }
    }
    if(toMute.roles.cache.has(role.id)) return message.channel.send("This member is already muted!")

    await toMute.roles.add(role);
    message.channel.send("I have muted them.")
    return;
   }
#

So for this command

#

For some reason

#

It just creates a new role

#

And adds it

#

But it doesn’t do anything

blazing portal
#

can you add js to the first row, so its "```js"

slow cape
#

Did it

#

Now

blazing portal
#

can you console.log(role) right after the let role = ... and tell me what it says?

earnest phoenix
#

Hello im trying to list all users my bot want to list**, but the problem is im just doing a for each users :
newclient.users.cache.array().forEach((member) => {})
So i can't check if the user that i DM is administrator, i would like to do
For each Guild -> For each member, then i can check informations about the user from the server

quartz kindle
#

you should probably use a for loop instead of forEach, as the above code will likely get you rate limited

#

@earnest phoenix you want to see who are guild administrators?

earnest phoenix
#

I want to dm all admins of guilds

#

About news of the server

knotty steeple
#

just dont

quartz kindle
#

you should not mass DM people

slender thistle
#

I suggest you create a separate channel and mention everyone there instead of mass DMing

earnest phoenix
#

Its not massDming

#

Its just admins of the servers

quartz kindle
#

shiv u a trialist lmao

earnest phoenix
#

its about 15 members 😂

amber fractal
#

that's a mass dm

turbid bough
#

"i want to dm all"
"im not mass dm'ing"

slender thistle
#

But you are still sending multiple DMs at once pogey

earnest phoenix
#

But its not that consequent

#

also sendt by the server owner 🤷

quartz kindle
#

if its a command executed by the server owner to DM server admins, should be fine i guess

slender thistle
#

Well consent or not, I mean...
you can have 200 admins and you'll be sending DMs to all of them thinkW

quartz kindle
#

but only admins inside that guild

blazing portal
#

if people are not in your support server they are likely not interested in the news?

turbid bough
#

rate limit

earnest phoenix
#

@slender thistle then u should think about checking ur server admins

#

U can't get rate limited for 30 dms

#

Also it will have a cool down

#

Im obviously not that stupid

turbid bough
#

yes

earnest phoenix
#

Don't want to send 35dm per seconds

slender thistle
#

I suggest you play it safe tbf

turbid bough
#

why would you want to dm all admins anyway?

amber fractal
#

you can get rate limited for 30 dms

#

it's 5/5

turbid bough
#

just create a new channel lol

quartz kindle
#

5/5 per channel, not sure how's with dms, since each dm is a different channel

turbid bough
#

thats what servers are for

earnest phoenix
#

Its about my projct, elsei would just create a new channel obviously its not what i asked winky

quartz kindle
#

anyway

turbid bough
#

i still dont understand your project of dm'ing all of your server mods

quartz kindle
#

you can loop over guild members, and check if they have admin permissions

turbid bough
#

that would require server members intent

earnest phoenix
#

yeah i know but i didn't used discordjs for a long time and v12 changed everything, so i don't know how to foreach guild members

amber fractal
#

as that is old

quartz kindle
#

thats old tho

amber fractal
#

but used to be

quartz kindle
#

im pretty sure the 5/5 is now per channel, not per server

#

let admins = guild.members.cache.filter(member => member.hasPermission("ADMINISTRATOR"))

#

@earnest phoenix

#

will only work for online/cached members anyway

earnest phoenix
#

Why only online ?

#

I didn't understand also the cached thing 😉

#

Can u explain me that as ur here

turbid bough
#

probably cause member intents?

quartz kindle
#

not all members are cached

#

if a guild has 200k members, your bot will not have 200k members cached by default, because it uses too much memory

#

guilds cache online members and active members

turbid bough
#

oor, you could manually add administrators to a list, and dm that list

earnest phoenix
#

I mean the Tim method looks fine

quartz kindle
#

non-cached members are not listed anywhere in your bot program and are not accessible directly

#

offline/uncached members have to be explicitly requested by using guild.members.fetch(id)

wheat jolt
#

how many times I am allowed to change my bot's activity per minute?

summer torrent
#

5

wheat jolt
#

ah, ok

#

thanks

turbid bough
#

well, if all your moderators are offline, that means noone will get the message right?

summer torrent
quartz kindle
#

@earnest phoenix caching means storing a temporary copy to make things faster and more efficient

#

so when discord sends you a message, it also sends you the information of the user/member who send the message

#

discord.js then caches this information, it stores the user and member data

#

for later use

turbid bough
#

does discord also cache invisible users too?

quartz kindle
#

and keeps this data updated, so you dont need to ask discord for this data

earnest phoenix
#

@turbid bough probably not because would make able developpers to like
If offline member is in cache

#

then he is in invisible

#

would fuck the point of the invisible mode 😂

quartz kindle
#

@turbid bough it caches users that make any kind of activity

#

if you receive a piece of data that contains some user information, that user will be cached

turbid bough
#

aight, thats cool to know

quartz kindle
#

user information is present in many types of data packets

#

such as typing

earnest phoenix
#

I see so if i use non caching method, it won't affect that much my program ? My server wont be scared of that 😂

turbid bough
#

wat

#

btw, is the only way to retrieve member list only trough cache now?

quartz kindle
#

all methods that are in .cache interact with the cache, which is the local copy of things your program is storing

#

interacting with those has no rate limits and is very fast

#

since its all inside the program

turbid bough
#

ooh, client cache

#

not from the server

quartz kindle
#

anything else that is not in the cache, such as fetching members/users/messages, goes through the discord server, which implies rate limits

earnest phoenix
#
newclient.guilds.cache.array().forEach((guild) => {
guild.members.cache.array().forEach((member) => {

})
})
#

Is this using all members on the servers ?

#

Or its cached ?

#

Yeah im stupid its cached lol

#

"cache" as said im so stupid

turbid bough
#

cache

quartz kindle
#

you dont need to use .array()

#

you can use .forEach directly on the cache

turbid bough
#

soo, since im using c#, i dont really see any cache variables

#

i wonder if it does that automaticly

quartz kindle
#

different libraries use different names and storage designs

#

most likely it does have some sort of caching

earnest phoenix
#

Tim so do you have the exact alternative as i have to not have caching and then being able to contact all server administrators

#

Also i can't use filter because i don't only want to check if the user is admin

slow cape
#

can you console.log(role) right after the let role = ... and tell me what it says?
@blazing portal it says undefined

earnest phoenix
#

I would like to foreach then execute multiples infios

turbid bough
#

manually add admins to a list, and pm that list

quartz kindle
#

the only way is to keep your own list of admins stored somewhere

earnest phoenix
#

But im not only checking for admins

#

Because im also updating an "VIP LIST"

turbid bough
#

ok, then add them too

quartz kindle
#

then keep your own list for both

earnest phoenix
#

LoL

#

Alright 😂

#

But the code u gave me before does use cache right ?

turbid bough
#

what code did you give?

earnest phoenix
#

TimAujourd’hui à 20:33
im pretty sure the 5/5 is now per channel, not per server
let admins = guild.members.cache.filter(member => member.hasPermission("ADMINISTRATOR"))

#

So there is technicly no simple way

turbid bough
#

yes, that one uses the cache

balmy knoll
#

In discord.js, how to move a category?

summer torrent
#

setPosition

heavy marsh
#
if (!args[1]) return [utils.timed_msg(utils.cmd_fail(`No guild ID has been mentioned!\n**Usage:** \`${prefix}rem serinv 611809972707131403\``), 5000),];

bot.shard.broadcastEval(`
const servers = this.guilds.cache.get('${args[1]}');

if (servers) {
true;

} else {
false;

} `).then(sentArray => {
if (!sentArray.includes(true)) {
return message.channel.send('![cross](https://cdn.discordapp.com/emojis/678626371110567973.webp?size=128 "cross") **No guild could be found with that ID!**');
}

const guild = bot.guilds.cache.get(args[1]);
let invitechannels = guild.channels.cache.filter(c => c.permissionsFor(guild.me).has(`CREATE_INSTANT_INVITE`));
if (invitechannels.size < 1) return message.channel.send('![cross](https://cdn.discordapp.com/emojis/678626371110567973.webp?size=128 "cross") **No Channels found with permissions to create Invite in!**');

invitechannels.random().createInvite(options).then(invite => message.channel.send(`**Found Invite:**\nhttps://discord.gg/${invite.code}`));
});

Is this a working code for a guild in a diffrent shard?

balmy knoll
#

@summer torrent Always thanks

heavy marsh
#

Dont tell me try it ....
It works for the same shard just wanted to know if it would work on a different shard?

summer torrent
#

broadcastEval evaluates a code or function on all shards

heavy marsh
#

So this will be a 100% for a server on a different shard?

summer torrent
#

yes

heavy marsh
#

Let me try it with 2 shards then

#

thanks you

quartz kindle
#

no it will not work

heavy marsh
#

👀

quartz kindle
#

const guild = bot.guilds.cache.get(args[1]); will not exist in the current shard if it exists in another shard

summer torrent
#

👀

quartz kindle
#

i believe i told you before, you need to create the invite inside the broadcastEval

#

and return the invite code

summer torrent
#

What means <Array<*>>

quartz kindle
#

probably array of values that can be of any type

heavy marsh
#

When I do this ...

if (!args[1]) return [utils.timed_msg(utils.cmd_fail(`No guild ID has been mentioned!\n**Usage:** \`${prefix}rem serinv 611809972707131403\``), 5000),];

bot.shard.broadcastEval(`
const servers = this.guilds.cache.get('${args[1]}');

if (servers) {
let invitechannels = guild.channels.cache.filter(c => c.permissionsFor(guild.me).has('CREATE_INSTANT_INVITE'));
if (invitechannels.size < 1) return message.channel.send('![cross](https://cdn.discordapp.com/emojis/678626371110567973.webp?size=128 "cross") **No Channels found with permissions to create Invite in!**');

invitechannels.random().createInvite(options).then(invite => message.channel.send('**Found Invite:**\nhttps://discord.gg/${invite.code}'));
true;

} else {
false;

} `).then(sentArray => {
if (!sentArray.includes(true)) {
return message.channel.send('![cross](https://cdn.discordapp.com/emojis/678626371110567973.webp?size=128 "cross") **No guild could be found with that ID!**');
}

return;
});```
Tells me invite not defined
trim nexus
#

what's the purpose of this code

#

why do you need to broadcast eval invite generation

heavy marsh
#

To get an invite for an x server

amber fractal
#

this is precisely why I don't allow bots to have invite generation

heavy marsh
#

Well mine i am working on a bump bot

quartz kindle
#

i was writing a sample piece of code for you, and i found out another problem

#

does broadcastEval even support promises?

#

i dont think so

heavy marsh
earnest phoenix
#
(node:15) UnhandledPromiseRejectionWarning: RangeError: Invalid permission string or number.
at Function.resolve (/home/container/node_modules/discord.js/src/util/Permissions.js:195:65)
at RESTMethods.createGuildRole (/home/container/node_modules/discord.js/src/client/rest/RESTMethods.js:438:58)
at Guild.createRole (/home/container/node_modules/discord.js/src/structures/Guild.js:1152:37)
at Object.execute (/home/container/commands/Moderation/muterole.js:38:32)
at Client.<anonymous> (/home/container/index.js:132:13)
at Client.emit (events.js:323:22)
at MessageCreateHandler.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
(node:15) 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:15) [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.

I got this error with this code:

#
const success = new Discord.RichEmbed()
        .setTitle(':white_check_mark:')
        .setDescription('Successfully made a role named Muted.')
        .setColor('#00ff00');
        
        if(!message.guild.me.hasPermission("MANAGE_ROLES_OR_PERMISSIONS")){
            return message.channel.send(nobotMR).then(m=>m.delete(10 * 1000));
        }
        if(!message.member.hasPermission("MANAGE_ROLES_OR_PERMISSIONS")){
            return message.channel.send(nouserMR).then(m=>m.delete(10 * 1000));
        }
        if(message.guild.roles.find("name","Muted")){
            return message.channel.send(alreadyarole).then(m=>m.delete(10 * 1000));
        }
        var rl = message.guild.createRole({ name: 'Muted', permissions:{
            "SEND_MESSAGES": false
        }}).then(
            message.channel.send(success).then(m=>m.delete(10 * 1000))
        );
        message.guild.channels.forEach(c=>{
            channel.overwritePermissions(rl, { SEND_MESSAGES: false });
        })
#

I tried changing SEND_MESSAGES to a string but I got the same error. How should I go about fixing this?

summer torrent
#

MANAGE_ROLES_OR_PERMISSIONS is not a permission flag

earnest phoenix
#

I also tried MANAGE_ROLES

#

same error

summer torrent
amber sigil
#

damn, you beat me to it

quartz kindle
#

@heavy marsh i guess it does then, interesting