#development

1 messages ยท Page 905 of 1

marble juniper
#

how can I get all the emojis from a message in discord.js

#

best would be if I could get them in an array

#

since I want my anti nsfw bot to also be able to scan emojis

#

I did searched it online but didn't find anything which fits my situation

west spoke
#

thats a very interesting question, i'd go and remove all text (non emojis) and add each emoji to an array as a object or sth, and get the url, and scan it

#

that's what i would do NepThink

marble juniper
#

yeah but how do I do that

west spoke
#

i have no idea

#

split at < and >

#

and afterwards join all text between < and >

#

and get rid of each other?

#

though the problem of having a loose > in your text would exist

marble juniper
#

I mean I did find a node module for getting emojis as an array but that one was made 9 months ago

west spoke
#

mm yeah

digital ibex
#

hi

marble juniper
#

I could try forking the code out of the module I found

digital ibex
#
let a = guild.tags.find((e) => message.content === e);
if(!!a.name) {
message.channel.createMessage(a.response)
}
``` why am i getting `can't read propery of 'name' of undefined`?
ocean violet
#

What is that double !!

digital ibex
#

it turns it into boolean basically

#

kinda like double negative

hallow sandal
#

Im currently using glitch to host the bot 24/7. I had no idea how to do it so I looked up. I did what they said and it doesn't work. I'm using uptime robot.

digital ibex
#

uptime robot is for monitoring ur services, not hosting

hallow sandal
#

Oh, because I looked in the forums.

surreal notch
#

I have used this to minus the money

#

from a person's account

#

but i think fetch won't work

#

please tell what should I do

digital ibex
#

the db library u r using

surreal notch
#

Yes

digital ibex
#

u asked us to ask u: tell u what to do
i say ask u: what db library are you using - not a yes/no question

surreal notch
#

Ohh

#

sorry

#

quick.db

#

@digital ibex

#

Ahh

digital ibex
#

yeah?

#

idk quick.db

hallow sandal
#

How can I host the bot 24/7 in glitch then?

surreal notch
#

@hallow sandal Not possible

#

Go and buy a good hosting

quartz kindle
#

you can use uptimerobot

#

i think many people use it

surreal notch
#

It only shows when bot goes down

#

XD

hallow sandal
#

Lost said its for monitoring, not hosting

quartz kindle
#

it is

#

you're not hosting on uptimerobot, you're hosting on glitch

hallow sandal
#

oh

#

I did use it but the bot didn't went on.

quartz kindle
#

then you used it wrong? idk

surreal notch
#

I have codes to keep bot 12 hrs on9

hallow sandal
#

I did put the correct the application link in the monitor

honest perch
#

You may need a web server on the glitch projecy

#

Used to do it before and thats how I got it working

hallow sandal
#

How do I get the web server?

honest perch
#

This has one

hallow sandal
#

Hm, I using python though, not ks

#

js*

honest perch
#

Oh right, idk then

pale vessel
#

someone hosted a python bot on heroku

quartz kindle
#

glitch is made for web services, not for websockets, like discord uses

pale vessel
#

well, you need a credit card

quartz kindle
#

to be able to provide their service for free, glitch automatically puts inactive services to sleep mode, and awakes them when they receive a request

#

so what you need to do is to regularly make a request to your glitch project to prevent it from going to sleep mode

honest perch
#

They also limited the amount of projects you can keep online 247 to 20

#

They also released a paid plan but its a rip off at that point

pale vessel
#

glitch just has a bad uptime

honest perch
#

For what you get its better to buy a pi

pale vessel
#

i would say a cheap vps

hallow sandal
#

I guess I should stick with heroku then xd

honest perch
#

Or that

#

If you're a student you could try the github edu pack

quartz kindle
#

none of those free services are made for bots, so you're gonna have a hard time on either one

pale vessel
#

never heard of a stable free bot hosting service either haha

hallow sandal
#

I mean, I am using heroku to host the bot but I want to switch to glitch. but eh

pale vessel
#

why?

quartz kindle
#

its basically switching from one bad thing to another bad thing

#

if you're gonna go through the effort of switching, at least switch it to something good

hallow sandal
#

its my only choice to host it 24/7

honest perch
#

Can't you pay for a vps or self host it

hallow sandal
#

eh, cant.

#

probab;y soon

pale vessel
#

a vps would be ideal

hallow sandal
#

probably*

pale vessel
#

for now just stick with heroku since they have a better uptime and move to a vps when you can

hallow sandal
#

Alright,

#

Also

#

I switched my codes to cogs in python, so when I imported all the files, added the reuirements.txt, procfile, etc, I tried to deploy but it says that its compatible

#

im using github by the way

#

im trying to run it on heroku

pale vessel
#

you mean "not compatible"?

hallow sandal
#

yeah

#

sorry for the typos

pale vessel
#

try removing the python buildpack from heroku and redeploy

marble juniper
#

so I forked and fixed and modified the discordjs-getemojis module and now I can get the ids from the emojis from a message but how can I check if the emoji is animated or not (without the emoji being cached or without the bot being in the server of the emojis)

hallow sandal
#

okay

pale vessel
#

emoji.animated?

marble juniper
#

I only have the id

#

I don't have the emoji object itself

pale vessel
#

ah

mossy vine
#

dont think you can get any data just from an id

marble juniper
#

and since there is a chance the bot isn't in the server of the emojis thats also a problem

pale vessel
#

you can try fetching the .gif version of the emoji and if the status code is not OK, grab the .png version instead

mossy vine
#

however the message content will include <a:name:id> if its animated wont it

marble juniper
#

do I just loop through the formats untill I get data sent back or what

pale vessel
#

just gif

marble juniper
#

thats what I meant

#

try if gif version works

#

and if not then png

hallow sandal
#

it still says that it's not compatible.

mossy vine
#

@marble juniper is checking if its animated all you need?

marble juniper
#

yes

#

since I only need the emoji link

#

I already have the id

mossy vine
#

wouldnt the message content include <a:name:id> if its animated

hallow sandal
marble juniper
#

yeah but idk how this module works since I just forked it

#

thats it

#

lol

#

Idk what the hell the regex does or anything

quartz kindle
#

lmao

marble juniper
#

I only modified it

#

explain to me what this does

mossy vine
#

if a .gitignore file is in a subfolder it will only apply to that subfolder right?

pale vessel
#

yes

marble juniper
#

ig

pale vessel
#

and the child folders ig

quartz kindle
#

jesus christ lmao

marble juniper
#

guess I will just try to loop through the formats

quartz kindle
#

i guess it parses unicode emojis?

marble juniper
#

uh yeah

#

also custom ones

hallow sandal
#

yeah

marble juniper
#

pretty much any emoji

#

the module didn't work since it didn't have .cache.get

#

thats the only thing I needed to fix

hallow sandal
#

it does only apply in the subfolder

pale vessel
#

why don't you use that instead (cache.get)

marble juniper
#

I did

#

but

#

ah forget it

#

I will loop through the formats with get requests

#

untill I get a result

#

that would be my solution

pale vessel
#

i think png format exists for all emojis so you only need to check for gif

#

i might be wrong

marble juniper
#

well after I changed an emoji url of a non animated one to gif it gave me a 415

#

so I can check for that status

#

with axios

#

lel

#

yep

#

that should be the solution

#

thanks yall for the help

#

cya

pale vessel
#

nice. np man cya

hallow sandal
#

does it work if the main code is inside a folder along with the reuirements.txt, procfile,etc and then deploy?

earnest phoenix
#

what is the sytem of bump bot?

#

how does the bump works

marble juniper
#

go ask in thier support server

pale vessel
#

probably not

#

but maybe if you change the path in procfile in the root

hallow sandal
#

