#development

1 messages · Page 855 of 1

charred jetty
#

Ok check it then

#

@earnest phoenix @finite bough

#

Lemme check it too

cinder patio
#

It's definitely using a webhook, you can change a webhook's name and avatar for every message

fallow quiver
#

Ok, I'm trying to write a function that gets parts of a string based on start and end values. Here is what I have so far:

function getStringPart(string, start, end) {
    var r_string = {};
    for(i = start; i < end; i++) {
        r_string[i] = string[i];
    }
    return r_string;
}

In stead of returning a string it returns something that resembles a C++ Map container. I don't really know JS well or how it handles strings so if anyone knows a better way to do this.

cinder patio
#

you can use regex? Can you give an example of what you are trying to do

fallow quiver
#

Something like grab arguments for a command

#

So

#

-send [channel id] [message]

cinder patio
#

you are returning an object (r_string is an object)

fallow quiver
#

Is there a way to get it as a string?

#

would something like to_string() work in this instance?

late hill
#

For the example you gave, you can do what most people do which is splitting on spaces

fallow quiver
#

Wouldn't that split the message too?

late hill
#

yeh but you see

quartz kindle
#

@fallow quiver you're trying to get a substring based on start/end indexes?

fallow quiver
#

Yeah

late hill
#

the other 2 values are always going to be 1 "word"

quartz kindle
#

you can simply use string.slice() or string.substring() or string.substr()

late hill
#

so you can simply join the rest back together

hollow token
#

Hi, does someone use sequelize as db?

cinder patio
#

I do

fallow quiver
#

Could I also use commas as separation characters instead of whitespace?

cinder patio
#

Sequelize is something like a wrapper for a bunch of databases actually

#

yeah you can

hollow token
#

yeah I know, I just mean that

quartz kindle
#

you can delimit a string with any character or pattern using string.split("char")

hollow token
#

I made a level system but the problem is that it's not unique for the server

fallow quiver
#

Ok, I'll look into it, thanks

quartz kindle
#

that will give you an array/list, not a string

hollow token
#

If my name is jhon and the rank in this server is 5, the rank of jhon is 5 also in other server

#

and obv also for others "jhon"

#

how do you handle that?

#

i thought about an hashMap

quartz kindle
#

you need to make a separate ranking for each guild

hollow token
#

yeah I know

cinder patio
#

yeah, does your user table have a row where you store guild ids?

hollow token
#

nope

#

thats why

cinder patio
#

yup, it's global

hollow token
#

I totally forgot about that

#

I have to do that

finite bough
#

global can be pretty handy sometimes

#

coz server levelings are annoying when u are like lvl 50 and u get banned, or server oofed

hollow token
#

mmm honestly i don't find it a usefull feauture

#

yes but maybe you have the same name of another person

#

in another server

#

and this create conflict

quartz kindle
#

rankings should never be based on names

#

they should be based on user IDs

hollow token
#

good to know, this is easy to change

#

I did it based on the name

finite bough
#

if u are doing names

pallid marsh
#
       $('#save').on('submit', function(e) {
          e.preventDefault();

          var formData = $(this).serializeObject();
         $.ajax({
            url: '/<%= serverid %>/save',
            type: 'post',
            dataType: 'json',
            contentType: 'application/json',
            data: JSON.stringify(formData),
            success:function(data) {
                if(response == "ok"){
                    document.getElementById("resp").style.color = "green";
                    $("#resp").text("Saved Successfully.");
                }else{
                    document.getElementById("resp").style.color = "red";
                    $("#resp").text(response);
                }
            },error:function(error){
                console.log(error);
            }
        });
        });

im trying to send a request via ajax with json. the request is getting made and a error is getting logged but the request is working, thats what i get from the console:

readyState: 4
getResponseHeader: ƒ (e)
arguments: (...)
caller: (...)
length: 1
name: "getResponseHeader"
prototype: {constructor: ƒ}
__proto__: ƒ ()
[[FunctionLocation]]: jquery.min.js:2
[[Scopes]]: Scopes[3]
getAllResponseHeaders: ƒ ()
setRequestHeader: ƒ (e,t)
overrideMimeType: ƒ (e)
statusCode: ƒ (e)
abort: ƒ (e)
state: ƒ ()
always: ƒ ()
catch: ƒ (e)
pipe: ƒ ()
then: ƒ (t,n,r)
promise: ƒ (e)
progress: ƒ ()
done: ƒ ()
fail: ƒ ()
responseText: "ok"
status: 200
statusText: "OK"
__proto__: Object
#

any idea of how can i fix it?

amber fractal
#

That doesnt look like an error

summer torrent
#

status: 200

pallid marsh
#

thats what i get from the console...

amber fractal
#

That looks like the request object

pallid marsh
#

if i use only success and console log it, nothngi happens

#

if i do

#

error:function error and i console log it

#

thats what i get

#

idk why

mossy vine
#

status: 200 thats not an error my guy

#

while im here can anyone explain what the watching activity is?

#

is it 3 just not mentioned in api docs?

pallid marsh
#

i know its not cuz the request is working

#

thats what i said

#

but why its sending it with the error object

blissful scaffold
#

It works the same as the PLAYING status

mossy vine
#

doesnt answer my question

#

but i got an answer from elsewhere anyways

earnest phoenix
#

Okay so my bot has to update like over 2300 channels in 183 guilds periodically - but every time I do this is vastly slows down when it gets about halfway done and sometimes just stops due to "socket hang up" and the "ECONNRESET" error. Anyone know how to circumvent this? I'm using the async functions to edit the channels and waiting for them before editing another etc.. I just expected it to take as much time as it needed and keep going, like waiting until it can do it; instead it just seems to stop. How do I fix this?

#

Hi guys, so I made this eval command in discord.js and when I run the code on my laptop it works perfectly, but when I run it on my free hosting service, it says that message and client are not defined

quartz kindle
#

@earnest phoenix thats considered api abuse and is against the discord TOS

earnest phoenix
#

soo... what do you do?

quartz kindle
#

why do you even need to update that many channels?

earnest phoenix
#

because the channels show information that needs updating

#

like that member count bot

quartz kindle
#

that is bad design

earnest phoenix
#

so what do I do instead?

quartz kindle
#

you shouldnt be doing that at all

#

if you want something like that, make it only 1 channel per guild, and space the updates by at least 1 minute

earnest phoenix
#

wait so how do the other bots do it then?

golden condor
#

In discord.js

#

How do I detect how long a cooldown is left

#

Do I have to use a specific cooldown system?

quartz kindle
#

@earnest phoenix what other bots?

#

i havent seen any bot doing that

earnest phoenix
#

and a hell of a lot more servers than me too

#

