#development
1 messages ยท Page 931 of 1
i personally disable voicestates, roles, members, channels, channel permissionOverwrites, presences, users
but doesnt your bot require presences?
not yet but its a feature in consideration
ah i though your statistics involved presences, hence why such cpu usage
wait is it just me or i'm wrong writing the codes so it appear a error like this "Discord.RichEmbed is not a constructor".
if your resources were already that bad i cant imagine with presences lol
@fickle arch RichEmbed was removed in v12
and replaced with MessageEmbed
ah alright
but it seems to me i cannot really deactivate caches, so it will not make much ram difference what lib i use, right?
if you need to track changes, you cannot disable caches
but there is a difference between how each lib caches
in you case, you could get a fairly decent improvement by caching small objects containing only the info you need
compared to storing full instances of a class
yes, like you said deactivating f.e. voicestates?
voicestates are also disablable via intents
(i dont use voicestate, only if the user is part of the channel)
and those are also disablable in d.js?
all intents?
dude i rellay dont know should i switch now from discord.js to eris, or something else. i feel like its not worth it to switch for now. what would you do?
Hi guys, simple discord js bot question. I want my bot to send an image file. It basically sends street fighter combos which are in an image.
I've got it with if statements to send an image based on a command but instead of having hundreds of if statements I want the user to define it and the bot will find and send the image file by that request. So a user can go !cammy and the bot will see if there's an image with that name and send it.
Sorry I'm new to all this and had trouble trying to google an answer.
where are you getting the images from?
stored as jpgs in my github repo
have on object of images with the keys being the command name/combo
So at the moment we have it as
if(msg==prefix+'akumasf2'){
message.channel.send("Akuma's Moves for Street Fighter II", {
files:["./SF2moves/akuma.PNG"]})}
lots of times for each character
so if args includes Object.keys(images)
images being the object of image paths and names
Is there a way instead, the user can just define the name they want and it can be filled in. So for example, where it says "Akuma", instead this can be a placeholder for the whatever the user puts in and the code runs based on the argument the user sends.
Sorry, still learning
there are many ways to do this
wish i could be able to opt out of presence packets but i cant
so i just stop caching them
why cant you opt out
because of the way it affects guild members
let command = msg.slice(prefix.length);
// method 1
files:[`./SF2moves/${command.toLowerCase()}.png`] // must match exact name. no built in option to change sf2 to another game
// method 2
let list = {
"akumasf2":"./SF2moves/akuma.pnk",
...
}
files:[list[command.toLowerCase()]] // must match exact name and exact game
// method 3
let list = [
{
names: ["akuma","akumasf2"],
url: "./SF2moves/akuma.pnk"
}
...
]
files:[list.find(item => item.names.includes(command.toLowerCase()))] // more flexible, can have multiple names and aliases for the same url
``` @humble plaza
how are you impressed, im just confused
can learn from this
another option is to change your command to something like !moves character game
what language is that
its pseudocode lol
anyone know if discord has some formula for welcome messages?
formula?
ah you mean the system messages
yeah idk why i said formula im tired
anyway eris does something with an outdated list that isnt used anymore
eris and outdated, name a better duo

outdated

i got the hopefully new and updated list so i was wondering if eris' formula was actually a valid formula
guess not
is there even a formula?
eris does
also, whats the point of tracking these client side?
~~(message.createdTimestamp % lengthOfJoinMessages)
since the api sends you them anyway
oh is it?
math.floor alternative apparently
it inverts then inverts again i guess
idk shit about bitwise
let me benchmark this
https://sourceb.in/632f4ce5d9
whrn the other person responds no errors but it doesnt send a message
so no errors and nothing happens
wait what
lol great
now i dont have to think that im sacrificing speed when i use math.floor
but stilll
thats insanity
im different
lmao
im the type of guy to sacrifice speed for looks 
LOL
im the opposite
actually, someone should make an editor plugin that formats your code to ascii art
this piece of code is faster, BUT this piece of code has a secret image of kirby in ascii art and therefor is better
hire luke
and force him
like the time he made functional code that looked like luca

luca's code best code
everyday i dream of being capable of coding like that
luca is my inspiration, my role model
it is
as long as it has permissions to manage roles
https://sourceb.in/f05642d7bf when the user responds nothing happens and it gives no errors
client.user is a user, not a guild member
sorry i was just in shock after revisiting luca's code
now i wanted to do something but i forgot
Shock from its beauty?
okay so
if I got let user = message.mentions.members.first() || message.author;How could I make it so if theres also an id instead of mentions it would also be able todo it, if that makes sense
will something like this be a decent enough indicator if a guild is a bot farm:
bots > 100 && humans < 50 (more than 100 bots and less than 50 humans/users)
hi, how can i update an array?
Is it easy to code a bot as never done it
like i have js ['hi']; how can i make it be something like ```js
['hi', 'bye'];
@stark needle if u know whichever language u r using to create it with, it is but not as hard as starting the language and creating a bot as ur learning so many things at once, u can't differentiate whats part of the lib and whats not
I was looking at the replay bot
any bot will be, doesnt really matter what the functions of it are
will something like this be a decent enough indicator if a guild is a bot farm:
bots > 100 && humans < 50(more than 100 bots and less than 50 humans/users)
@sick cloud that really depends on if you think it's satisfactory. What if I get a bot farm with 51 people? What if I get a bot farm with 1 person and 99 bots? I also like logging how many bots a server has (if it has a lot just run a command to leave the server).
If you wanted to be more correct you can simply check the percentage of bots to humans (just one way).
we've been discussing it in #memes-and-media for ages but ty
also i can't really log and look through as i can get 100+ servers a day
yeah for large bots that's a big no no
you can try checking if people are using your commands or not
like, after a week or so, if they have yet used a command at all
how would I get a whois command to show if someone is in a server e.g support server
just check in every guild your bot is in
would require parsing every guild
shouldn't take long
guilds.cache.map(guild => guild.members.cache.has(id))
something like that
lol nvm, discord.net just added a function with it
public IReadOnlyCollection<SocketGuild> MutualGuilds
=> Discord.Guilds.Where(g => g.Users.Any(u => u.Id == Id)).ToImmutableArray();