so it has to be outside the folder?

pale vessel
#

so try putting the procfile in the root dir

hallow sandal
#

oh

#

but the procfile is on the same folder as the main code?

pale vessel
#

no

#

outside

#

the root of your application

hallow sandal
#

Oh alright

pale vessel
#

and make it python botFolderName/main.py or something

#

sorry idk python

hallow sandal
#

How can I remove the folder but keep the codes, etc?

pale vessel
#

you can use GitHub desktop

#

clone the repository and move all the files to root

hallow sandal
#

I'm on 32 bit though

pale vessel
#

and then commit and push to origin

#

should work i think

hallow sandal
#

Github desktop is on 64-bit though

pale vessel
#

oh

#

well maybe you can use git

#

otherwise, you're out of options

hallow sandal
#

hmm, I could make a new repo

pale vessel
#

how many files are there in that folder?

hallow sandal
#

and then put all the files except for the extra folder

#

36

pale vessel
#

yeah probably make a new repo

digital ibex
#

why are you using github tho

pale vessel
#

GitHub is good

earnest phoenix
#

@chrome field is it changing in your Developer Portal? or can you not use it anymore once it changed?

#

(expired token) NjY3ODIxMTQ0NTY4NjI3MjIw.Xq6isA.geGvNt9Ko8B6WstABS4dgREKOG8 because this part changes every time you reload your page

#

well atleast for me

pale vessel
#

hopefully the token was regenerated

earnest phoenix
#

it's an old one from a deleted application

chrome field
#

I don't do anything but it changes on its own, I don't even need to refresh the page

earnest phoenix
#

but can you still use the old one in your code?

#

or does it say it's invalid

chrome field
#

I can run if I am fast enough, but it is automatically renewed when not fast

digital ibex
#

gitlab is better

chrome field
#

I notified Discord support team, but they haven't returned for 2 days

earnest phoenix
#

i never had any issues with the token regenerating itself

#

no System Notifications either?

chrome field
#

no System Notifications either?
@earnest phoenix no

quartz kindle
#

@chrome field does your bot stop running?

#

or what is the problem

earnest phoenix
#

they're saying that the token gets regenerated randomly, making the old one invalid

chrome field
#

My bot token is constantly changing automatically and if I can't be fast enough when I reboot my old code, I need to reboot my codes

earnest phoenix
#

@chrome field Maybe you could just make a test code to check if that's maybe your codes issue or something, just a simple command returning your username

quartz kindle
#

does the entire token change, or only a part of it? because its normal for a part of it to change

chrome field
#

@chrome field Maybe you could just make a test code to check if that's maybe your codes issue or something, just a simple command returning your username
@earnest phoenix Ok i can try

#

does the entire token change, or only a part of it? because its normal for a part of it to change
@quartz kindle It refreshes even though I don't press the rebuild button
There is no problem in the way the token changes, but there is a problem in its constant change.

hallow sandal
#

Okay, so it did deploy and it worked.

#

But

#

the bot didn't went online

#

I dont see any errors on the logs as well.

quartz kindle
#

@chrome field what rebuild button? you mean the regenerate button?

chrome field
#

@chrome field what rebuild button? you mean the regenerate button?
@quartz kindle yes

quartz kindle
#

if only a part of it changes, its not a problem

#

its the normal behavior, and the changes dont invalidate older tokens

chrome field
#

if only a part of it changes, its not a problem
@quartz kindle there is no problem but the problem is that it changes every second even though I do nothing

quartz kindle
#

but if the bot works, its not a problem

chrome field
#

but if the bot works, its not a problem
@quartz kindle bot does not work because the token is constantly changing because the token is invalid when the bot will run

quartz kindle
#

hence why i asked, does the entire token change? or only a part of it?

chrome field
#

only part of it is changing

quartz kindle
#

then thats not the problem

#

your problem is somewhere else

#

not the token

chrome field
#

I'm currently trying to run it with simple codes

quartz kindle
#

if you dont explicitly regenerate the token, it will always work no matter how much it appears to change

#

because the key component is not changing, only the time component is

viral spade
#

Regarding my XP bot. As you know (tim) i changed the database engine from memory to innodb yesterday and cpu shows better performance.

However, you said i should cache stuff that gets accessed frequently. so i wonder if maybe it makes sense to let only the guild table in memory, because it is accessed with every message to check for the command prefix.

chrome field
#

okey, thank you for helping @quartz kindle

quartz kindle
#

@viral spade i would not rely on mysql memory

viral spade
#

ok, but will i need to cache the row, where the prefix is in sometime, right?

#

or wont this be a problem for the disk for a long time?

quartz kindle
#

MEMORY performance is constrained by contention resulting from single-thread execution and table lock overhead when processing updates. This limits scalability when load increases, particularly for statement mixes that include writes.

Despite the in-memory processing for MEMORY tables, they are not necessarily faster than InnoDB tables on a busy server, for general-purpose queries, or under a read/write workload. In particular, the table locking involved with performing updates can slow down concurrent usage of MEMORY tables from multiple sessions.

viral spade
#

oh sounds about the exact wrong usecase for an xp bot ๐Ÿ˜‰

quartz kindle
#

yup

#

prefix should be cached in the bot itself, like in the guild object for example

viral spade
#

ohh, i can safely add properties to the client object?

quartz kindle
#

what i do is this:

  1. check guild prefix
  2. if guild prefix doesnt exist, check database for guild prefix
  3. if database exists, put prefix in guild, if doesnt exist in databse, put default prefix in guild
  4. on prefix change, update both guild and database
#

yes as long as you dont accidentally overwrite something that already exists

viral spade
#

oh that is really nice

#

i thought i better not temper with the discord js object

#

and what is the amount of servers where someone should really implement the prefix check that way?

quartz kindle
#

the safest way is to create a custom namespace in your objects

#

for example, i use AppData

viral spade
#

oh that sounds also nice

quartz kindle
#

guild.AppData.prefix
user.AppData.lastCommand

#

etc

viral spade
#

namespace you simply mean like an extra property? not like in c?

quartz kindle
#

yes, a single property to contain everything that is specific to your bot, and not part of discord.js

viral spade
#

nice, i willdo it that way. So at what servercount would not implementing it this way bite me in the ass?

#

approx.

quartz kindle
#

you mean as compared to querying your db on every single message?

viral spade
#

yes

quartz kindle
#

querying the db on every single message will be bad since the very beginning, and exponentially get worse as your bot grows lmao

viral spade
#

hmmm. thing is, even with the prefix cached, i will need to call the database for almost every message anyways, because a message is either a command, or has to be added to stats (most of the messages).
So i guess i have to implement the cache for stats too (periodical flushing of groups), or i wont see much difference?

quartz kindle
#

i would cache everything that is checked on every single message, including non-commands

#

you can leave db queries for actual commands

viral spade
#

ok this would basically means, cache every setting (guild,guildmember,role,channels) and let all my like 30 setters operate on both, cache and db. And use only the cache when working off an event?

quartz kindle
#

yes

#

and only query the db when the event passes whatever it condition it needs to pass

#

for example once you confirm that a message starts with the correct prefix and contains a valid command

earnest phoenix
#

anyone know a library that can convert a string like "europe/berlin" to a number equal to it's current gmt ? so it would account for daylight saving hours

quartz kindle
#

moment.js can do that

#

they have a specific timezone module

earnest phoenix
#

hmm

#

when i search for moment.js there are multiple modules?

#

luxon?

split hazel
earnest phoenix
#

so npm i moment-timezone

split hazel
#

Yes

earnest phoenix
#

know a website you can enter and it displays the respective string you would have to input?

quartz kindle
earnest phoenix
#

that would work, but it's something i need the end user to provide

#