Can't I just artifically slow it down and purposely make it go for a longer period..?

#

it's not like it needs to happen often

#

on a server-by-server basis that is

blissful scaffold
#

@earnest phoenix if you really want to update a lot of channels then add a delay of multiple seconds between every channel update

true ravine
#

Anyone here have any experience with node-cron? I want to check if my syntax is right but I want it to run at the start of each month so I'd have to wait 25 days to see if it works lol

#

This is the interval I've written for that: 0 0 1 * *

#

If anyone knows if that will run at the start of each month or not that would be helpful

blissful scaffold
#

you could try it by setting it to 0 0 6 * * and if that runs midnight then it will also work the 1st of the month if you set it to 1

amber fractal
#

you're welcome

earnest phoenix
#

Is that really the fastest it can go?

true ravine
#

Oh thanks both of you

hushed berry
#

you're gonna run into global ratelimits pretty fast too

earnest phoenix
#

because that means these other bots would be literally impossible to create

#

by my knowledge..

amber fractal
#

yours was right

blissful scaffold
#

@earnest phoenix you want to make sure your bot never rate limits and while updating channels you still want to handle other commands/requests

slate quail
#

What do people use to host their bots?

earnest phoenix
#

Yeah that's what I was wondering, how do I know when I've hit the limit and need to wait..?

true ravine
#

@amber fractal Thanks that's really helpful

slate quail
#

Because I have been using repl.it with uptime robot for ages and it is free good hosting.

blissful scaffold
#

@slate quail I host one bot on my NAS at home and one bot on a VPS

slate quail
#

Ah

amber fractal
#

"good" is a relative term

quartz kindle
#

@earnest phoenix you can ask them how they do it, but i wouldn't update more than once per minute

amber fractal
#

you're very limited

slate quail
#

Good for free

#

Wdym limited?

earnest phoenix
#

..right

amber fractal
#

Very low ram, no read/write access, you'd have to use hosted databases

#

probably not a lot of storage

blissful scaffold
#

everything is "good" if it is free, because you can't expect anything

slate quail
amber fractal
#

Does it?

slate quail
#

At least for python

amber fractal
#

So it does

#

I still wouldn't use it ¯_(ツ)_/¯

slate quail
#

I mean, it is that or using a raspberry pi zero w in my situation. If we are talking free

blissful scaffold
#

I would use a RPI over free hosting

slate quail
#

Why?

true ravine
#

You could always look at "free" trials of certain services such as gcp or aws

slate quail
blissful scaffold
#

I have stable internet and I have full control over a RPI

late hill
#

@earnest phoenix there's definitely better ways than a simple loop going through all channels with a delay inbetween
You should make sure that you're not updating something that hasn't changed
You could also have it update only if a "certain amount" of change has been hit

slate quail
#

I am running a flask web server with uptime robot pinging it every 5 mins to keep it online

#

In the background of my discord bot

late hill
#

Either way it's just dumb design that missuses channels for things that don't even matter

earnest phoenix
#

Actually that makes more sense

#

Yeah I have a few ideas

#

ty

latent ocean
#

Why isn't there the number of servers my bot is on?

amber fractal
earnest phoenix
#

@blissful scaffold Would dividing it among shards make it able to do more? Or is that not how shards work

#

because I always thought the other bots could do it because more shards meant less limits

blissful scaffold
#

I never used shards, so I cant tell you if that will work

earnest phoenix
#

Right

blissful scaffold
#

the api will let you send the number of servers to top.gg

earnest phoenix
#

guys i have a problem when i use Discord.MessageEmbed();

#