one question...
are we allowed to give away code for free volintarily without anyone asking for it?
uuuh, not really?
lol
not in here atleast
github is probably the place to go where nobody will look at it anyway
nah
unless you post a token, then they are really into that
i just wanted to share my corona command
no thanks
I have been getting this in my logs lately, and Im not sure why it does that, or what it wants...
at RequestHandler.execute (/rbd/pnpm-volume/3e0e7ff0-a6f9-4413-afc4-43ee427079be/node_modules/.registry.npmjs.org/discord.js/12.2.0/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
at processTicksAndRejections (internal/process/task_queues.js:88:5)
(node:10781) 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: 6)```
any ideas?
missing permissions
what don't you get about that
ur bot is missing required permissions
It has perms in my server...
you can change permissions in the developer portal
your server?
so idk why it needs perms when it already has perms for my server
your bot is in other servers too
Ok...
Ok?
nvm
lol
soo, i managed to fix my bot so it stopped used 3gb of ram
now it only uses 130mb of ram
what did you do to achieve that? @turbid bough
Which lib?
c#
but not beacuse of the library
i made a dbcontext transient and only put it on the root servicecollection, and it never got disposed.
so everytime i needed to access the db, it would create a new instance, store it in ram, and keep it there forever till the app crashed
cause i thought scoped was not working, cause i didnt even actually create a scope in the messagehandler
hi
is it possible to get a user's friends with d.js?
oh
on the first command you pushed it and returned it
so it showed it
then the eval thingy got flushed
and it's now empty
yeah
u kno when i do guild.updateOne({ mod: { $push: { role: 'h' }}}), even in eval it usually updates, why doesn't it?
mod is an object with role inside
no idea
I ended up randomly writing a little minigame manager module thing today and did a simple reaction based tic tac toe minigame ๐
wait, that didn't change anything ๐ฟ
oh yeah? i made text based uno in swift once 
with djs?
now everyone's bots all of a sudden all have ttt commands
someone said that grammar and punctuation on docs equals bad code https://img.thaun.dev/fyazu.png
doubt
I am not to smart but I saw this and thought it's ttt
lol yea iw as lazy in making my player square objects
I ended up randomly writing a little minigame manager module thing today and did a simple reaction based tic tac toe minigame ๐
and uh, you know, this message
need to make it more effieicnt and junk, but it was just a fairly quick mock up ๐
wondering what other ascii based minigames i could maybe do
chrome dino
i honestly would do animated stuff if embeds would allow for image files to be changed
i actually started making a text based emoji based smash bros game but
oh you can
every time i tried the image would come out of the embed ๐
sec, i was more nub with d.,js then and rewrote my code since, ill try again
np, hf ๐
@neat ingot bot name?
guild.updateOne({ mod: { $push: { role:s 'h' }}}) anyone got any ideas why it doesnt update in the db? using mongoose
mod is an object
which has roles which is an array inside
yea, no. the image still comes right out of the embed for some reason ๐ฆ
my bot is called DekBOT, but its undergoing changes atm that arent live. ๐
Ok
ctx.beginPath();
ctx.rect(0, 0, canvas.wdith, canvas.height);
ctx.fillStyle = "#7289DA";
ctx.fill();```
๐ฎ canvasery โค๏ธ
im trying to set the background color for my canvas but its not wrking
this is regular browser canvas, or like, canvas js, or what?
canvas with discord.js
yes
k i use that, sec ๐
hmm
it appears i set the font color and then fill rect
sec, i wrote a bitmap class to handle it all so its all abstract atm lol
ok yea, the updating fonts handles fillStyle as well
so lets see
ok
for just filling an area in, all i do is:
ctx.fillStyle = '#C9B037';
ctx.fillRect(x, y, w, h);
ctx.fillStyle = "#7289DA";
// Since the image takes time to load, you should await it
ctx.fillRect(0, 0, canvas.wdith, canvas.height);```
im trying to fix the whole backgroun
background
@neat ingot
thank you
np, working now? ๐
yeah but i have another trouble
f ๐
what does [object Object] mean i done forgot ๐๐
Using discord.js
I've been trying to generate a list of what games people are playing on a server, though it doesn't seem to catch my current game and records it as me playing nothing
I'm using this:
GuildMember.presence.activities.name
Which feels wrong but it's the only lead I can get from the discord.js documentation, and the code isn't returning errors so I'm not really sure...
Not sure if this is a place where I should ask questions like this, sorry in advance if not
activities is an array
you can't call object properties on it because you don't have a reference to the object, you have a reference to the array of objects
any idea how to get their current activity then? I tried activities[0] as well which was probably smooth brain, obviously with no luck
actually, I managed to get it via eval 
I appreciate your time, hopefully I can figure it out before 4am brain hits me too hard

a user can have multiple activities concurrently, the solution on the top my head is just to use .map() to map the array to the activity names and then use .join() to join the newly created array of strings into a single string
I figured it out, I was checking for activities[0].type === "PLAYING", as it turns out they're integers
so it threw me off
I appreciate the help a bunch, sorry if it was trivial smolbrain stuff

what does this mean?
I was trying to install beautify as a module, and it says this.
witch are in the package.json file.
can someone explain to me why this is undefined
<script src="assets/js/jquery.min.js"></script>
<script src="app.js"></script>
at download (app.js:70)
at HTMLButtonElement.onclick (index.html:21)```
something's wrong with the jquery installation ig
is there a way to get a list of the people that reacted to a message? (discord.py)
like this:
$$reactions <messageid>
gets a list of the people who reacted
there should be an answer here https://stackoverflow.com/questions/2075337/uncaught-referenceerror-is-not-defined
var obj = {
message.guild.id: user.id,
};
JSON.stringify((JSON.parse(data || null).concat(obj))),
Does not work and i already have one stringify soo
JSON.stringify(obj)
you think it would it be faster to fully edit an embed from a message, or replace it, or negligible? (discord.js)
i mean, either way your fully changing the message content
fun ๐