would it be possible to make a site maybe, that a user can click and upon visiting the site reveal their timezone indirectly through the http request or something like that

viral spade
#

Okay this is very comprehensive for me for settings tables (guild, guildchannel, guildrole, guildmember).

But with the stats tables (textmessage, voiceminute,vote,bonus) i am not sure.

First would you do it user.AppData.textmessages [channel,count]
or
channel.AppData.textmessages [user,count]
?

and then how would you flush it? A periodical infinite loop over all users/channels. Lets say users.
Then rotate over the users to calculate their possible levelups/totalScore and add it to the cache. Then rotate again over all users to take the rows for all/multiple users and add them in one transaction.

like this?

modest maple
#

id go with user

quartz kindle
#

are scores global per user or guild specific per user?

viral spade
#

guild specific

quartz kindle
#

so i would do like this

  1. on message check if member object has scores
  2. if no scores, retrieve scores from database and add them to member object
  3. do whatever updates you need to do to the member object
  4. push a copy of the update to the database
viral spade
#

Ok i see. Thats what i am already doing basically with the (former in-memory) database, to a remote database on another machine.
When a row in any table does not change for 1 hour, but maximum after 4 hours (if it has been changed), it will get pushed to my persisent remote database.

I thought using an in-memory db is like using "in-program variables" as cache.

So basically i could delete the "local" database completely, transfer my whole "local" database into cache/"program-variables" and update to the remote database from within the cache.

quartz kindle
#

depends, if you're not gonna push the cache to anywhere for hours, you could lose a lot of data on a crash/restart

viral spade
#

thats okay, if i get a lot of perfromance for it

#

settings tables are updated more frequent

earnest phoenix
#

where is the documentation to the moment-timezone lib?

quartz kindle
earnest phoenix
#

oh ty

#

oh nvm, the doc says npm has everything installed

slim heart
#

yo should i make my cluster master open like a utility http server rather then using purely worker message posting? idk if it'd be faster or not but feels like cuz atm it needs to send an event and then wait for another event back with the same ID and while that'd still happen on fetching data it wouldn't happen between requester and manager if it was http

viral spade
#

if i cache within the shards client object ,for example the guild, but also other tables, would you rather cache everything (like 50 rows with different settings) or really only the information needed like prefix and totalScore to check/select, so only "rare code" causes db queries.

I wonder should i really add specific stuff to the cache and let the rest be as is, or transfer like everything into the cache, before it lands on the (non-container) backup db., cutting out the db in between.

modest maple
#

@slim heart i would do uttility

#

otherwise its a real pain controlling your clusters globally

slim heart
#

right

#

well i mean less utility and more things like fetching guilds and such

earnest phoenix
#

how could i make the moment-timezone lib communicate with Date()? i'd like to calculate the utc offset or gmt of a given timezone ie convert "europe/oslo" to +2

slim heart
#

like the ability to get /guilds/id rather than sending a GUILD_FETCH and waiting for a GUILD_FETCHED back

modest maple
#

hmm

#

maybe

#

cant rlly be a bad thing

slim heart
#

current is what i do and works fine but if http is faster than i'm all for it

modest maple
#

i have all my clusters setup so they all host a small http server

#

and the master webserver allows me to control restarts turn shard on and off etc...

#

so the webserver tells each cluster what it is and what todo

slim heart
#

i don't think that's good practice tho

#

http servers on all clusters is bad

#

but idk abt http servers on only the master

modest maple
#

they only act as clients

#

so the server can send a receive data to and from the clusters

slim heart
#

that's what the worker thread messages are for

modest maple
#

i prefer not to have a file in control of it

#

deploying via k8s

#

scaling with that

#

each server is designated by the k8s router

#

tho idk how well js does sub process managing

slim heart
#

m websockets would be the best solution really

modest maple
#

yh

#

for me its easy enough just to have a small http server that is like 20 lines that just lets the containers talk to and from the other systems

#

tho all contained in VMs

quartz kindle
#

im looking into how to orchestrate something like that too

#

any of you tried out unix sockets or tcp messaging?

modest maple
#

I personally would say trying to scaling anything without containing it with docker or somthing is a bad idea

#

wayyy to easy to get dameons

slim heart
#

what i do with worker thread messaging will be the same as what is done with websockets if and when i scale across multiple machines

#

i just send message events with an e and d, e being event name and d being data payload

modest maple
#

how r u deploying it

slim heart
#

so it creates all the workers and if it were websocket wait for all of them to connect, at which point along with worker data would send the id of each cluster then the master sends SPAWN payloads with an array of shards to spawn and shard count etc, and when all the shards on the cluster ready up it sends READY back to master which then SPAWNs the next cluster

modest maple
#

ah

#

I use kubernetes stateful sets

#

so each scalled container has a incremented id

#

which the worker can get just from getting it's system name

slim heart
#

i'd rather not rely on a platform like that ig

modest maple
#

why not

slim heart
#

if i were doing websocket i'd just tell the cluster which id it is

modest maple
#

its considerably better than doing it with a file to control

rustic marsh
#

turkeyyyyyyyy

slim heart
#

cuz if i wanna change from kubernetes then yeet

modest maple
#

then thats easy?

quartz kindle
#

im thinking about doing the opposite, instead of a master sending spawn payloads, have the shard request permission to connect, and the master only controls rate limits and allows or denies

modest maple
#

k8s just uses docker containers which are good practice for deployment anyway

#

but overall it only takes one process to not close properly and then you start getting issues

#

which is where things like k8s are good

slim heart
#

well tim that would be better for largely scaled bots possibly, don't to very tiny increments i think. but the thing is you want them to spawn within identifyable times since it's heavily ratelimited

modest maple
#

not to mention the ability to dynamically scale and increase clusters / decrease them just by doing --scale xyz

slim heart
#

sort of the point of a master is to control not limit but it'd work ywah

modest maple
#

and setting limits to how much each cluster can use to stop one hogging or causing issues

quartz kindle
#

i have another idea in mind

#

that plays well with this method

#

hot-swappable/resumable shard restarts

slim heart
#

cf8 i just don't like the idea to locking everything i do to having to be on a platform (kubernetes). if i wanted to switch now there's a bunch of thing i'll have to reimplement which i could just do inside of the netes and not use a proprietary feature if that makes sense

#

also that'd be interesting yeah

#

be able to move shards off of specific clusters and then do whatever with it

modest maple
#

what we do for all our deployment for our sites n stuff all im sayin

slim heart
#

another reason i am sort of liking the idea of the http server is cuz atm i host the dashboard on cluster 0 which obviously isn't great but in order to move it off i'd have to outfit all the events to ignore it and yada itd be annoying. so an http server wouldn't require the worker to be a cluster thread n stuff

modest maple
#

Sounds like bad fore thought to me xD

viral spade
#

Would it be too much to cache my whole statistics data within the clients user objects?

user.AppData.stats.textmessage = [{guildid,channelid, values,..},{guildid,channelid, values,..},..]

user.AppData.stats.voiceminute= [..]
...

modest maple
#

yes

#

thats alot of users

#

therefore

#

alot of cache

viral spade
#

So should i only pick specific values to cache from each table? Like totalScore, prefix, ..

quartz kindle
#

if you put stats in the Member object, then you dont need to have the guild id on every item

#

less memory waste

viral spade
#

right, but would it be too much then?

quartz kindle
#

and yes, i would keep only the hot values in the cache, values that are accessed on every single message/event

slim heart
#

but anyways ig my question still stands is http faster or the same or slower then worker thread message exchange by any noticeable amount?

earnest phoenix
#

wait utc offsets that isn't just whole hours but also minutes is a thing?

#

+08:45

viral spade
#