(node:7821) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function
at Function.normalizeFields (/home/pi/bot/test/node_modules/discord.js/src/structures/MessageEmbed.js:436:8)
at MessageEmbed.setup (/home/pi/bot/test/node_modules/discord.js/src/structures/MessageEmbed.js:70:91)
at new MessageEmbed (/home/pi/bot/test/node_modules/discord.js/src/structures/MessageEmbed.js:11:10)
at embedLikes.map.e (/home/pi/bot/test/node_modules/discord.js/src/structures/APIMessage.js:164:40)
at Array.map (<anonymous>)
at APIMessage.resolveData (/home/pi/bot/test/node_modules/discord.js/src/structures/APIMessage.js:164:31)
at TextChannel.send (/home/pi/bot/test/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:166:62)
at Client.client.on.msg (/home/pi/bot/test/index.js:36:21)
at Client.emit (events.js:189:13)
at MessageCreateAction.handle (/home/pi/bot/test/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
(node:7821) 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:7821) [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.

summer torrent
#

update node js

earnest phoenix
#

v10.15.2

latent ocean
#

@blissful scaffold merci

earnest phoenix
#

oh i see

summer torrent
#

d.js v12 requiring node.js v12 or higher @earnest phoenix

earnest phoenix
#

yes i seen

#

thanks

quartz kindle
#

@earnest phoenix shards have their own rate limits but only for websocket requests, not for REST requests

#

REST requests are global across all shards afaik

earnest phoenix
#

What's the difference?

quartz kindle
#

REST = get/post/put/patch/delete

#

websocket = presence/request guild members

summer torrent
#

request guild members Thonk

earnest phoenix
#

oh

quartz kindle
#

channel edits are REST so they will count for global limits

#

you could make something like a queue per guild

#

listen to events, and every time an event happens that changes the stats, add an update to the queue, if the queue is empty, process it immediately

#

else, it will wait in the queue

#

although per-route rate limits are applied to channels, not guilds, so having a per-guild queue wont help much

earnest phoenix
#

my npm does not work :/

#

i just updated nodejs

quartz kindle
#

how did you update?

earnest phoenix
#

apt

quartz kindle
#

apt's node version is old af tho

summer torrent
#

I suggest use NVM

bitter pawn
#

can you set a bot to dnd

summer torrent
#

yes

bitter pawn
#

bc my bot doesnt set to dnd it only sets to online and idle

summer torrent
#

what is your lib

bitter pawn
#

d.pu

regal saddle
#

Cf8 maybe could help.

#

Otherwise take look in the Internet.

#

Or Docs idk.

bitter pawn
#

but thats the problem im doing it right and nothing happens

regal saddle
#

Can i see your code?

#

I know a bit of Python.

earnest phoenix
#

Node nodemon and npm no longer work

grizzled raven
#

doesnt $ node v 12 or something like that update node?

#

or am i tripping

knotty steeple
#

ur tripping hard

#

never seen that before

grizzled raven
#

also im pretty sure some versions of node.js v11 can work with d.js 12

golden condor
#

In discord.js
How do I detect how long a cooldown is left
Do I have to use a specific cooldown system?

grizzled raven
#

i could be thinking about npm idk

marble juniper
#

well its kinda easy actually

#

you can use booleans

#

and setTime out

golden condor
#

I use Sets atm

marble juniper
#

and after a while the cooldown will be set to false

golden condor
#

But I wanna know how much time is left on it

marble juniper
#

oh that

#

well idk

golden condor
#

ok

#

thx

marble juniper
#

maybe something on npm

cinder patio
#

Save when the countdown started (in ms) and how much seconds it is

earnest phoenix
#

^

#

subtract the date now from date of the entry

marble juniper
earnest phoenix
#

other way around

marble juniper
#

I have found this

#

this is probably what he needs

#

go on and fork dat out of stackoverflow cuz who doesn't I do it every day

cinder patio
#

Math.round((started + cooldown) - Date.now()); should do the job.

started is when the cooldown started in milliseconds
cooldown is how many milliseconds the cooldown lasts

#

That will return the time between in milliseconds, divide by 1000 to get the seconds and maybe round it then

pastel gazelle
#

how does one change the owner of their bot on the website

#

for mine is incorrect

quartz kindle
#

contact a mod i guess

pastel gazelle
#

epic

paper cliff
summer torrent
#

what is this

#

"Read all messages"

earnest phoenix
#

look at the top "lean"

summer torrent
#

"Join servers for you"

earnest phoenix
#

it kinda seems like a self bot just from that screenie

summer torrent
#

not safe I think

earnest phoenix
#

^ strong agree

sudden geyser
#

It looks like a bot to replace your entire existence on Discord.

earnest phoenix
#

Aren't i supposed to write:
message.author.id
For my own or the message's sender's id?

summer torrent
#

message's author

earnest phoenix
#

Yea yea

#

@summer torrent so check my code up there... Why does it say can't read the property of 'id' of undefined?

finite bough
#

@earnest phoenix can u send ur code

summer torrent
#

🔭

earnest phoenix
#

Bruh scroll up @finite bough

summer torrent
#

@summer torrent so check my code up there... Why does it say can't read the property of 'id' of undefined?
@earnest phoenix which line

earnest phoenix
summer torrent
#

🧐

earnest phoenix
#

That error confused the shit out of me literally...

finite bough
#

I will be honest

#

I never got an error that big in my whole entire coding career

earnest phoenix
#

I mean it's just one error but i used the command 2 times and it printed the error 2 times @finite bough

finite bough
#

ok that console is too clumsy

earnest phoenix
#

(the 3rd is a permission error which was probably from a server that my bot joined but didn't had permission)

finite bough
#

so

#

message.author is undefined

earnest phoenix
#

So how's it undefined?

finite bough
#

is message defined?

earnest phoenix
#

In none of my commands it's undefined but it's just undefined on this one... Somehow...

#

@finite bough ???

#

Isn't message a function?

finite bough
#

like

#

how do I put this

earnest phoenix
#

Like let message = "bruh" or something?

finite bough
#

nope

earnest phoenix
#

Then what do you mean by it?

finite bough
#

client.on("message", message =>{

earnest phoenix
#

That's on the very very top

elder vine
#

message.channel.send("bruh")

finite bough
#

check the brackets

earnest phoenix
#

@finite bough i literally don't see any issues with the brackets

elder vine
#

arrow function correctly?

#

Also, don't code on a phone :p

earnest phoenix
elder vine
#

message returns a promise

earnest phoenix
#

@elder vine i try that... Still nope

elder vine
#

I can't properly see

finite bough
#

^

elder vine
#

What version of djs do you use?

earnest phoenix
#

12.1.1

elder vine
#

Alright, good.

finite bough
#

doesnt rlly matter rn

stable nimbus
#

So I have a handcuff command with my bot, and what I want it to do is detect if a member has been handcuffed and respond with a message, what I currently have didn't work and I don't know how I would google search it. Its under an if statement, if somebody could point me in the right direction that would be amazing!

elder vine
#

Do you use a users fetch?

earnest phoenix
#

Nope

elder vine
#

Cody, what is the code?

finite bough
#

^

stable nimbus
#

case 'bcuff': {
let member = message.mentions.members.first()
var embed = new RichEmbed()
.setTitle('Cuff Test!')
.setColor('#a1ee33')
.setDescription('🔒 ' + <@${message.author.id}> + ' Has cuffed: ' + <@${member.id}>)
message.delete
message.channel.send(embed)
var handcuffed = 'cuffed'
if(member.id, handcuffed = true) {
message.channel.send("You can't use commands when in cuffs!")
} else {}
break;
Here is my code.

elder vine
#

What line is the error on?

stable nimbus
#

No error.

elder vine
#

What is the error?

earnest phoenix
#

I wonder how message.author.id can be undefined...
Like what...

stable nimbus
#

Just doesn't do what I am looking for it to do.

elder vine
#

What line Voltex?

#

message.delete()

earnest phoenix
elder vine
#

Does it do anything?

stable nimbus
#

So say I ran /cuff @granite pagoda, what I want it to do if said use tries one of the commands I want it to respond with "You can't use commands while you're in handcuffs!"

elder vine
#

what line is the error on?

stable nimbus
#

Oh, so it tagged someone.

#

I don't have an error,

#

This is what its doing.

elder vine
#

Yea

quartz kindle
elder vine
#

but how would it know if it was cuffed?

stable nimbus
#

I want it to do something when someone else that is cuffed sends a message.

elder vine
#

You need to store the cuff then.

earnest phoenix
#

@quartz kindle yea?

elder vine
#

in a database or something.

summer torrent
#

return; @stable nimbus

quartz kindle
#

@earnest phoenix you're checking for message.mentions.users.first().id

#

regardless if a mention exists

mystic violet
#

How to check if an invite exists by a certain user?

#

discord.js

#

my bot is really getting ratelimited rn lol

earnest phoenix
#

@quartz kindle so what would i do instead of that?

summer torrent
#

<Invite>.inviter

quartz kindle
#

first check if a mention exists

mystic violet
#

wheres the collection of invites? is it in channel?

earnest phoenix
#

Oh ok that would make sense... @quartz kindle lemme check

quartz kindle
#

let mention = message.mentions.users.first()
if(mention) { do stuff } else { do other stuff }

#

all other logic comes after that

summer torrent
mystic violet
#

like how do you get invite? from a channel?

#

like channel.invites.find("inviter", "Name")

elder vine
#

wht.

#

What version of djs LoseJoe?

mystic violet
#

v12

summer torrent
#

<Channel>.fetchInvites() method

#

or guild

elder vine
#

guild.fetchInvites()
.then(invites => console.log(Fetched ${invites.size} invites))

mystic violet
#

Does fetchInvites() get ratelimited?

quartz kindle
#

its a rest method, so yes

#

but get requests have pretty high limits

earnest phoenix
elder vine
#

Really..

#

You use !

earnest phoenix
#

Hmm...

elder vine
#

so if it does not have mention it will look for a mention

#

! = opposite boolean

quartz kindle
#

you should put ALL mentioned user logic inside the if(mention) block

#

and ALL user logic on an else

earnest phoenix
#

Idk how does that work or mean... Can you show me? @quartz kindle

#

Wait... Why on that if(mention) tho?
That works...

#

There's 2 of them

quartz kindle
#
let embed = new MessageEmbed();
if(mUser) {
  if(!cookies) { do cookies }
  let cookie = cookies[user]
  embed = embed.bla().bla().bla()
} else {
  if(!cookies) { do author cookie }
  let cookie = cookies[author]
  embed = embed.bla().bla().bla()
}
channel.send(embed)``` @earnest phoenix
earnest phoenix
#

Hmm good idea but that do cookies and do author cookie... Wdym by that?
Like create a cookie profile for them that doesn't have cookies? @quartz kindle

quartz kindle
#

yes

earnest phoenix
#

Oh ok... Lemme try that

elder vine
#

xD

quartz kindle
#

thats what i mean by placing ALL logic in the same scope

#

you dont need 3 IFs, you can organize everything in one IF

elder vine
#

^

mystic violet
#

@quartz kindle (sorry to mention) but the code I showed earlier about the invite thing (with the weird timeout) its getting ratelimited as hell

#

even though im only creating 5 invites

#

but people use the command alot

elder vine
#

Add a cooldown to it

mystic violet
#

I have a 30 second cooldown

elder vine
#

Queue the events

mystic violet
#

thats smart as hell

#

idk how to do that though

elder vine
#

Try figure something out, and we're here to help.

mystic violet
#

or I can keep all guilds invites in a cache somewhere

#

instead of requesting them each time

#

I can just pick them out

#

and update them every few minutes

elder vine
#

Do you have a database?

mystic violet
#

yeah

elder vine
#

Mongo?

mystic violet
#

nah quick.db

elder vine
#

Well, then someone else shall help u :P

quartz kindle
#

@mystic violet are you fetching existing invites or creating new ones?

mystic violet
#

creating new ones

#

I want it to create one

#

and keep it like that

#

but people keep executing the command

#

and I dont wanna turn the bot off ;-;

#

I have a beta bot though

#

just dont like the ratelimits

#

bruh its already on 100 servers

#

not on any bot list or anything

#

;-;

#

I made it yesterday

quartz kindle
#

im not sure about the rate limits for creating invites

#

but its probably much lower than getting them

#

in any case, after creating one, you should save it somewhere and reuse it

#

the problem is checking if its still valid

mystic violet
#

hm

#

this is really messy code I cant read half of this lol

elder vine
#

Re-code and fix then.

mystic violet
#

True

#

I better do that

#

ill get started asap

#

and keep the invites

#

and remake them like every 2 hours

slender thistle
#

imo 1s delay between the same type of request is a somewhat safe bet

earnest phoenix
#

@quartz kindle also that worked... Thx

amber fractal
#

Is there ever a time when Tim's solutions don't work

earnest phoenix
#

@amber fractal nope... Tim is just the god of resolving errors and codes...

quartz kindle
#

@_@

earnest phoenix
#

Im on discord js

#

How to fetchAllMembers

#

Because bot.users.size not showing the good numbers of members

summer torrent
#

use reduce()

earnest phoenix
#

@earnest phoenix bot.users.cache.size

quartz kindle
#

fetchAllMembers is a client option. you add it to the client when your create it

earnest phoenix
#

you're allowed to hit ratelimits once, but after that you must respect the RetryAfter header, if you don't - that's where it gets problematic

quartz kindle
#

but fetching all members uses a LOT of ram

earnest phoenix
#

Hmm

quartz kindle
#

you can get an accurate user count if you join together the guild.memberCount of all guilds

earnest phoenix
#

bot.users.cache.size doesn't work

#

Its for show all members of all guild in a message

quartz kindle
#

you want to show only number of members? or also usernames?

earnest phoenix
#

Numbers

#

Of all guild

quartz kindle
#

then join together the memberCounts

#

guild.memberCount has the accurate number of members a guild has

#

you need to loop over all guilds, and add together their memberCounts

earnest phoenix
#

Okey

amber fractal
#

can you reduce on guilds?

quartz kindle
#

yes

earnest phoenix
#

but. what about users in multiple guilds?

quartz kindle
#

using a reductor function is the most efficient way

#

users will be duplicated

#

nothing you can do about that

amber fractal
#

also why would you make your bot look worse

earnest phoenix
#

Look

#

Grrrr

regal saddle
#

Tim doing a great job.

earnest phoenix
#

Yes

#

Very nice

quartz kindle
#

well, of course you are not supposed to use guild literally

#

you need to get the guild from somewhere duh

#

like message.guild if in a message event

earnest phoenix
#

No look my code

regal saddle
#

There is no code?

earnest phoenix
#

Wait

#

2 min plz

#

But how's it possible to get all the guilds that the bot is in and fetch it's memberCount? @quartz kindle

#
.addField("Utilisateurs 👶 ", `${guild.memberCount}`, true)
#

Look

regal saddle
#

That hurts.

earnest phoenix
#

@earnest phoenix wait a second... What's guild as defined as?

#

Its for any guild

quartz kindle
#

i told you

#

you have to get the guild from somewhere

#

not literally use guild without context

#

@earnest phoenix you can loop over all guilds

earnest phoenix
#

Like fetch the guilds id... And then use it in the function

quartz kindle
#

a for loop, or a forEach, or a reduce

#

@earnest phoenix you can access ALL guilds from client.guilds

#

where client is the name you gave to your client

#

if you use bot, then its bot.guilds

#

then you can either use a for loop, or use .forEach() with a counter, or use .reduce() with a function

amber fractal
#

Wait was guilds not changed to a GuildsManager?

quartz kindle
#

in v12 yes

#

i think they're on v11

amber fractal
#

o

#

How would you get all guilds in v12 lmao

#

do you have a list of all ids?

quartz kindle
#

client.guilds.cache

amber fractal
#

Oh just caches all?

#

Then what's the point lmao

quartz kindle
#

by default all guilds are cached yes

amber fractal
#

So you can uncache it then?

quartz kindle
#

well, you can

#

but it will break discord.js

amber fractal
#

lol

quartz kindle
#

unless you use workarounds

copper cradle
#

as I said yesterday

#

they don't know what they're doing

limpid pulsar
#

.help

cursive dagger
earnest phoenix
#

i die inside a little bit everytime i see ! . - ? being used as a prefix

topaz fjord
#

how are u still alive then

#

liar

earnest phoenix
#

Can someone say me why my nodejs stopped working?

topaz fjord
#

not without an error

earnest phoenix
#

But i get no error 😅

#

Nothing just happens

#

Neither nodejs, nodemon nor npm work

#

how do i make my commands insensitive?

#

What du you mean @earnest phoenix

#

i think hes talking about upper/lowercase

#

that it doesnt matter

#

like -help and - HeLp

#

yea i think

quartz kindle
#

@earnest phoenix install nvm (check their github for instructions)

#

and install node using nvm

earnest phoenix
#

I try it

#

Why doesn't it work with apt?

quartz kindle
#

apt is outdated

#

not apt itself, but the list that apt uses

earnest phoenix
#

Hm ok

#

Thank you

#

It worked

earnest phoenix
#

Anyone know how to easily "record time" in nodeJS? Like set a timer going, run some code, and then resolve it or whatever and get the amount of time since starting it and resolving it?

quartz kindle
#

there are many ways to record time

#

process.hrtime(), performance.now(), Date.now(), console.time()

#

all of those can be used to record a time, and then compare to a second recording to get elapsed time

earnest phoenix
#

oh yeah I didn't think about Date.now()

#

thanks

mystic violet
#

I tried this, it gives me a collection back, but it doesnt show the invite the bot made

#

        message.guild.invite = Bot.invites[message.guild.id].filter(invite => invite.inviter.id == Bot.user.id)```
#

this is the Bot.invites

#
    Bot.guilds.cache.forEach(g => {
        g.fetchInvites().then(guildInvites => {
            Bot.invites[g.id] = guildInvites;
        })
    })```
quartz kindle
#

using .forEach with async code is a very bad idea unless you want paralelism

earnest phoenix
#

are you looking it up right after creation

quartz kindle
#

if you have 100 guilds that will send 100 requests at once

#

and get you rate limited

mystic violet
#

oh

#

what would I use?

quartz kindle
#

a for loop with async/await

mystic violet
#

ugh I hate for loops

#

lmao

#

can I do like for(g of guilds)

quartz kindle
#

not sure if collections can be iterated directly, but you can try that yeah

mystic violet
#
for(g of Bot.guilds.cache) {
        g.fetchInvites().then(guildInvites => {
            Bot.invites[g.id] = guildInvites;
        })
    }```
#

so like that?

quartz kindle
#

no, let invites = await g.fetchInvites()

mystic violet
#

and for async(g of guilds) {

quartz kindle
#

the await there will pause the loop until a value is returned. a .then will not pause it

#

no, thats invalid

#

the loop needs to be inside an async function

mystic violet
#

okay cool

#

Idk how you dont lose your mind in here tim

#

im pretty stupid when it comes to loops lol

#

says g.fetchInvites() is not a function

#
async function RegenInvites(Bot) {
    for(g of Bot.guilds.cache) {
        let guildInvites = await g.fetchInvites()
        Bot.invites[g.id] = guildInvites;
    }
}```
quartz kindle
#

hmm

elder vine
#

It's a promise

mystic violet
#

wdym

wide ridge
#

let g of bot.guilds.cache

mystic violet
#

nope

#

still doesnt work

quartz kindle
#

yes you need to initialize g as a variable

#

as Gopi said

mystic violet
#
async function RegenInvites(Bot) {
    for(let g of Bot.guilds.cache) {
        let guildInvites = await g.fetchInvites()
        Bot.invites[g.id] = guildInvites;
    }
}```
#

doesn't work

#

do you mean

#

like g = ""

#

before the for

#

or something

quartz kindle
#

no, like you posted

#

what doesnt work?

#

same error?

mystic violet
#
(node:7996) UnhandledPromiseRejectionWarning: TypeError: g.fetchInvites is not a function```
#

yep

quartz kindle
#

where are you running this function?

mystic violet
#

Oh wait

#

on the guide

#

it said to wait

#

1 second

#

on ready event

#

to create invites

quartz kindle
#

wait i found why

elder vine
#

g.fetchInvites().then(guildInvites => {
Bot.invites[g.id] = guildInvites;
});

quartz kindle
#

when you loop over a collection using for of it iterates over entries, like Object.entries()

#

so g is [id,guild]

elder vine
#

oh, 🤦

mystic violet
#

so I would be guild = g[1]

quartz kindle
#

yes

#

or g[1].fetchInvites()

mystic violet
#

and for the invites[g.id] I would use invites[g[0]]

quartz kindle
#

yes

mystic violet
#

Yep it worked

#

thank you

#

so much

#

!!

#

So. again with that filter command (lol im so sorry)

#
message.guild.invite = Bot.invites[message.guild.id].filter(invite => invite.inviter.id == Bot.user.id)```
#

it isn't responding with any invites

quartz kindle
mystic violet
#

ok

#
Collection(14) [Map] {```
#

full of invites

earnest phoenix
#

yes @earnest phoenix and @earnest phoenix, is there a way to make the commands insensitive?

#

lib?

#

again, you're talking about stuff like "THIS" and "this" right?

#

that it gets ignored

#

that it gets ignored

#

yes hope

#

lib

#

pls

#

discord.js

elder vine
#

To make commands not work?

mystic violet
#

tim?

earnest phoenix
#

no i want it to work regardless of the caps, so if someone does help or HeLp it executes the same command

mystic violet
#

.toLowerCase()

elder vine
#

make it toLowerCase() in cmd handler

earnest phoenix
#

@earnest phoenix it does not matter if !bla or !BLA or !blA

#

okay thanks everyone

#

sure

elder vine
#

No problem, hope it helped.

earnest phoenix
#

gladly

mystic violet
#
<collection of invites>.filter(invite => invite.inviter.id == Bot.user.id)
#

why doesnt this work

elder vine
#

What does not work?

#

Any errors?

mystic violet
#

No errors

#

the filter isnt giving out the invite made by the bot

elder vine
#

Is the invite fetched?

mystic violet
#

Yes

earnest phoenix
#

@earnest phoenix what kind of bot you do program?

elder vine
#

Can you use "bot's id here", to see?

mystic violet
#

I think I figured it out

#

my invite expired on my bot lol

earnest phoenix
#

@earnest phoenix a bot that has everything, Fun commands, misc, moderation etc.

mystic violet
#

thank you for trying to help my ignorance lol

elder vine
#

xD

urban folio
#

@noble egret tf

elder vine
#

Any error?

slate pilot
#

i'm send data to express

#

no

elder vine
#

What is it supposed to do?

slate pilot
#

nothing appears in console

#

@elder vine
i want to send data to express

#

but nothing appears in console when send data

quartz kindle
#

any logs on the browser console?

slate pilot
#

no

quartz kindle
#

try $("form").on("submit") instead of $("#save_perData").on("click")

#

put a console.log at the beginning of the function to see if the function is working

high bough
#

tf is this?

(node:24089) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
slate pilot
#

yep, i'm try this change #save_perData to form and use console.log in top code and put console.log("working") first this function and show the working but ajax is not working

elder vine
#

The bot has missing permissions @high bough

quartz kindle
high bough
#

What did i miss?

quartz kindle
#

@slate pilot btw cache not cashe

slate pilot
#

yep, i'm try this change #save_perData to form and use console.log in top code and put console.log("working") first this function and show the working but ajax is not working
but i see this value in file app.js

quartz kindle
#

check the network tab in the browser console before you click, see if there is a network request

slate pilot
#

i got this when select value

elder vine
#

Where is id="numbers" stored?

slate pilot
#

POST /numbers - - ms - -

summer torrent
earnest phoenix
summer torrent
#

ah ty cry

#

why chalk didn't work on pm2 logs ?

scarlet hill
#

I'm making a starter bot (just trying to learn) and im getting this error:

high bough
#

@scarlet hill Currently, almost everyone is having problem using js this.commands.filterArrayIt's better not to use it.

scarlet hill
#

I don't know where i am using it though/how to not use it

high bough
#

Find out the exact line of the code that uses it.

wide ridge
#

In my shardingManager I keep coming across issues with trying to get the server count for all shards

const manager = new ShardingManager('./indexOld.js', { token: token });
// const DBL = require('dblapi.js');
// const dbl = new DBL(topggtoken, { webhookPort: process.env.PORT, webhookAuth: process.env.WEBHOOKAUTH });

let totalShards = 2;
manager.spawn(totalShards);
manager.on('shardCreate', shard => {
    console.log(`Launched shard ${shard.id}`);
    console.log(manager);
});

console.log(manager.shards.size);
if (manager.shards.size == totalShards - 1) {
    manager.fetchClientValues(`guilds.cache.size`)
    .then(results => {
        let totalGuilds = results.reduce((prev, guildCount) => prev + guildCount, 0);
        console.log("hi")
        console.log(totalGuilds);
    })
}```
#

how do you post server count to dblapi using shardingManager?
my basic idea is this:

  • get server count for all shards
  • divide by total number of shards
  • post for each shard id
    But I keep coming across issues with fetchClientValues not being ready?
    Alternate solution: Just set a timeout for every 30 mins and do fetchClientValues then, because by then all the shards will be ready anyways?
mystic violet
#

does anyone know what permission a bot needs to fetchInvites()?

summer torrent
#

manage server

peak dirge
#

How does the Roles position work? Like if I would do for example:

guild.roles.create({
  data: {
    name: 'Super Cool People',
    color: 'BLUE',
    position: '1'
  },
  reason: 'we needed a role for Super Cool People',
})

Would that role be at the top of the roles?

earnest phoenix
#

lowest iirc

#

role positions are in a descending order

peak dirge
#

Hmm, even tho I set that to position: '100' it still comes out in position 1 :[

earnest phoenix
#

probably because there aren't a hundred roles

#

try grabbing the position of the highest positioned role and set that in create instead

astral yoke
#

How would I get the location of my reader folder? My command is in commands, owner, and eval, and the reader is in src, loaders, then reader, this is what I have which it cant find. const config = require("../src/loaders/reader"); //get data from botconfig file

#

Error: Cannot find module '../src/loaders/reader'

high bough
#

Is it .json or not?

astral yoke
#

Nevermind, I found it.

#

I fixed it.

high bough
#

Oh ok

#

I'm testing my DM command, can anyone help?

hollow granite
#

the shards for my bot are always going out randomly, and I'm not getting any errors. Is there something i can do to keep the shards from disconnecting? (discord.js v12 if it helps)

short kite
finite bough
#

u will find it in their website

summer torrent
wide ridge
#

Anyone know how I can send a DM to a user with sharding?

#

Using discord.js v12

#

Essentially I want to send a DM to the user who just voted

tight plinth
#

same method as without?

#

using webhooks oh

#

I never managed to do dbl webhooks+sharding

wide ridge
#

without it I did
client.users.cache.get(vote.user).send(voteMsg);

tight plinth
#

erm yea

wide ridge
#

with it, I tried broadcastEval, but it ends up sending multiple messages to the user

#

if they're in servers that multiple shards are hosting

#

someone mentioned that
"you could use <Shard>.send() to make one of your shards dm the user"
Is this true? How would dming work with a shard for voting?

earnest phoenix
#

How can i make a bot like this

#

Tells the news in the sites

#

drops

tight plinth
#

apis

earnest phoenix
#

Yep

valid frigate
#

depends

#

if they offer webhooks for drops then use that

earnest phoenix
#

But note some of then don't work properly

pallid marsh
#

ok im trying to send a form via json with ajax. my code is:js $.ajax({ url: '/<%= serverid %>/save', type: 'post', dataType: 'json', contentType: 'application/json', data: JSON.stringify(formData), success:function(response) { if(response == "ok"){ document.getElementById("resp").style.color = "green"; $("#resp").text("Saved Successfully."); }else{ document.getElementById("resp").style.color = "red"; $("#resp").text(response); } } ,error:function(jqXhr, textStatus, errorMessage){ console.log(errorMessage); } }); And the error i get is : ```console
SyntaxError: Unexpected token o in JSON at position 0
at parse (<anonymous>)
at jquery.min.js:2
at l (jquery.min.js:2)
at XMLHttpRequest.<anonymous> (jquery.min.js:2)

#

any idea of how can i fix it?

#

the request is being sent and its saving and all i just get this error and idk why

valid frigate
#

the response might not be json

#

wait you're sending it

pallid marsh
#

the response isnt son

#

ye

valid frigate
#

it's probably confused at JSON.stringify()

#

that might not be an object?

pallid marsh
#

i think i know why

#

i get from the server side ok

#

thats what i defined when its working

#

so maybe thats the o?

#

thats what i get

woeful fractal
#

Starter here I think its a common

#

Im getting a message when using node .

#

node : The term 'node' is not
recognized as the name of a
cmdlet, function, script file,
or operable program. Check the
spelling of the name, or if a
path was included, verify that
the path is correct and try
again.
At line:1 char:1

  • node .
  •   + CategoryInfo          : O
     bjectNotFound: (node:String
    ) [], CommandNotFoundExcept
    

ion
+ FullyQualifiedErrorId : C
ommandNotFoundException

#

Im getting this when im trying to code the login part

twin iron
earnest phoenix
#

how i can get adidas yeezy and wunders api

woeful fractal
#

I downloaded the node

earnest phoenix
#

U need to do node index.js

#

Or what ever your main file is called

#

node bot.js

twin iron
#

@woeful fractal "node : The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program." so your node have problems

#

try to fix install

woeful fractal
#

Should I delete node and reinstall?

twin iron
#

yes

summer torrent
earnest phoenix
#

@woeful fractal BTW what node u installing

woeful fractal
earnest phoenix
#

i couldnt finded

#

Ik 12 or 13

obtuse wind
pale vessel
#

bad gateway

obtuse wind
#

Interesting thanks I'll find a way to fix it

#

somehow

pale vessel
#

just wait and try again later

distant sky
#

I have a small problem, I got a code from someone that made it for me, it worked perfectly till I tried to run it today and got a bad token error, the token is correct tho.

summer torrent
#

I have a small problem, I got a code from someone that made it for me, it worked perfectly till I tried to run it today and got a bad token error, the token is correct tho.
@distant sky show error and code

distant sky
#

Can I DM the code? I would prefer not to send the code here.

summer torrent
#

yes

distant sky
#

I have a small problem, I got a code from someone that made it for me, it worked perfectly till I tried to run it today and got a bad token error, the token is correct tho.
@distant sky
Discord.py (forgot to mention that)

tight plinth
#

node v13

#

wattttttttttt

slender mountain
#

Wondering if anyone would like to point out what I am doing wrong here:

async function updateChannelPerms (array, channelID, permissions) {
    console.log(array);
    for (var i = 0 i < array.length; i++) {
        bot.channels.fetch(channelID).then(c=>{
            let userToEdit = await bot.users.cache.get(array[i]));
            c.updateOverwrite(userToEdit , {SEND_MESSAGES: permissions});
        });
    }
}
#

I'm not great with async/await stuff

#

array, channelID, permissions
this stuff returns undefined inside the fetch promise, but not out of it, I know I need to use await to fix this, I am just not surely exactly how to utilize it

drowsy sentinel
#

You can simply do the guilds cache size. If you're sharding you can broadcast an eval for the guild count and post the total sum.

tight plinth
#

npm is useless for me 😦

#

it needs to install the node package, but it needs it to install it

drowsy sentinel
#

Did you check the process arches to see what they supported?

#

Did you also try to remove your node modules and reinstall the dependencies?

tight plinth
#

I tried

#

but nothing

drowsy sentinel
#

Yoinks, did you install it wrongly?

tight plinth
#

I just did npm i

drowsy sentinel
#

try npm-install-missing

tight plinth
#

ok

quartz kindle
#

you're not supposed to have a node folder in node_modules lol

#

what are you trying to install?

tight plinth
#

just my bot's dependencies

#

it can't install any module at all

#

not even upgrade npm

quartz kindle
#

did you install node using nvm?

tight plinth
#

yes

quartz kindle
#

did you run nvm use NODEVERSION?

#

do nvm ls

tight plinth
quartz kindle
#

and node -v shows the correct version, yes?

#

what about npm -v?

tight plinth
#

node -v yes

#

6.13.7 for npm

#

I tried hours an hours of google, can't find any solution

quartz kindle
#

looks correct

#

what dependency are you trying to install?

#

show your package.json

tight plinth
#

literally this one

quartz kindle
#

remove node

#

from your dependencies

tight plinth
#

k

#

I have to install packages 1 per one?

#

node is dumb

quartz kindle
#

it looks like everything is already installed

#

whats missing?

tight plinth
#

sqlite

#

manual install works

quartz kindle
#

do npm rebuild quick.db

tight plinth
#

doing it

summer torrent
#

what is "funding"

tight plinth
#

idk

quartz kindle
#

donations/patreon/sponsorship

dusky marsh
#

to provide devs with funding and stop package ads

quartz kindle
#

since when are there ads in packages? or in open source in general

tight plinth
quartz kindle
#

it usually just means if there is no funding, development will stop

tight plinth
#

I hqve to do port forzqrding

#

fuck

quartz kindle
#

that error is not about port forwarding

#

its your code

dusky marsh
#

there were a few packages with ads, i read some articles on it at some point before they implemented npm fund

#

there was a big fuss

quartz kindle
#

there is no process.env.PORT on a vps/linux

tight plinth
#

ye

quartz kindle
#

unless you set it via system environment variables, or load them from env files

summer torrent
tight plinth
#

removed webhooks, works

quartz kindle
#

all you needed was to specify a port lol

tight plinth
#

ye

#

managed to open a port with my box aaa

#

webhooks r bacc

#

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

robust moth
pale vessel
#

gyp

broken jay
#

Is possible to spawn new shard during session?

raven urchin
quartz kindle
#

@broken jay possible? yes. good? no. should you do it? no

#

@raven urchin that setInterval is basically doing nothing but wasting cpu

late hill
#

How do large bots handle spawning new shards

earnest phoenix
#

Hola

late hill
#

Doesn't it mean that they have to fully reboot basically

modest maple
#

just have redundant shards

quartz kindle
#

yes it does

earnest phoenix
#

Español

late hill
#

Which takes a long time because of the shards being one each 5s

modest maple
#

yes

earnest phoenix
#

Me agregan

quartz kindle
#

thats why the only time they increase the shards is when they double them

modest maple
#

why do you think most large bots have 1000 guilds per shards

#

lets them grow for a while before needing to

quartz kindle
#

ie: from 64 shards with 2k servers each to 128 shards with 1k servers each

modest maple
#

^^

earnest phoenix
#

🖕🖕🖕🖕🖕🖕🖕

late hill
#

I'm on like 20 shards now i think

#

nice finger @earnest phoenix

earnest phoenix
#

@late hillx chupame la polla

quartz kindle
#

habla-se inglés en este canal

raven urchin
#

@quartz kindle How can I make it so the ${client.users.size} update every 20 seconds?

late hill
quartz kindle
#

mete te por el culo @earnest phoenix

earnest phoenix
#

mete te por el culo @earnest phoenix
@quartz kindle

#

lol

quartz kindle
#

@twilit rapids

modest maple
#

TIM be a good boy

#

told duane

twilit rapids
#

Nice

regal saddle
#

Tim do be kinda mad doe pogChamp

quartz kindle
#

he started lmao

earnest phoenix
#

though i like that they're not using the general chat pogey

regal saddle
#

he started lmao
But youre not a kid aPES_LovePat

quartz kindle
#

i am allowed to be a kid every once in a while

regal saddle
knotty steeple
modest maple
#

Duane beat u to it timo

twilit rapids
#

smh

#

Had to translate shit first

quartz kindle
#

@raven urchin js setInterval(() => { // what to do in the interval, ie: setActivity() }, 20000) // every 20000 milliseconds

raven urchin
#

For what to do in the interval, what do I put?

#

Like anything?

quartz kindle
#

the code you want to be run every 20 seconds

raven urchin
#

Oh okay, got it. Thank you

knotty steeple
#

no that could not work

#

it wont work

#

what are u trying to do???

elder vine
raven urchin
#

trying to do what Tim sent. But showed an error.

knotty steeple
#

yea

#

what

raven urchin
#

It's where it just refreshes the users count every 20 seconds

knotty steeple
#

do u want

#

why exactly

raven urchin
#

Removing module won't work.

elder vine
#

Wait

#

This is in an event manager?

raven urchin
#

No.

knotty steeple
#

it will get the cached members automatically tho

elder vine
#

You would need to set the activity inside the interval function

raven urchin
#

Oh, lemme try

earnest phoenix
#

How would I get the highest roles position of the person who executed the command?

elder vine
#

What library and version?

raven urchin
#

I got it working, thank you!

earnest phoenix
#

V12.1.1

elder vine
#

No problem

lyric hawk
#

Hi, when editing a message, can you confirm the ID stays the same but the object message itself changes?

elder vine
#

Use .highest @earnest phoenix

#

Yea, ID of message does not change.

earnest phoenix
#

So message.member.roles.highest?

#

I'm kinda new to d.js, started on d.py

#

message.member.roles.cache.highest?

elder vine
#

Sorry my mistake

#

guildMember.roles.highest;

earnest phoenix
#

Oh, Thanks!

elder vine
#

No problem

raven urchin
#

Another quick question. For setStatus. How do we do it? Been trying to figure it out

elder vine
#

Read the docs?

spare goblet
#

prety sure its setActivity

#

but check the class clientUser

elder vine
#

client.user.setPresence({ activity: { name: 'with discord.js' }, status: 'idle' })

#

yea setActivity also works

pale vessel
#

setStatus is a thing

earnest phoenix
#

how do i make all packages reinstall themselves or update?

#

im on a new project and i dont wanna install them 1 by 1

#

(pnpm)

summer torrent
#

npm i

earnest phoenix
#
npm WARN deprecated snekfetch@3.6.4: use node-fetch instead
npm ERR! code ETARGET
npm ERR! notarget No matching version found for node.js@^0.0.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget 
npm ERR! notarget It was specified as a dependency of 'hello-sqlite'
npm ERR! notarget 

npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npm-cache/8.15.1/_logs/2020-04-06T12_05_34_410Z-debug.log```
#

how can i know if a message is embed

#

if(message === ?)

#

nvm

elder vine
#

npm audit fix

tardy monolith
#

So I'm just starting out, what code language should I use?

crimson vapor
#

It is all personal preference to be honest

tardy monolith
#

I see thanks.

night creek
#

guys i need help

#

in c# dsharpplus

#

how do i make a music bot? join and leave functions are in, i wanna do something like rythm where it searches from youtube

queen needle
#
client.on("message", message => {
    
  if (message.content.startsWith("^slot")) {
    
 
  
 message.channel.send(fish = Math.floor(Math.random() * 3) + 1);
  message.channel.send(fish2 = Math.floor(Math.random() * 3) + 1);
  message.channel.send(tod = Math.floor(Math.random() * 3) + 1);

if(fish === fish2 && fish === tod){
message.channel.send("winner");
}else{
message.channel.send("better luck next time muggle")
}
}
  
  
});```
#

hey could anyone help me put that in a cool down earlier i tried and it didn't work so wel

quartz kindle
#

why are you sending 4 messages lol

pine aspen
#

How can i check for a channel user permission if you get what i mean?

queen needle
#

its a slot machine and i don't know how to put all 3 plus the winner or loser message in one message

pine aspen
#

Check if the user has VIEW_MESSAGES permission in a specific channel.

queen needle
#

oh

pine aspen
#

Help Cinnamon first.

quartz kindle
#
let fish = Math.floor(...)
let fish2 = Math.floor(...)
let tod = Math.floor(...)
let result = `${fish}-${fish2}-${tod}\n`;

if(fish === fish2 && fish === tod){
  result += "Winner";
} else {
  result += "Loser";
}

message.channel.send(result)
pine aspen
#

Tbh that's well written code. ^^

#
How can i check for a channel user permission if you get what i mean?
Check if the user has VIEW_MESSAGES permission in a specific channel
slender thistle
#

Tbh that's well written code. ^^
He didn't use switch-case so no it's not

#

:^)

queen needle
#

i had to use switch case for my mute command

pine aspen
#

Lol

#

Switch also works.

#

@slender thistle got any clue how I could fix my thing?

slender thistle
#

d.js?

pine aspen
#

Yup.

#

11.5.1 preferably.

finite bough
#

what was ur problem again?

pine aspen
#

How can i check for a channel user permission if you get what i mean?
Check if the user has VIEW_MESSAGES permission in a specific channel

#

(Ticket System)

finite bough
#

oh

#

thats easy

regal saddle
#

message.auhtor.hasPermissions? wasnt it that?

finite bough
#

yes

pine aspen
#

Oh?

#

It works within a channel.

#

Like a channel permission.

#

Ok.

regal saddle
#

Wait

finite bough
#

message.member

regal saddle
#

Do you want to check it in a channel or?

pine aspen
#

Only a single channel permission.

#

Yes, checks it in the ticket channel.

regal saddle
#

Cache the channel and then check the permission

pine aspen
#

So like.

finite bough
#

u can do it either by

pine aspen
#

channel.get()

channel.member.hasPermission?

finite bough
#

seeing if the role has permission

pine aspen
#

Not I role i need.

quartz kindle
#

switch is only good if you have 3 or more if-else cases lol

pine aspen
#

User permission.

regal saddle
#

client.channels.cache.get(id)

pine aspen
#

(11.5.1)

#

No cache

regal saddle
#

Oh

pine aspen
#

😛

#

let target = message.channel.permissionOverwrites.get(member);

#

Would this works perhaps?

quartz kindle
#

@pine aspen channel.permissionsFor(user).has(permission)

pine aspen
#

Ah!

#

Ok

#

I'll try it

main laurel
#

hello @quartz kindle how are you ?

pine aspen
#

gr8

queen needle
#

@quartz kindle thank you i was able to use that method to create a dice game

terse trench
#

is there any way to make shortcut via cmd?

#

literally

#

say i have bruh.exe, and need to make shortcut of it

tight plinth
#

PATH

terse trench
#

can you be more like

#

u know, specific

valid holly
#

get the path location for bruh.exe

tight plinth
#

set PATH='path/to/file'

#

wait

#

maybe

#

set PATH=%PATH%;C:\your\path\here\

ruby bane
#

did you guys managed to get the command row deleted?