JS?
I write in python ._.
Fc

How do i make my bot give people the voted role? I used discord.js
Ohhhhhh
Nvm I don't know
How do I make roles changeable instead of fixed, E.g.
let mainrole = msg.guild.roles.cache.find(role => role.name === "New");
How to I make the role "New" variable
Libary?
Wdym changeable instead of fixed?
Like
I run a command like q!setrole mute @muted or something like that, instead of it being hard coded
so i have an input
<input class="input-condensed" type="text" name="savepath" id="savepath" value="out/" disabled />
the value should be out/, but it's somehow being set to true:
need help sorting that
true
Very funny
ok?
How i can delete all this data? (discord.js, quick.db)
map(item => db.delete(item)) something like this @iron scroll
i don't use quick.db so look at its docs for the right method
Is there a function that acts the same as the enter key when writing a help command, e.g ('first line of help here') ('second line under it') etc, but I don't want the bot to send 50 separate messages either
\n
Js?
Ok thx so much
Np
Do I need to use backticks?
No but with backticks you can just do enter
Has anyone had a problem with bot double messages? (Language - Python)
||Sorry if there are errors (I'm not too good in English)||
Make sure you are restarting your bot properly
More precisely all my commands are repeated, except for Help (I restart the bot correctly)
maybe you're hosting it somewhere else too, without the help command
can you type what you need to say in one cohesive message
Idk
roles are always editable...?
No I mean
oh you mean change which role to assign
I wanna make the actual roles it's looking for editable in the server, so it's not hard coded
Yeah exacc
you need to use a database to store the id of the role
then simply get the role object with the id from the database
if you structure it like that, yeah
in an SQL database you'd have a table and in the table fields like guildId, mainRoleId etc etc
based on that
you can query for the role id of a specific guild id
Cry is there any npm stuff that I need to install for SQL?
@pure lion don't you just want to search any role? For example:
!find Muted
Bot reacts: There is no role called Muted
Like that in another format?
that's what I understand you want to do
they want the ability to freely set which roles are used for what
not being restricted to a name lookup
Ye that
ohhh okay
We don't do custom nicknames. Yours was changed to make it easily mentionable
Can't I run a fetch command for the roles in the server and check if the argument matches the role or am I just talking gibberish
We don't do custom nicknames. Yours was changed to make it easily mentionable
a mod probably changed it thinking that the d was a p (it's filpped)
but if you read it how it's supposed to read, it's a d
It's fiiiine
Can't I run a fetch command for the roles in the server and check if the argument matches the role or am I just talking gibberish
@pure lion yes you can do that
Oooooo
that'll only be in memory though
once you restart your process all of the data you stored is going to be gone
it's why you have to use a database
think I still don't understand you then ๐
don't be afraid to play around with it - it's the best way to learn
hi
i mean i literally started coding 2 days ago for the first time maybe i should relax a bit
you seem to be a fast learner then
if i have js let o = ['hi', 'bye']; let p = ['hi', 'nobye']; how can i check if any value of o is equal to p, in his case, it would return true
95% of newbies we get here complain about how they can't do anything and demand to be spoonfed lol
bruh lol
i've tried ```js
o.includes(p);
@digital ibex for loop through o, that way you get each string separately, use p.includes(o[your index from the for loop]) and break out of the for loop when the includes returns true
ah, ok, thank u
you'd also have some bool value laying around that you can set to true when p.includes returns true
o.some() works too right? Think that's better
same logic
check if array b contains the element from array a
can i do like
let o = ['hi', 'bye'];
let p = ['hi', 'nobye']; o.some((e) => e === 'hi');```
yes you can, but that doesn't do what you want
^
You need to combine .some with .includes
you want to check if the element is the same as an element in the other array
kk, thanks guys
np
.some(e => p.includes(e)
You need to combine .some with .includes
@quartz kindle o[key] will do the same, right? Or is includes() better? Just asking
like this: .some(e => p[e]
.some will iterate over an array and give yoi each item from it
So for each item, you need to check if it exists in the other array
yes I know, but I'm asking if one of e => p[e] and e => p.includes(e) is better
you cant do p[e] in this case
Because p is an array, and e is a value, not an index
[a,b,c][0] = a
[a,b,c][a] = undefined
[a,b,c].includes(a) = true
aaaaaaaa
if(newPresence.user.presence.status !== oldPresence.user.presence.status){
Cannot read proprety user of undefined
how can i do please
params > module.exports = async function(client, oldPresence, newPresence) {
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit
uh oh
use a single listener and handle all of your commands in that listener
oki
By now I develop bots in discord.js, but for my first bot I used discord.js-commando because it was easier to use. Now I would like to modify my first bot in commando, but I don't know how I can insert the custom prefix functionality. Can someone help me?
Aaaaaaaa ! I have found intelligent life on this planet!
Tim has a handle on it! @balmy knoll
@balmy knoll you need to have a database to do that properly
@earnest phoenix https://discord.js.org/#/docs/main/stable/class/Presence?scrollTo=user
I see a ? there, I guess that means the property is not always there
I don't know why, but I think it will properly work if you first check if newPresence.user exists
@nocturne grove Can i make this in a .json?
you can, but many don't recommend it
I did that too, and spent another couple of hours to convert it to a proper database (which is also easier to use)
@nocturne grove Ok thanks
any ideas how can I check the message is an emoji? (excluding custom emojis, only emojis like ๐๏ธ ๐ ๐ etc)
Apparently I can't check them by trying to .get and see if it returns undefined or not, since they're unicode I guess.
Also making it inefficient like trying to use react doesn't seem like an idea, so maybe anyone has other ideas? ๐ค
if you are ready to admit you cant use that, try using one of the emoji regexes
i could use that emoji map but im lazy 
yes but i check how @nocturne grove
erm 1 quick question how to use db for bot ?.
which db
How to get GuildMember from user id?
for welcome message ?.
guild.members.cache.get() or guild.members.fetch()
(discord.js v12)
is the ID I send with or without the @
displayed ID but not member name ?.
like Gigawolf#4406
bot mentioning user ?>
how
do i
let a user join a guild with oauth2
i have it setup now only the script to let it join
I'd go against you in connect four 
๐
bot update wont be live for a while, when it is we can have a game in test room ๐
ive made 4 minigames already ๐
tic-tac-toe, connect-4, maze runner, and a number version of hangman ~ 'guess my number man'
I have a question, how do I make a bot say something different at a certain time?
uh
I am creating a dashboard for my bot and I was wondering how you can get the look of the official discord website and mee6 dashboard
do you mean schedule a message, or send a random message each time @autumn quarry
@sullen patrol what do you mean
the styling?
they hired professional web designers
@earnest phoenix I mean, if the command is executed at 8:00 it says something, but if it is executed at 10:00 it says something different
ok
which language are you using tirenity
Discord.js (v11)
ok so js, that's a lib
use Date.now() and getHours() on that
though this is a problem because almost everyone is in a different timezone
so you'll probably want getUTCHours() for the UTC timezone
that'll return an int (0-23) and then you can switch case on it and do a response that you want for certain hours
timezones are definitely a problem in the servers i am in, barely anyone are in the same timezones lmao
yes but i check how @nocturne grove (https://discordapp.com/channels/264445053596991498/272764566411149314/711565253552635944)
@earnest phoenix still needed?
@earnest phoenix I am confused on where to use the Date.now() and getHours()
wherever your command handling logic is
I mean, do I use them like this:
let hours = getCDTHours() if(hours = ("8")){ message.channel.send("user is unavailable") };
oh, are you doing the "user is unavailable" for yourself?
where are you hosting the bot
home or a vps
home
o
if(hours = ("8")){
this line is completely wrong
hours is an int
= is for assignment, == is for comparison ignoring types, === is for type sensitive comparison
you probably want to use the last one
okay
makes sense why it gives me an error when i mistype
so would it just be:
getHours(8){}
no
getHours doesn't take in any arguments
it returns an int of the current hour
oh
I put it in, and it says: "getHours is not defined"
I am just confused on how to do the second part
you can check if it's true send message
re-read what i said here
converting a date to a string takes time (not to mention overhead time for the includes method which is slow)
there's no reason to do that when you only need to check the amount
if you want to run discord bot dont use heroku
best way to code with heroku is to make a github repo, put ur code in and run it with heroku
yes
<b> </b>
lol
this is weird everytime i'm updating script the bot didn't show the console.log and it remain offline.
@fickle arch updating != running
did you press ctrl + c and type node .?
yes
ctrl+ s then ctrl + c and do node . or maybe node index.js
how would i do a command that shows the uptime of my bot discord.js v12
restart the script like how ?.
yes @nocturne grove
@next mica <Client>.uptime is a value that shows, in miliseconds, for how many time the bot is running. simply use it
ok thanks
np
@earnest phoenix use this:
if(newPresence.user && newPresence.user.presence.status !== oldPresence.user.presence.status){```
(ping me if you react)
i get the thin g humanize is not defined
i just want to said that xd.
ok
i also keep getting this
(node:13324) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit
idk
humanize still aint working
what is an emoji identifier used for?
like, if i change the getter to something different, would there be any consequences?
lol
Error: sqlite: filename is not defined How can i fix this error?
define filename
@grizzled raven I've never used this package. What's a filename and what do I put in it?
A filename is something like:** index.js**
i got this righ there
(node:15092) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit
im wondering where yo i put the emiiter.setmaxlisteners at
@granite girder Ok, but...
client.setProvider(
sqlite.open(path.join(__dirname, 'database.sqlite3')).then(db => new commando.SQLiteProvider(db))
).catch(console.error);
The database.sqlite3 file where should I create it and what should I put in it?
if it is in the same Folder you can type: ./database.sqlite3
would i do client.on(emitter.setmaxlisteners())
@granite girder Ok, but i take this code online, what should I replace this file with?
Do you mean you upload it in to an cloud or something like this?
@granite girder I got this code from the official discord.js-commando github. It servers me so I can save data from each guild. But I've never used the sqlite library, so I don't know how to use it.
i need help, pm2 decides to just shut off my main bot
but not my other bots
nor can i actually scroll onto it
i fixed the emiiter with client.setMaxListeners(0);
better you should not do that
me
yes
why
@balmy knoll i also donยดt know anything about sqlite3. Sqlite3 is a Database type right?
its not a fix, its simply turning off the fire alarm lmao
nested events gives maxlisteners error
how do i fix it then
dont add so many listeners
i need to set up a prefix thing?
no, you need to do ```js
client.on("bla", bla => {
command1,
command2,
command3
})
and not ```js
client.on("bla", bla)
client.on("bla", bla)
client.on("bla", bla)
thats not what im doing
so how do i combind that to one event
@next mica thats doing exactly that i said not to do lol
@granite girder I don't know anything, I got the code online, I don't know what to do.
@next mica you can make it like this:
client.on('message',(message) => { if(message.content === 'help'){ console.log('help') } if(message.content === 'yeet'){ console.log('yeet') } }
@balmy knoll If it is a normal Database you could use Mysql
Cannot ready proprety user of undefined @nocturne grove
like this if i dont want to log it
(./filename.sqlite)
yes
@torn nebula sqlite.open(path.join(__dirname, 'database.sqlite3')) Yes, but in this code, database.sqlite3 is a file that i have to add in the bot folder?
i cant do it for all of mine i have some async functions
if database.sqlite is your database file
use
sqlite.open(../database.sqlite,)
to open db file
crafty how would i put a async funtion into that
@next mica then use: client.on('message',async (message) => {
})
don't use async until you good with that
@torn nebula Ok, but what does a database file look like and what do I put in it? Is there an online guide?
wait
so do one for async funtions
@balmy knoll you dont make the file yourself
sqlite will create and manage the file for you
everything you do has to be done by sqlite, you never mess with the file yourself
@quartz kindle I found this in the discord.js-commando documentation to use the built-in command to set different prefixes for each server. But to do that I need this database, but I don't know how.
how do i fix [object Object]
im using discord.js 11.2.1
@balmy knoll look at the quick.db npm package it can be useful.
object is a data structure that contains many items
you need to chose which item you want
otherwise, if you want to dump the entire object, you need to stringify it
JSON.stringify(object)
Whats a eval command for
for you to run tests and experiments in your bot
for example you can access your bot's code without having to change anything or restart your bot
anyone know hoo to make discord oauth2?
anyone know hoo to make discord oauth2?
you don't make it, you implement it
and it all depends on what you're using
let y = process.openStdin()
y.addListener("data", res => {
let x = res.toString().trim().split(/ +/g)
client.channels.cache.get("681657479691632641").send(x.join(" "));
});```i have this code to talk from console to channel but how do i make it so that i can also see messages sent by others in that channel
MS question, How do I display the GMT time, Is it like {TIME:GMT}
console.log messages coming from that channel
how would i do music commands for my discord.js v12 bot
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString UTC is equivalent (to 0.9 seconds anyways) of GMT+0
is it possible to hyperlink an image (different than the source image link)? with the markdown it only supports linking text and not images, so im wondering if it's even possible
console.log messages coming from that channel
@quartz kindle how do i do that
how do you receive messages from discord?
message.channel.send
wait nvm
thats to send messages
await message.channel.send? this way its waiting for a response
you should really learn how async/await works and how to use the lib you're working with
where do all your discord messages come from?
a channel?
the user
where is the variable message first defined?
oh
anyone can help me solve this error ?.
^
TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received an instance of Object```
would I be able to get more information on my bot being denied
The "listener" argument must be of type function. Received an instance of Object
@rugged brook check who declined your bot in #mod-logs and dm them
tyty
@rugged brook mostly your bot got denied because
offline
lack of commands
etc.
@dusty onyx I believe you can make it reach all shards using broadcastEval (discord.js). Not sure about other libraries.
mm yea i use py
good luck lol
Ughhhhhh
I gave up on mine lmao
Should be able to yes.
ytdl is not define
but i have const ytdl = require('ytdl-core')
show your code
server.dispatcher = connection.play(YTDL(server.queue[0], {filter: "audioonly"}));```
ytdl is not defined.
are you blind
you defined it as ytdl
and you're trying to use YTDL
javascript is case sensitive
ytdl is not the same as YTDL
let x = 4;
let X = 3;
console.log(x, X); //4 3
oh yes work perfectly.
oh anyways how to make bot showing activities for (elapsed time) ?.
yeah
first get the current date and the length of the video
then do some math to get the remaining time
I don't remember the formula for that
i mean like
playing (apps name/watching servers) elapsed times : xx:xx.
Make sure you're saving the IDs as a string.
Can't I save them as numbers? Because I have to compare them to server ID's I get from the discord API and those are decimal
oh lol my bot could play but can't stop xd.
Why would a server ID be a decimal?
Sorry, I mean integer :D
something lost in translation
is the ID not a string itself? Are you using a library? What language are you using (I assume js from the screenshot)?
I use discord.js and just looked in their docs. The ID is indeed a string, so that solves my issue. Thanks for pointing that out.
never the less, If I would like to store a large integer via LowDB, it will not be possible?
var server = servers[message.guild.id];
if (server.dispatcher) server.dispatcher.end();
break;```
skip commands stop music and not skipping to other and also stop commands doesn't do anything
```case "stop":
var server = servers[message.guild.id];
if (message.guild.voiceConnection) message.guild.voiceConnection.disconnect();
break;```
ytdl is not define
but i have const ytdl = require('ytdl-core')
@fickle arch i already have this
I use discord.js and just looked in their docs. The ID is indeed a string, so that solves my issue. Thanks for pointing that out.
never the less, If I would like to store a large integer via LowDB, it will not be possible?
@lethal hawk JavaScript is rounding the number because it's an overflow of what's allowed.
@pure lion fixed already but thanks.
That's why you should store it as a string or use BigInt (it's new but I don't know what it does in detail).
Ok, thanks for the good response!
@fickle arch but i need help
jeez my music scriptpretty messed up
firstly my skip function stop the current music and not skipping to the next one
second my play function when added another music it stop the current play
third my queue function doesn't work xd.
oh
okay so in mongodb i have the following document structure {id: 1234, nodes: [{from: 1, to: 2}, {from: 2, to: 1}]} how could i query the node objects based on only the to or from value?
@pure lion what is your issue (as in the problem you're having)?
im not sure how to phrase it
what does erela.js used for ?.
@sudden geyser connection.play isn't defined even though i have the correct npm packs installed and set as a constant
show the error.
alright
@mossy vine maybe fetch them all and do a find on them if its practical
const docs = // docs from mongodb
const item = docs.find(doc => {
const val = doc.nodes.find(node => node.from === 1 && node.to === 2);
return val;
});
@pure lion are your code same like this ?
server.dispatcher = connection.play(ytdl(server.queue[0], {filter: "audioonly"}));
yeah
Hey can someone help me? my little brain cannot understand this.
but connection.play are showing as "any" when i hover my mouse over them
Hey can someone help me? my little brain cannot understand this.
@earnest phoenix what with?
don't use that @pure lion
what.
you're not using typescript so djs won't show it properly, just use the docs
im looking at the docs rn
whats your issue
@earnest phoenix what with?
@pure lion So i am trying to make a currentprefix command and this is what i have used.
client.on("message", (message) => {
if (message.content === ("/currentprefix")) {
message.channel.send(`Your current prefix is ${fetched}`);
}
})```
Now there is an error that says `fetched` is not defined even though i have defined it here:
```js
let fetched = await db.fetch(`prefix_${message.guild}`);
@sick cloud i had issues where my skip function turned into stopping music, play function stop the current music playing.
show code
can i show it on dm ?.
no, send it here
alright wait.
@fickle arch you can't have rich presence on a bot
play function
if (!args[1]) {
message.channel.send("Please provide a valid link.");
return;
}
if (!message.member.voice.channel) {
message.channel.send("Please join a voice channel first.");
return;
}
if (!servers[message.guild.id]) servers[message.guild.id] = {
queue: []
};
var server = servers[message.guild.id];
server.queue.push(args[1]);
if (!message.guild.voiceConnection) message.member.voice.channel.join().then(function(connection) {
play(connection, message);
});
break;```
skip function
```case "skip":
var server = servers[message.guild.id];
if (server.dispatcher) server.dispatcher.end();
break;```
stop function
```case "stop":
var server = servers[message.guild.id];
if (message.guild.voiceConnection) message.guild.voiceConnection.disconnect();
break;```
stop function literally doesn't working because skip function actually stop the current music.
if (server.dispatcher) server.dispatcher.end();
well that's why?
you're ending the music
I have a list like this in my json.
{ "test": [{"name":"test","age":"number"},{..}]}
I wanted to send in the channel this: Name:test, Age:numbers
question
this wont work, right?
list.test[0][0].join(", ")
ah, ok thanks โค๏ธ
alright its working now
so i need to replace skip with stop and delete the voiceconnection.disconnect() ?.
when playing music the music that been played is replaced with other music.
So i am trying to make a currentprefix command and this is what i have used.
client.on("message", (message) => {
if (message.content === ("/currentprefix")) {
message.channel.send(`Your current prefix is ${fetched}`);
}
})```
Now there is an error that says `fetched` is not defined even though i have defined it here:
```js
let fetched = await db.fetch(`prefix_${message.guild}`);
can someone help me?
try using var fetched instead of let fetched
like custom prefix ?.
yea i have a working custom prefix command but i am trying to make a currentprefix command in case someone forgets their prefix
try using
var fetchedinstead oflet fetched
@lethal hawk will do
well before i had function that when you mention bot like (namehere) current prefix it would shown the prefix.
When I synchronize a voice channels permissions with its parent category using channel.lockPermissions().catch(console.error) (discord.js) I get the following discord API error.
Note that the bot does have the 'Manage Channels' permission in its role and the permissions are synced as they are supposed to.
DiscordAPIError: Missing Access
at RequestHandler.execute (/rbd/pnpm-volume/36094c96-e504-4ecf-ab99-62f02cdefd9c/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
at processTicksAndRejections (internal/process/task_queues.js:88:5) {
name: 'DiscordAPIError',
message: 'Missing Access',
method: 'patch',
path: '/channels/711671087355658290',
code: 50001,
httpStatus: 403
}
well before i had function that when you mention bot like (namehere) current prefix it would shown the prefix.
@fickle arch How'd you do that?
can someone help me figure out why my MarkDown text isnt showing? Well some is only 1 of the commands, all the rest aren't showing. ._.
___________________________________________________
Commands :
NonAdmin :
Economy (Work in progress) :
-X-
Social (Work in progress) :
-X-
Fun :
+avatar Shows your charactars avatar
+random Gives you a random number from 1-100
Other :
+help Shows the list of commands
+ping Shows how laggy the bot is
Admin :
Moderation (Work in progress) :
+kick Kicks a player from the server
+purge Deletes a certain amount of messages (Up to 999)
Other :
+react React to your message (Good for polls)
+say Have the bot say something (Work in progress)
___________________________________________________
and it gives me this
Commands :
NonAdmin :
Economy (Work in progress) :
-X-
Social (Work in progress) :
-X-
Fun :
+avatar Shows your charactars avatar +random Gives you a random number from 1-100
Other :
+help Shows the list of commands +ping Shows how laggy the bot is
Admin :
Moderation (Work in progress) :
+kick Kicks a player from the server +purge Deletes a certain amount of messages (Up to 999)
Other :
+react React to your message (Good for polls) +say Have the bot say something (Work in progress)
even tho there is clearly more than those lines
make sure there is a space between * and the line
for example, if you want to create a bullet list
if you're not using bullet lists, just normal lines, you need to use double lines, otherwise MD will put them in the same line
if i have this ```const errors = require("../../../utils/errors.js");
const { ownerid } = require("../../loaders/reader");
module.exports = {
config: {
name: "test",
aliases: ["testing"],
},
run: async (bot, message, args) => {
let channel = bot.db.fetch(channel_${message.guild.id})
if (ownerid.includes(message.author.id)) {
if(channel) return channel.send("test")
}
}
} ``` why does it throw an error saying channel.send isnt a function
play function
if (!args[1]) { message.channel.send("Please provide a valid link."); return; } if (!message.member.voice.channel) { message.channel.send("Please join a voice channel first."); return; } if (!servers[message.guild.id]) servers[message.guild.id] = { queue: [] }; var server = servers[message.guild.id]; server.queue.push(args[1]); if (!message.guild.voiceConnection) message.member.voice.channel.join().then(function(connection) { play(connection, message); }); break;``` skip function ```case "skip": var server = servers[message.guild.id]; if (server.dispatcher) server.dispatcher.end(); break;``` stop function ```case "stop": var server = servers[message.guild.id]; if (message.guild.voiceConnection) message.guild.voiceConnection.disconnect(); break;```
@fickle arch where do i paste the skip and stop functions?

discord.errors.HTTPException: 502 Bad Gateway (error code: 0): <html> <head><title>502 Bad Gateway</title></head> <body> <center><h1>502 Bad Gateway</h1></center> <hr><center>cloudflare</center> </body> </html> I keep getting this error- does anyone know what it means/a fix for it?
i can ch eck
hh where can i find the vers im on? im pretty sure its the latest but im not certaim
what IDE r u using
are you having a slight stroke btw?
pycharm
go to file -> settings -> interpreture settings
look for discord.py in your module list
ok! 1.2.5
update
will i have to change my code at all?
hey can you help me in #topgg-api plz
oh good qwq
it just fixes some cloudflare issues
ugh upgrade packages failed
hi
That's a bit rude
nothing beats rudeness more than me yelling at my teammate because his frontend design attempt sucks
anyway
whats your problem
how can i check the users which have a certain role from an array of strings? so its like ```js
let array = ['role 1', 'role 2'];
Ok so I'm using the ms npm pack for a timed mute, it's doing it in milliseconds so how do I make it last seconds and not milliseconds
try multiplying by 1000
damn
Ikr
what
wdym "how do I make it last seconds and not milliseconds"
what did you try
dont know much about d.js development, im more of a py guy so
1000ms = 1s
that's not how that works
uh
array is not a number
i mis interpreted the question
that won't be how u do it
you should specify what you are using then
still wrong though
no
i thought he meant a user having those roles
the answer is still wrong despite you misinterpreted the question
provide the correct solution then

i'm too high for this shit
just debug
no ik how to get the members roles & stuff, i just can't seem to filter it to which role & the members in tht role
users that have any of the roles in the list, or users that have all roles in the list?
any role in the list
some, ig
if a user has any role of the list, or find all users that have any role of the list?
guild.members.filter(member => member.roles.some(role => arrayofroles.includes(role)))
oh
but keep in mind that you are limited by the members existing in the cache
uncached members will not be found
when i was doing it, it would return an empty array, i'll try and use it
ty, i cache all users
you can enable cacheAllUsers in client options but memory
my bot is small so i have that enabled for now
and i didn't read haha
jeez my music functions start breaking apart.
do something about it
i'm still figuring out why play function actually replace current played music, and skip function actually stop the music xd.
could not switching to the new intents thing slow down your bot? I have a bot I made yeeeeeaaaaarrrrssss ago and I haven't changed anything and it's having problems now
because update.
Can i ask is this the right one?
client.guilds.cache.size
well.. yeah
this is why you try first
why are people so afraid of just letting it run
do people not want to deal with errors
or smt
(node:4) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
Welp, help
well i'm letting my music function run and ended up having trouble.
because it will delete all files in the working directory
@sterile mesa x is not defined (x.id)
have you tried reading the error
author is undefined
always been thinking of making a discord.js-optionalCaching of some sort 
me and my fantasies
๐
discord.js-light
Eris, a NodeJS Discord library
Whoops
const embed = new MessageEmbed()
.setTitle('Deisel Fuel!')
.setColor('#a1ee33')
.setDescription(':fuelpump: Please wait 30 seconds for your truck to be refuled!')
.setFooter(copyright);
await message.delete();
await message.channel.send(embed);
setTimeout(function() {
embed.setDescription(':white_check_mark: Your truck now has a full tank!');
message.channel.send('Hey ' + `<@${message.author.id}>` + '!', embed);
}, 30000);
break;
}```
Line 97 is:
```await message.delete();```
Andy my error is the following:
```(node:7132) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message
at RequestHandler.execute (C:\Users\dargc\Desktop\Coding\betarpbot\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
at processTicksAndRejections (internal/process/task_queues.js:97:5)```
Unsure why this is happening
Discord.js is 12.2.0
is it async
Yes my code is async
Author message.
if (message.deletable) message.delete();
So it deletes it.
it didn't say anything about line 97 in the error
i use eventhandler ;-;
Yes it does.
where?
hi @quartz kindle sorry i took so long, uh, it still returns an empty array for some reason
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Not. As thats where the error is cropping up.