yes, i would keep only the hot values in the cache, values that are accessed on every single message/event
So for statistics tables, where basically every message causes an update event, would caching 30 seconds+bundle in 1 transaction reduce the workload only a bit or drastically, compared to make a write in the db for every message?

quartz kindle
#

@slim heart in theory, http is much slower, but in the real world, the difference shouldnt be more than a few miliseconds

viral spade
#

Because i mean the same amount of data has to be written, only the overhead is less

slim heart
#

alright, sounds good

quartz kindle
#

but before jumping into http, i would look into unix sockets if same machine, or tcp if networking

#

@viral spade the amount of data written has a much lower impact than the amount of individual writes needed

#

think about downloading a 5mb file compared to downloading 50 100kb files

slim heart
#

aren't unix sockets just ipc?

viral spade
#

oh, interesting. Thank you!

quartz kindle
#

yeah, node's ipc module has all of them

slim heart
#

why would i use it?

quartz kindle
#

tcp is faster than http

slim heart
#

is it faster than the worker.postMessage?

quartz kindle
#

worker you mean worker threads in the same process?

#

or child processes?

slim heart
#

worker_threads

#

i'm capping my thread usage so that's why i started clustering

quartz kindle
#

since worker threads share memory, im not sure if their IPC uses sockets or something else, but most probably they are the fastest

#

but generally sockets are the fastest way of communicating between processes in the same machine

slim heart
#

right

quartz kindle
#

for multiple machines over network, tcp is the fastest

#

since udp is unreliable

slim heart
#

eventually when i move because of memory usage i'll end up doing that probably

#

gotta long way to go though lol

quartz kindle
#

another option i have been thinking about, would be using a database as some sort of master process, but that will most likely be slower

#

for example, keeping all caching in a redis db, so you have a unified cache throughout all shards

slim heart
#

i mean ik like redial

#

fuck

#

redis* but u already said it lol

#

i'm pretty redis can do a pubsub sort of thing

#

so communication and cache

quartz kindle
#

yes it can

slim heart
#

that'd be neat

#

i might look into redis

quartz kindle
#

im trying to write my lib with all that in mind

slim heart
#

never really thought i'd need it but might be cool

quartz kindle
#

hopefully it gets somewhere

slim heart
#

yeye

earnest phoenix
#

moment-timezone seems to only give gmt in whole hours, but when i google i come across a bunch of countries that has their gmt as hours and minutes

quartz kindle
#

how are you getting the offset?

earnest phoenix
#

wait is that a different norfolk

quartz kindle
#

i use it like this moment.tz.zone(timezone).utcOffset(date)

#

but my use case is different

earnest phoenix
#

oh i use it like

#
if (message.channel.id == "702161547421810824") {
        if (message.content.startsWith("+hey")) {
            message.delete();
            message.channel.send("All Works!");
        } else {
            message.channel.send("Delete does not work!")
            message.delete();
        }
    }

Why does he not go in the else-block?

#

context?

#

well if the message doesn't start with +hey, it says "Delete does not work!"

#

that's what your code does

viral spade
#

Tim if you want you can look for a <5$ key on g2a and i buy it for you and send you the key as a little thanks

quartz kindle
#

there isnt anything im interested in on g2a at the moment, but thanks :3

mossy vine
#

should i use mongodb or redis for longer cooldowns (hours to day)

#

(im using mongodb as a general database anyways)

quartz kindle
#

then stick with it

mossy vine
#

aight

earnest phoenix
#

i tried fetching channels from the quick.db

#
let fetched = await message.guild.channels.forEach(channel => attachmentchannels.fetch(`${message.guild.id}.${channel.id}`))```
#

and its returning undefined when i console log it

#

@earnest phoenix If I write a message with kek it will come nothing

#
let fetched = await message.guild.channels.forEach(channel => attachmentchannels.fetch(`${message.guild.id}.${channel.id}`))```

anyone knows what the problem is ?

#

@earnest phoenix then dont console log it

#

bruh

#

200iq

#

if you dont have a real answer then dont answer

#

How do u saving data?

slim heart
#

you're providing no information what any of this means

#

also don't post twice

earnest phoenix
#

oh..

slim heart
#

we need an error and what you're actually trying to do

earnest phoenix
#

im using quick.db to store the data

slim heart
#

oh

#

forEach doesn't return results

earnest phoenix
#

so what is

slim heart
#

you can use something like map

#

channels.map(x=>fetch(x stuff))

#

that'll give you an array of promises

#

which you can Promise.all

earnest phoenix
#

now its sending
1,1

#

(2 channels)

#

i need to get the name tho

#

@slim heart

slim heart
#

i told you what you need to do idk what else you're trying to do so

earnest phoenix
#
let fetched = await message.guild.channels.map(channel => attachmentchannels.fetch(`${message.guild.id}.${channel.id}`))```
#

its returning 1,1

#

(which are the 2 channels)
but i need the name

#

Bro jpb you know how to

#

Do

slim heart
#

then just .name

earnest phoenix
#

it doesnt seem to be working

slim heart
#

what're you doing

earnest phoenix
#

i tried putting .name after `)

slim heart
#

Bro jpb you know how to
@earnest phoenix no you're entire question is extremely vague

#

no you need to map the response

viral spade
#

replace id with name

earnest phoenix
#

but im fetching the id

#

You now Python dict

#

no you need to map the response
@slim heart how to

#

i dont use map so much

slender thistle
#

@earnest phoenix access the key data

earnest phoenix
#
let fetched = await message.guild.channels.map(channel => attachmentchannels.fetch(`${message.guild.id}.${channel.id}`))```
this is the current code
im so confused lmao
#

Bro can example bro

slender thistle
#

and since that seems to be a list that's the value... ['data'][0] and then access the key question_id from the returned data

#

Accessing dict keys in Python is basic language knowledge, though nekothinking

#

You access a dict key like some_dict['my_key_ooo']

earnest phoenix
#

shivaco, how can i map this?

#
let fetched = await message.guild.channels.map(channel => attachmentchannels.fetch(`${message.guild.id}.${channel.id}`))```
this is the current code
im so confused lmao
slender thistle
#

Why are you assuming I speak JS

earnest phoenix
#

i was told i need to map the response when i used foreach

#

:noidea:

pale vessel
#

what are you trying to do

slender thistle
#

Well that's my answer to your question :^)

earnest phoenix
#

fetch all channels that are in the db

pale vessel
#

so why do you need map

earnest phoenix
#

i tried forEach but i was told i need to use map

#

forEach returned undefined

#

Thanks bro shivaco

royal portal
#

I'm not sure how to make my code so if you have the role, the code wont run

pale vessel
#

check for member roles

royal portal
#
client.on('message', (message) => {
  if (message.content.includes('discord.gg/'||'discordapp.com/invite/')) {
    message.delete()
      .then(message.channel.send('no invites allowed'))
  }
})
slim heart
#

i dont use map so much
@earnest phoenix then google it

earnest phoenix
#

i tried but i didnt find anything

pale vessel
#

lies

earnest phoenix
#

fr

slim heart
#

very

#

no you're either lying or blind man idk what to tell you but we're not here to give out code

pale vessel
#

it's literally the first result when you google "map js "

earnest phoenix
#

i looked for map response

slender thistle
slim heart
#

no Array.map

slender thistle
#

Found with javascript map

slim heart
pale vessel
#

if you can't use google then you can't code

earnest phoenix
#

but i looked for map response

#

not js map

#

i now did

#

yeah i didnt

#

google uses keyword searching, not 23rd century technology that reads your mind

#

lmaoo

slim heart
#

lmao

mossy vine
#

how the fuck do i display a Set in a string without having it as [object Set]

earnest phoenix
#

i did it

#

lmao

#

with array

#

i didnt

#

D:

pale vessel
#

@mossy vine just stringify it

mossy vine
#

why did i not think of that

#

nvm doesnt work

pale vessel
#

it should

earnest phoenix
#

Guys do you know why it shows (Object, object) in Discord.js?

const playembed = new Discord.MessageEmbed()
.setTitle(`${song.title}`)
.setColor(`RANDOM`)
.setURL(`${song.url}`)
.setDescription(`๐ŸŽถ Sta cominciando: **${song.title}**`)
var playingMessage = await queue.textChannel.send(`${playembed}`);```
pale vessel
#

try await queue.textChannel.send(playembed);

earnest phoenix
#
let fetched = await message.guild.channels.array(channel => attachmentchannels.fetch(`${message.guild.id}.${channel.id}`))```
its returning every channel in the server
#

lmao

#

k let me try

#

It doesn't work @pale vessel

#

Hi, I have a question, how can I do to play a song with a link but then a command to skip that song? xD

amber fractal
#

make a queue system

earnest phoenix
#

I have it

#

xD

#

but i don't know how to do to play the link with the command

#

add it to the queue*

quartz kindle
#

if you made a queue system, you should know how to do that lol

earnest phoenix
#
let fetched = await message.guild.channels.array(channel => attachmentchannels.fetch(`${message.guild.id}.${channel.id}`))```
its returning every channel in the server
pale vessel
#

@quartz kindle not if they copy and pasted it from a guide mmLol

#

@mossy vine did you solve the set thing

quartz kindle
#

that would mean he didnt make it :^)

earnest phoenix
#

It's from my friend

mossy vine
#

@pale vessel yes by not using a set because i realized its not even what i need

earnest phoenix
#

xd

royal portal
#
client.on('message', (message) => {
if (!message.member.roles.cache.some(role => role.name === 'Allowed')) return;
  if (message.content.includes('discord.gg/'||'discordapp.com/invite/')) {
    message.delete()
    message.channel.send('invite links not allowed')
}
});

im not sure where to put the role checking so if role 'Allowed' then don't delete their message and if they dont have the role then delete their message

pale vessel
#

how did you try to stringify the set though

mossy vine
#

doesnt matter as i literally dont need to use a set

pale vessel
#

ok

#

JSON.stringify(set) would've worked

copper cradle
#

@earnest phoenix you're sending the object inside a string, just send the plain object, who told you to string interpolate it?

rotund lantern
#

@pale vessel hello man thanks for your help

#

i can do embed messages

royal portal
#

I got an error

#

FetchError

#

path /gateway/bot

#

is discord down?

tight forum
#

hello there

#

i upgraded my bot from node 10 to node 12 and upgraded all packages

#

i guess there is no bot.guilds.reduce in node 12

#

what should i use instead?

pale vessel
#

guilds.cache

#

did you upgrade to d.js v12?

#

idk why i assumed you did

tight forum
#

yeah upgraded

#

using 12.2.0

pale vessel
#

well guilds is now a manager

#

that holds the cache

#

read the guide i sent you

tight forum
#

im reading it

#

ty

delicate zephyr
#

All the .send***() methods have been removed in favor of one general .send() method.

#

finally

quartz kindle
#

wasnt it already deprecated for years anyway?

delicate zephyr
#

yea

#

but they finally remove it entirely

quartz kindle
#

it was already removed from master all those years it was not stable yet lmao

delicate zephyr
#

One of my bots is one v11

#

since I never updated it

#

since it still works fine

quartz kindle
#

if its not broken, dont fix it

delicate zephyr
#

but I always replaced .sendM with .send

#

and yea

#

XD

quartz kindle
#

i have a bot thats also in a very weird state

#

using discord.js master before the addition of the .cache thing

#

so its neither v11 nor v12 (well, its v12.0.0-dev)

#

lmao

restive furnace
#

i prefer v12.0.0-dev

#

cache is weird thing

#

but mostly nowdays i use eris :D

digital ibex
#

hi,

let a = `${guild.tags.find((e) => message.content === e.name)}`;
    if (a) {
        return message.channel.createMessage(`${a.response}`);
    }```
 i have this, how can i check for tag being in front of the a? so the syntax would be !tag hi and not !hi which it is atm, anyone got any ideas?
pale vessel
#

no idea what tags are

restive furnace
#

@digital ibex simply "a?tag " + a

heavy anchor
#

Am I doing something very stupid here or is this right? .setImage('https://top.gg/api/widget/702935974308741140.png?v=' + (Date.now() >> 0).toString(36))

#

It's not loading any picture

#

To load the DBL stats widget into an embed

digital ibex
#

it won't let me

#

i get an error a is undefined

copper cradle
#

where are you using a

restive furnace
#

a is the tag

copper cradle
#

In the code

#

not what it is

restive furnace
#

if (a) {

copper cradle
#

yes but

#

if they're using it anywhere else

digital ibex
#

yes

merry dagger
#

anybody know how to make a bot for WoW private servers; example below:

restive furnace
#

just like a normal bot

pale vessel
#

those probably use APIs

merry dagger
#

yeah API's are available

#

im just not sure how to go about it...

restive furnace
#

axios on js, http on python

surreal notch
#
  const args = message.content.slice(prefix.length).split(" ");
  const command = args.shift().toLowerCase();

  if (command === `subtract`) {
    const user = message.mentions.members.first();

    if (!user) {
      message.channel.send("Please mnetion someone");
    }

    if (!args[1]) {
      return message.channel.send(`Please give the amount`);
    }

    let cdata = db.get(`cdata_${message.author.id}`);

    if (cdata === null) cdata = 0;

    if (args[1] > cdata) {
      return message.channel.send("You do not have enough money");
    }

   db.subtract(`cdata_$(user.id)`, args[1]);
    await message.channel.send("Money subtracted successfully");
  }
});```
I am trying to subtract money from a user's acc. but now working
#

now error

#

but money is not subtracting

slender thistle
#

-needdev

gilded plankBOT
#

DBL is not a place to find developers for jobs. You can try and put a request on Fiverr or Freelancer. Please do not post the request again. Doing so may result in punishment.

merry dagger
#

got it @slender thistle

heavy anchor
#

oops

earnest phoenix
#

umm

#

what

#

oop dw

restive furnace
#

503

#

cant do anything

earnest phoenix
#

kk

#

ty

slender thistle
#

Wrong channel

restive furnace
#

its website admins problem

slender thistle
#

also try again a bit later

royal portal
#

can anyone help me with my code, the permissionsFor isnt working

#
client.on('message', (message) => {
  if (message.member.roles.cache.some(role => role.name === 'Server Administrator')) return;
  if (message.channel.permissionsFor(message.guild.me).has("SEND_MESSAGES","MANAGE_MESSAGES", true)) {
  if (message.content.includes('discord.gg/'||'discordapp.com/invite/')) {
    message.delete().catch()
    const embed = new Discord.MessageEmbed()
    .setColor(15158332)
    .setTitle("Access Denied")
    .setDescription("Invite links are not allowed in this server. \n Please make sure you have the `Server Administrator` role then try again.")
    message.channel.send(embed).catch()
  }
}
});
copper cradle
#

that's not how includes works

#
if (message.content.includes('discord.gg/') || message.content.includes('discordapp.com/invite/'))
royal portal
#

I fixed it now but the permissionFor isnt work

copper cradle
#

do you get any errors?

royal portal
#

nope

shell raptor
#

hey

royal portal
#

the problem is that

#

if you send an invite

#

in a channel

pale vessel
#

has("SEND_MESSAGES","MANAGE_MESSAGES", true)

#

bruh

#

it's has(["SEND_MESSAGES","MANAGE_MESSAGES"], true)

royal portal
#

oh

shell raptor
#

if(!message.member.hasPermission("MANAGE_MESSAGE")) return message.channel.send(You don't have permission);
const userMessage = args.join(" ");
await message.delete()
const botMessage = message.channel.send(userMessage);
botMessage.react('โœ…')

copper cradle
#

ah

pale vessel
#

wdym

shell raptor
#

why its dont work ?

royal portal
#

also

pale vessel
#

wdym it doesn't work

#

please explain

copper cradle
#

people think that with just a chunk of code we can guess what the rest of their workflow looks like

royal portal
#

I'm testing it now

#

I didnt test it with []

copper cradle
#

it's probably a problem with some other random shit

shell raptor
#

the bot doesnt react why ?

copper cradle
#

botMessage is a promise

#

await it

#

wait

royal portal
#

mine works now its just I don't know what to change this if (message.member.roles.cache.some(role => role.name === 'Server Administrator')) return;

copper cradle
#

since I highly doubt you've ever used async/await

#

do this

restive furnace
#

or use promises.

royal portal
#

because the user didnt send the message yet

#

so how would I check the role

copper cradle
#
const botMessage = message.channel.send(userMessage).then(msg => msg.react(':white_check_mark:'));
royal portal
#

because it sends cannot read property 'roles' of null

copper cradle
#

instead of using await

royal portal
#

in console

copper cradle
#

bc I don't want to explain how to use async await

restive furnace
#

@royal portal by fetching from ur bots cache.

royal portal
#

hm

pale vessel
#

if (message.member.roles.cache.some(role => role.name === 'Server Administrator')) return;
add a !

shell raptor
#

@copper cradle it dont work

copper cradle
#

wdym

#

I swear to god

#

show your code

royal portal
#

@pale vessel thats the part that doesnt work

#

the message part

copper cradle
#

with a code block

royal portal
#

because it cant read property 'roles' of null

shell raptor
#

how i made a code block ?

copper cradle
#

you didn't make it yet

#

that's past

pale vessel
#

```js
c o d e
```

copper cradle
#

```js
code here
```

shell raptor
#
const Discord = require('discord.js');

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

    if(!message.member.hasPermission("MANAGE_MESSAGE")) return message.channel.send(`You don't have permission`);
    const userMessage = args.join(" ");
    await message.delete()
    const botMessage = message.channel.send(userMessage).then(msg => msg.react(':white_check_mark:'));
};

module.exports.help = {
    name: "poll"
}
copper cradle
#

and please follow the markup

#

wait

#

remove const botMessage

#

bc you don't need that anymore

#

does it send the message?

#

do you get any errors in the console

shell raptor
#

no

copper cradle
#

change what I told you and show your code

shell raptor
#
const Discord = require('discord.js');

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

    if(!message.member.hasPermission("MANAGE_MESSAGE")) return message.channel.send(`You don't have permission`);
    const userMessage = args.join(" ");
    await message.delete()
    message.channel.send(userMessage).then(msg => msg.react(':white_check_mark:'));
};

module.exports.help = {
    name: "poll"
}
copper cradle
#

how come it doesn't react to it

shell raptor
#

idk

amber fractal
#

use the actual unicode character

shell raptor
#

what ?

copper cradle
#

oh wait

#

lmao

#

I didn't see that

amber fractal
#

White check mark is a real character supported

copper cradle
#

fuck

amber fractal
#

yeah you can't paste it anymore

#

idk why they did that

#

just look up white check mark on google and copy the character

pale vessel
#

just copy this

#

\โœ…

amber fractal
#

oh you can paste it

royal portal
#

add a !
@pale vessel thats not what i meant

shell raptor
#
const Discord = require('discord.js');

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

    if(!message.member.hasPermission("MANAGE_MESSAGE")) return message.channel.send(`You don't have permission`);
    const userMessage = args.join(" ");
    await message.delete()
    message.channel.send(userMessage).then(msg => msg.react('โœ…'));
};

module.exports.help = {
    name: "poll"
}
pale vessel
#

ok

shell raptor
#

like this ?

copper cradle
#

yes

pale vessel
#

you didn't tell shit, how am i supposed to know

royal portal
#

or else it will delete invites if the user has the role

copper cradle
#

what flazepe said

royal portal
#

the problem is that im not sure on how to replace the message part in if (message.member.roles.cache.some(role => role.name === 'Server Administrator')) return;

shell raptor
#

oh its work thx !!

royal portal
#

because the member didnt send the message

pale vessel
#

ok tell us if there is any error

royal portal
#

cannot read 'roles' of null

amber fractal
#

member is null

#

not cached most likely

pale vessel
#

console.log(message)

cinder patio
#

are you sure message is what you think it is

royal portal
#

im trying to make it so if you dont have the role 'server administrator' then delete their invite and send the 'access denied' message and if they have the 'server administrator' role then let them send the invite

pale vessel
#

that's exactly what i did

#

i said put a !

shell raptor
#

ok

pale vessel
#

because some will return a boolean

#

but that's not the problem here

shell raptor
#

and now how i put โŒ with the mark ?

copper cradle
#

not you sarloux

pale vessel
#

\ โŒ

copper cradle
#

if you want to

#

duh

pale vessel
#

ook no

royal portal
#

if i add the ! then people with the role cant send links with discord.gg

pale vessel
#

only some emoji works

shell raptor
#

\โŒ

royal portal
#

im trying to make it so people with the role are allowed to send invites

shell raptor
#

how i put it too ?

royal portal
#

and people without are not allowed

pale vessel
#

so if they don't have the role, which is false

#

or oh wait

#

return means it doesn't do anything

royal portal
#

yeah but at the start it has message.

pale vessel
#

never mind then

royal portal
#

and the user didnt send a message

cinder patio
#

cannot read 'roles' of null
@royal portal Do you check if the message is sent in DMs? messages sent in DMs won't have a member property

royal portal
#
client.on('message', (message) => {
if (message.author.bot) return;
if (message.channel.type === "dm") return;
  if (message.member.roles.cache.some(role => role.name === 'Server Administrator')) return;
  if (message.channel.permissionsFor(message.guild.me).has(["SEND_MESSAGES","MANAGE_MESSAGES"], true)) {
  if (message.content.includes('discord.gg/'||'discordapp.com/invite/')) {
    message.delete().catch()
    const embed = new Discord.MessageEmbed()
    .setColor(15158332)
    .setTitle("Access Denied")
    .setDescription("Invite links are not allowed in this server. \n Please make sure you have the `Server Administrator` role then try again.")
    message.channel.send(embed).catch()
  }
}
});
#

done

#

but it still will do the error

#

randomly

#

because its before the user sends the message

#

it might be fixed now

#

let me check

shell raptor
#
const Discord = require('discord.js');

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

    if(!message.member.hasPermission("MANAGE_MESSAGE")) return message.channel.send(`You don't have permission`);
    const userMessage = args.join(" ");
    await message.delete()
    message.channel.send(userMessage).then(msg => msg.react('โœ…, \:x:'))
};

module.exports.help = {
    name: "poll"
}
#

fuck

copper cradle
#

???

shell raptor
#

oh i can make this

copper cradle
#

๐Ÿคฆโ€โ™‚๏ธ

shell raptor
#

hahaha

copper cradle
#

that's not how you do it

#

you need the plain emoji first

shell raptor
#

i know

copper cradle
#

and react only takes in one argument

#

so you need multiple react statements

tardy estuary
#

technically that is only one argument lol

copper cradle
#

for every emoji you want to add to the message

shell raptor
#

how ?

copper cradle
#

@tardy estuary still wrong

tardy estuary
#

for sure

#

its not gonna do what he is expecting it to do

copper cradle
#

yeah lol

shell raptor
#

i want like this

#

test

#

this

copper cradle
#

you'd do something like this

tardy estuary
#

you'll have to add two reactions to the same message

#

2 lines of code for that, afaik

copper cradle
#
msg => {
  msg.react('โœ…');
  // then add more react functions
}
tardy estuary
#

yeah that

copper cradle
#

now they copy and paste this into a random line in their code

shell raptor
#

oh

copper cradle
#

'why is bot not work'

shell raptor
#

i will try it

copper cradle
#

lmao

tardy estuary
#

lool

#

this is the new stackoverflow

copper cradle
#

don't copy and paste it

#

lmao

tardy estuary
#

im totally cool with people learning how to code, but yeah its frustrating when they just copy your example without knowing what its doing

#

but anyway im just gatekeeping lol

shell raptor
#

okay but how i can do this

tardy estuary
#

what exactly do you want to happen when the user doesn't have the correct permission to do what they are doing?

viral spade
#

Lets assume i have two bots on two vps with a persistent database on each. The entries in the databases correspond to guilds in the respective bot.
Now i want to let the bot run on 3 machines and increase the number of shards. From what i understand by the sharding formula, guilds will be reassigned to different shards when increasing the amount of shards.

Is there any way to increase shards and machines without reassigning the guilds to different shards, so each guild stays on the vps where the data is? How is this problem solved usually?

quartz kindle
#

there is no way to define which guilds go where

#

the problem is solved by having the database on the network

#

and have all shards connect to it remotely

#

or, using a replication system like redis does, where all machines have a full copy of the database, and they keep each other updated

copper cradle
#

sarloux

#

I already told you

#

what to do

tardy estuary
#

im pretty much wondering if hes returning too early for what he wants to happen?

quartz kindle
#

or if you wanna go a different route, you can always do a full database rebalancing/reorganizing when you change the total shards, and move all guilds to their new locations lol

shell raptor
#

ok its done

viral spade
#

it seems just crazy to combine all the data, because it could be sharded so well too and doesnt need to reside in one database. i guess certain operations will be more costly for each entry in the database.

so what do you do when you are at the point that this combined database, where every shard connects to, bottlenecks you (assuming there is no further optimzations via cache,etc. possible)

hasty salmon
#

Am I allowed to show the list of the servers that my bot is in?

quartz kindle
#

your database will never bottleneck you if you use it correctly, considering its designed to handle millions of operations per second

viral spade
#

even tough its running on one machine?

quartz kindle
#

but if you ever need that kind of scaling, big services like discord/facebook/twitter/etc use ditributed database systems and horizontal scaling

#

but its still all over network

#

queries are made to load balancers, which then redirect them to instances of a clustered database either by load if the data is replicated, or by indexing, if the data is distributed

#

so you would still not have 1 database on each bot machine, you would have each database on a dedicated machine for the database, and communicate to it remotely from your bot machines

earnest phoenix
#

How i can see what server my bot in ?

#

How i can see what server my bot in

#

-_-

#

in which lib

#

discord.js

#

guilds property on your client

#

?

copper cradle
#

"who is that???"

earnest phoenix
#

how can u give me example code ??

copper cradle
#

I knew it lmao

#

no

earnest phoenix
#

Lmao

#

bruh

amber fractal
#

it's literally just accessing properties

#

basic js

earnest phoenix
#

i can

#

but i won't

copper cradle
#

guilds property on your client: the guilds property that your client instance has

#

dude

#

it's basic knowledge

amber fractal
copper cradle
#

how can you not understand that

#

holy cow

earnest phoenix
#

@copper cradle No i dont :))

tardy estuary
#

bot developer role seems loosely handed out lol

earnest phoenix
#

GWonoNanamiWhat how did you code your bot then if you don't understand that

#

perish, help vampire โœ๏ธ

copper cradle
#

maybe stack overflow

earnest phoenix
#

for legal reasons what i said is a joke

#

example code pls :))

#

no

#

try to figure it out yourself

copper cradle
#

it's just 2 words holy fuck

earnest phoenix
#

We can only give you tips

copper cradle
#

to get your bot's guilds you can use your client's guilds property

tardy estuary
#

assuming discordjs v12, client.guilds.cache should get you started

copper cradle
#

read that

#

and select keywords

earnest phoenix
#

You can even get example codes by googling, you won't get one from us

copper cradle
pale vessel
#

ew

earnest phoenix
#

Better than just getting spoonfed

viral spade
#

@ Tim. So i shouldnt need any database sharding for my project forever? But then i am doing something wrong with my remote database.

When f.e. i have to reset the stats of all guildmembers of a guild, i set all the ([channel,user,values]) records to their defaults for 4 tables. This takes about half a minute for my remote mysql server. During that time it is at max capacity and wont answer other requests.

This works now, with only a few resets from time to time, but this cannot work anymore with 10x the servers..

earnest phoenix
#

Better than just getting spoonfed
@earnest phoenix you're saying that as if they won't find what they need and copypaste it without reading the explanation lol

copper cradle
#

I mean if you don't understand that 'your client's guilds property' means client.guilds.cache in v12 and client.guilds in v11 and < then how did you make an entire functioning bot

tardy estuary
#

yep pretty much

royal portal
#

what do you guys think of this?

mossy vine
#

server administrator role?

#

dont you mean administrator permission

royal portal
#

yes

#

no

#

i have it role only

valid frigate
#

huh

#

why

limpid isle
#
Error: Incorrect login details were provided.

Guys, I'm getting this error, does anyone know the solution?

royal portal
#

yes wrong token

valid frigate
#

are you sure you can't bind it to a specific permission

earnest phoenix
#

so i wanted to see what server my are in

turbid bough
#

@royal portal Just do a check if they have permission to create invite links

valid frigate
#

like administrator or manage messages

cinder patio
#

That's kinda inconvenient, better check for the administrator permission or something else

earnest phoenix
#

i used this commands

turbid bough
#

there is no need to check for admin perms

#

just check for invite perms

valid frigate
#

i think he means denying discord link posting

#

not necessarily creating them

royal portal
#

@turbid bough its not a problem im just wondering if you guys like it or not

turbid bough
#

or yeah if its for configuration

valid frigate
#

o you mean the design

royal portal
#

yea

valid frigate
#

i mean its pretty standard so yeah no problem with it

earnest phoenix
#

guild.createInvite({ unique: true }).then((invite) => {
console.log("Your new invite link is: https://discord.gg/" + invite.code);
});

turbid bough
#

idk it looks like discord

earnest phoenix
#

what is wrong ?

turbid bough
#

you posted it 3 times now

valid frigate
#

nice and clean and not filled with fields that arent aligned properly

royal portal
#

I just don't know if I should change 'then' to 'and'

#

should I?

valid frigate
#

if you want to keep then

#

add a comma after role

royal portal
#

or keep

valid frigate
#

otherwise you can substitute then for and

#

both mean the same thing so your choice

royal portal
#

so 'please make sure you have the server administrator role, then try again.'

valid frigate
#

sure

royal portal
#

dbl is like an online class lol

turbid bough
#

You could also use a ping instead too

#

so it would change by name automaticly

royal portal
#

well

tardy estuary
#

there are numerous messages you could post there. do whatever you think sounds fine

clear wraith
#

May I ask for assistance... So im working on a addrole command, but mines doesn't seem to give the users the role mentioned, and it tells me that they already have it. but from my looks they dont.

Screenshot

turbid bough
#

code?

clear wraith
#

Yeah, 1sec

royal portal
#

its been 5 secs

#

now 8 secs

earnest phoenix
#

nvm

clear wraith
#

module.exports = {
    name: "addrole",
    category: "Moderation",
    description: "Adds a role to a specific member",
    run: async (client, message, args) => {
        if(!message.member.hasPermission("MANAGE_ROLES")) {
            return message.channel.send("You don't have permission to execute this command")
        }
        
        if(!message.guild.me.hasPermission("MANAGE_ROLES")) {
            return message.channel.send("I don't have permission to execute this command.")
        }

        let rMember = message.mentions.members.first() || message.guild.members.cache.find(m => m.user.tag === args[0] | message.guild.members.cache.get(args[0]))
        if(!rMember) {
            return message.channel.send("Please provide a member to add a role")
        }

        let role = message.guild.roles.cache.find(r => r.name === args[1] || message.mentions.roles.first)
        if(!role) {
            return message.channel.send("Please provide a role to add to the member.")
        }

        let reason = args.slice(2).join(" ") || "Unspecified"

        if(rMember.roles.cache.has(role.id)) {
            return message.channel.send(`${rMember.displayName} already has the role!`)
        } else {
            await rMember.addRole(role.id).catch(err => console.log(err.message))
        }

        let embed = new MessageEmbed()
            .setColor("GREEN")
            .setAuthor("Role successfully Added!")
            .addField("Role added to:", rMember)
            .addField("Moderator:", message.author.username)
            .addField("Reason:", reason)
            .setFooter(client.user.username, client.user.displayAvatarURL())
            .setTimestamp();

        message.channel.send(embed)

    }

}```
#

There ya go

earnest phoenix
#

I wanted to create a invite in every server my bot in

#

so please help me

tardy estuary
#

@royal portal in your message above, you're saying a server administrator is the only role that can send invite links?

clear wraith
#

@turbid bough ^^^

royal portal
#

yes

limpid isle
#

Guys do you know why this token error is happening?

valid frigate
#

might be because you're getting it from the cache?

#

not sure

royal portal
#

select your application

#

regenerate the token

limpid isle
#

okey

royal portal
#

copy the token, add it to the code

limpid isle
#

thanks

uneven lichen
#

Where I should paste this script: if(msg.content.toLowerCase()==="cancel") return; when I write cancel, the queue I'm searching for has been cancelled, and so I can search for a new one without duplicating the search.
Script:

exports.run = (client, message, args, ops) => {
  
  search(args.join(' '), function(err, res) {

    if (err) {
      if (message.deletable) message.delete(5000)
      return message.channel.send('Sorry something went wrong')
      .then(m => message.delete(5000));
    }
    let videos = res.videos.slice(0, 10);
    
    let resp = '';
    
    for (var i in videos) {
      
      resp += `**[${parseInt(i)+1}]:** ${videos[i].title}\n`;
    }
    
    resp += `\n Choose a number in between: **1-${videos.length}**`;

    const Embed = new Discord.RichEmbed()
    .setAuthor('Searching', thumbnail, invite)
    .setColor("BLUE")
    .setDescription(resp)
    .setTimestamp()

    

    const filter = m => !isNaN(m.content) && m.content < videos.length+1 && m.content > 0;


    const collector = message.channel.createMessageCollector(filter)

    collector.videos = videos;
    
    message.channel.send(Embed)
    console.log(chalk.green('Searching for music...'))
    
    
  

    collector.once('collect', function(m){
      

      
      let commandFile = require('./play.js');
      
      commandFile.run(client, message, [this.videos[parseInt(m.content)-1].url], ops)

  
    
    });
 
  
  });


}

amber fractal
#

@clear wraith first is a function, you're missing a second | in the members.cache.find() function, first() returns the value, which is a role so you don't need to get the role if you have it, you should message.mentions.roles.first() || find function like your first one does https://oliy.is-just-a.dev/zaoo4h_3789.png

clear wraith
#

ok

#

ohhhh

amber fractal
#

also... why are you using find on a get

#

?

clear wraith
#

to find the role

surreal notch
#
if(message.content.toLowerCase() === `${prefix}search`) {
    var numbers = [ 0
];


let cdata = db.get(`cdata_${message.author.id}`)
  
  if(cdata === 0) db.subtract(`cdata_${message.author.id}`, 30)
  
    var answer = numbers[Math.floor(Math.random()*numbers.length)];
if(answer === 0) {

 return message.channel.send(`You caught robbing a bank and paid a fine of 30 coins`)
 db.subtract(`cdata_${message.author.id}`, 30)
}
    var embed = new Discord.MessageEmbed().setColor("#FF4500").setTitle("**Redeem Coins**")

    .setDescription(`You have found **${answer}** coins`)
    db.add(`cdata_${message.author.id}`, answer)
    message.channel.send(embed)
    }
})```
whenever i use p!search if the winning ammount is getting in my account but whenever i lose means 0 the ammount is not subtracting from my acc.
clear wraith
#

or the user

amber fractal
#

yeah but get will return it already so why use find on it afterwards

#

just uses more ram and cpu

shut inlet
#

ive installed node-fetch like 9 times

tardy estuary
#

am i the only person that doesnt like writing one line if statements on the same line? lol

earnest phoenix
#

How i can make a invite when mys bot is ready????

magic jackal
#

npm i node-fetch -g

queen needle
#
if (message.content.startsWith(prefix + "reset")) {
    if (message.author.bot) return;
    if (message.author.id !== "606279329844035594")
      return message.reply("You can not use this command");
    resetBot(message.channel);

    // Turn bot off (destroy), then turn it back on
    function resetBot(channel) {
      // send channel a message that you're resetting bot [optional]
      channel
        .send("Resetting...")
        .then(msg => client.destroy())
        .then(() => client.login(token));
    }``` how could i make it so it sends a message when my bot goes back up
magic jackal
#

?

tardy estuary
#

your question has some grammar issues, im not sure I understand what you're asking

earnest phoenix
#

How i can make invite when my bot is ready, and it will console.log to me

surreal notch
#

@tardy estuary ik

#

but how to do that?

turbid bough
#

bot.on("ready") im guessing

surreal notch
#

i tried a lot ways

tardy estuary
#

do what, exactly?

earnest phoenix
#

:(((

#

:((

turbid bough
#

:(

slim heart
#

npm i -g node-gyp @shut inlet

delicate zephyr
#

@earnest phoenix stop spamming...

surreal notch
#

I have a bot cmds which send money in account of user so I am trying p!search cmd if the person wins then he gets prize in his account but if he loses the amount is not subtracting from his account

tardy estuary
#

@surreal notch you are returning when answer === 0

earnest phoenix
#

ok

tardy estuary
#

and the subtraction is not happening

magic jackal
#

@earnest phoenix client.on('ready', async () => {})

tardy estuary
#

if thats what you wanted to happen

magic jackal
#

read the docs

tardy estuary
#

that code never runs

earnest phoenix
#

yes but the invite funciton

shut inlet
#

that makes no fucking sense

surreal notch
#

so i have to remove return?

magic jackal
#
client.on('ready', async () => {
  console.log(`Logged in as ${client.user.tag}!`)
})```
turbid bough
#

what is the "invite function"

surreal notch
#

@tardy estuary

magic jackal
#

@earnest phoenix What about it?

valid frigate
#

you dont need async

earnest phoenix
#

I want when bot is ready to make a invite

#

and send it to console.log

valid frigate
#

client.on('ready', () => console.log())

earnest phoenix
#

bot.on("ready", async (message) => {
console.log(${bot.user.tag} is ready);
bot.user.setActivity("/help", { type: "LISTENING" });
bot.user.setStatus("idle");
channel.createInvite({ unique: true }).then((invite) => {
console.log("Your new invite link is: https://discord.gg/" + invite.code);
});
});

Discord

Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.

tardy estuary
#

@surreal notch does the line if(answer === 0) { mean you "lose" and need to have 30 coins subtracted?