#development
1 messages · Page 921 of 1
There are nuances in updates but that is coding
if the engine updates you move with it
no why cant i use windows xp
So, Tim, only iconURL should work ?
it would be a fun experiment to boot up windows 95 and see what you can do
@earnest phoenix the iconURL property of guild should work
@quartz kindle it don't work
as long as your guild object is real
guild is not defined
its a nullable field, that means it can be empty if your guild doesnt have an icon
of course guild is not defined, you have to get it from somewhere
i didnt tell you to remove what you had, i just said it should work
what you had was correct all along
@earnest phoenix go backwards in your object chain and make sure the root is defined
make sure the variable is the object you believe it to be, etc.
when i said iconURL should work, i mean that the iconURL property of the guild object (that you are getting from member.guild) should work
everything is context and everything has to come from somewhere
member.guild.iconURL is not a function
Tim, we have a problem. Now if you close the page and then go back it forgets your socket ID
its not a function in v11
I just realized something
Sabin what is member from your console log?
Nobody gave us the source code for how our bodies work so we've basically spent centuries reverse engineering ourselves
member.guild.roles.find isn't a function anymore, does anything else work?
elon, if you are on v12 you should use guild.roles.cache.find
ok
object.a // this is a property. do it like this in v11
object.a() // this is a function. do it like this in v12
Loaf, wdym ? I don't understand english very good 😅
@earnest phoenix
yes
@earnest phoenix if member.guild object is undefined, what is member object?
@quartz kindle you are the best man
its not undefined
@cinder patio sessionStorage doesnt survive closing the page and returning
only reloading
yeah welp it's not that big of a deal
if you have 2 tabs open, and you close them both, then reopen one of them, which tab should it reconnect to?
its better to simply create a new connection i guess
I solved all the errors but the bot still don't send any message
yeah but if the game has started then they won't be able to play
you can use localStorage though, no?
it's alright though that's good enough I doubt someone would close the page
then you will need something persistent, but then it wont work with multi-tabbing
unless you do something like show a list of active sessions on this browser and let the user pick one
or you implement some user account system to resolve after the connection is established
doesnt even need to have a password, just make the user create a unique player name, and then if he inputs the same name in another tab/window, he can rejoin the session
you'd probably also need to track their ip addresses to avoid some random person from the other side of the world join their session accidentally lol
Tim, the bot still don't send any message, but in logs i got the channel id, guild id, channel name etc.. Any idea? Should i give you the code?
yes
yup, already doing that for alt detection! Thanks, without you I'd be probably banging my head right now
lmao
https://pastebin.com/JCWEjQRJ here is the code Tim if you can have a look, ty
You need to await it.
Well is it like if you did return message.channel.send(...) it would not work?
ye
it doesnt even do the check
and instantly skips to the bottom one for administrator permission
@earnest phoenix what does your console.log show?
yeah i've got no idea why my code doesn't stop at the return
as if try doesn't respect the return in a if / else if chain
which return are you expecting it to stop at?
the one for cd.has
everything in console.log or only the channel thing ? ( i have the custom prefix too so is + 200 lines )
as it is true
but like I log that too, even if its true, it gets skipped
like it starts from the bottom LOL
hello im quite new to bot development but i know some C#. so my question is can you use C# to develop a discord bot?¿?
probably yes
if it gets skipped then its not true?
but when I console log it
There's plenty of Discord libraries for C#
it returns true
There's plenty of Discord libraries for C#
@slender thistle ok thanks
@quartz kindle i got this
type: 'text',
deleted: false,
id: '709122923293573120',
name: 'welcome',
position: 2,
parentID: '707898970080280647',
permissionOverwrites:
Collection [Map] {
'687996961298579494' => PermissionOverwrites {
id: '687996961298579494',
type: 'member',
deny: 0,
allow: 7168,
denied: [Permissions],
allowed: [Permissions] } },
and more other permissions
.
.
.
does it log if you put a console.log inside that if?
@earnest phoenix looks correct, is it not throwing any error?
when a member joins?
i have log inside that if, it doesnt log anything
"only this", thats the reason why its not working lol
but logging the check in the else if returns true
addField() is wrong
you cant do addField(a,b,c,d)
you have to do addField(a,b).addField(c,d)
cd is a new set()
ah ok, then what is the item in the set supposed to look like?
is it supposed to look like this? "287987598345 + 7237498749223"
Isn't member.guild.name correct?
each separate message author with each separate guild id
@earnest phoenix it is correct
but in the welcome message it says undefined and there is no error
oh nvm, i solved it
@quartz kindle an easy fix would be just removing the check for !message.member.hasPermission('ADMINISTRATOR')
and it wouldn't affect the code much, however later on I might need it and i'll have same issue I have rn 
yes, and idk why it even skips it
try console.log(cd.has(...)) before the entire if, or even before the try
My question relates to JSDoc and WebStorm IDE.
I'm having issues referencing parts of my code in another file. In src/Rin.js, I exported an extended class of the Eris client (https://abal.moe/Eris/docs/Client): https://hatebin.com/hlppuzeezy
I'm using @type to declare each property added and your usual @param for methods/functions.
I'm able to use this.client.logger without any issues in a new command/event, but if I use it in the base class (such as src/structures/Command.js), it says it can't find the variable: https://hatebin.com/gpolgrklha (Unresolved variable logger)
I tried changing Client in only JSDoc to Rin to test it, and it makes methods show up, but not properties. Does anyone know what could be causing this?
where are you defining cd btw?
how to code to put the user avatar to the right corner?
.setThumbnail()
or something like that, check the docs for the exact usage if u use discord.js
yeah it still returns a false for the set
as if at the time of adding it it already clears it
so it has to do something with the timeout not having proper time
as once it gets added timeout runs instantly and it removes it
instead of waiting the time
@sudden geyser is it just the IDE not resolving it, but the actual code still works when executed?
Yeah the code works itself.
isn't this touppercase?
ahhhhhhhh i got it, it was the ms( ) at set timeout, forgot that takes string and converts it to miliseconds
so it was not needed ,now the cooldown works properly
Hey, I was making a seperate file to query my database. I use this:
module.exports = {
query(queryContent) {
await new Promise((resolve) => {
const mysql = require('mysql');
const con = mysql.createConnection({ ... });
con.connect();
con.query(queryContent, (err, result) => {
if (err) return console.log(err);
console.log(result); // working here
return result;
});
con.end();
});
},
};```
```js
// this is async
const database = require('path');
const result = await database.query('SELECT * FROM table');
console.log(result); // returns undefined```
This is not working, I also tried it with `return new Promise( ... ` instead
In your query callback, try resolve(result) instead. You still need to return the new promise I think.
Though I don't know about making a new connection to the database every time to query some stats.
Doesn't sound so good.
whats the eris equivalent of js message.channel.awaitMessages(...)?
there isnt afaik
fuc
You need to make your own message collector.
how do i get a class method to show up in generated jsdoc? right now i have this and its not showing up in the generated html
https://cdn.discordapp.com/attachments/272764566411149314/709422827912036513/unknown.png
i made a credits system and i don't know how to make it globally ( on all servers ) help, please?
What am I doing wrong wtf
delete require.cache[require.resolve('./config.js')]
Is not a function, is there something I'm missing
@sudden geyser thank you. Some people advised me to do so 🤷
what
to make a new connection every time
@magic jackal dms
ok
@digital ibex like I have 2000 credits on one guild to have on another
yes it works now, Kinolite. Thank you
wdym ?
u want ur 2000 credits on one server to get added onto a different one?
no man
with my bot, on a server i have a sum of credits ok ?
but on other server i have another sum of credits with the same bot
Sounds to me like the coins/credits are saved per server
i don't know what language u r using and idek what db u r using
nvm man, i think i solved it
How many credits do I have on one server I want to have on another, now u understand ?
node.js, discord.js v11, quick.db
i've never used quick.db, can't help 🤷♂️
Just store in a "global" database that you call from. I do that with my bot. I have the credits amount in the user account table of my db and call from that. That way their credits aren't associated with a guild id, they're associated with a user id.
https://discordapp.com/channels/264445053596991498/272764566411149314/709417238251307068 with something like this (it works now), is there an option to stop the execution in the file this function is used? Like in the second code block, stop that execution there if the query in the database.query() function gave an error. I could use like return null; with an error and if (result == null) message.reply('an error occured'), but is there an easier way too?
Any idea why my leaderboard doesn't work ?
@earnest phoenix please send it using pastebin/hastebin and say where the leaderboard code is
thanks
is there a package to detect if a discord message is a link?
i dont wanna use http:// https:// because its not always a link
@earnest phoenix I'm sorry idk, I'm not familiar with db
@nocturne grove uh, ok, ty
https://i.callumdev.pw/ptgxv.png
I am a bit stuck here, I cannot see why this does not work
m is never gonna be a number, so that typeof will never pass
<--- JS stacktrace ---> ==== JS stack trace ========================================= 0: ExitFrame [pc: 0x74a93fcfc5d] Security context: 0x2278e6f9d9f1 <JSObject> 1: set [0x2278e6f90e49](this=0x3761b559ca91 <Map map = 0x25fbd318f631>,0x0cb69decfb61 <String[18]: 641460083536166924>,0x213f149e8db1 <Base map = 0x25fbd31c9471>) 2: get emojis [0x11abef4390e9] [/home/thenoob27/Starboard/node_modules/discord.js/src/client/Client.js:~170] [pc=0x74a94a11eea](this=0x180e40782931 <EventEmitter map = 0x560032857c1>) 3:...
``` what the hell do these mean
how do i prevent it
never seen a stack trace like that
seems to be related to
the client emoji getter
maybe because my bot is a bot that deals with reaction emojis quite often? idk
reaction emoji is a getter which uses client.emojis
and then also other stuff
but how do i prevent it
is there nothing else logged?
how i put
message.channel.send(waifu[Math.floor(Math.random() * waifu.length)]);
in an embed pls ?
embed description?
yes this
i try it
@grizzled raven thats usually caused when u run out of memory
but there is 33 images and i want he send juste 1 randomly
its a c++ thing
?
you use the result of your math random with the embed functions from the link above
i try
const Embed = new Discord.MessageEmbed()
.setColor('RED')
.setMessage('message.channel.send(waifu[Math.floor(Math.random() * waifu.length)]);')
message.channel.send(Embed);
but its doesnt work
there is no setMessage
beacause .setMessage doesnt exist
read the guide
i know
also, read about concatenation and string templating
"result is 10 + 10" // "result is 10 + 10"
"result is 10" + "10" // "result is 1010"
"result is " + (10 + 10) // result is 20
`result is ${10 + 10}` // result is 20
So I ported my loop code system from djs to eris, but this happens https://discordapp.com/channels/264445053596991498/385837258768515083/709443304588050636 wtf (not using LL)
@white anvil definitly not caused due to lack of memory
i have like 16gb on my system and i use an average of 1.2gb
yeah but the heap size won’t be that big
nodejs only has a certain amount of allocated memory
yeah thats what im saying
maybe ur right
the full log is way bigger than just that
that part is pretty useless on its own
i have an image of it from a while ago, i'll check
it also says if its a memory problem
ok so
if u didnt get that then idk
were u just running something and this hapepend?
yes
weird
i dont see ur code causing this it must have come from one of the packages you were using
unless ur running very weird shit
if its an out of memory crash, then its a memory leak
// random logging stuff
<--- Last few GCs ---> [24530:0x31de0a0] 12709429 ms: Scavenge 1254.9 (1412.4) -> 1254.3 (1412.9) MB, 9.4 / 0.0 ms (average mu = 0.245, current mu = 0.205) allocation failure [24530:0x31de0a0] 12709489 ms: Scavenge 1257.7 (1415.5) -> 1256.8 (1416.0) MB, 9.3 / 0.0 ms (average mu = 0.245, current mu = 0.205) allocation failure [24530:0x31de0a0] 12709553 ms: Scavenge 1263.9 (1422.2) -> 1262.9 (1422.2) MB, 8.3 / 0.0 ms (average mu = 0.245, current mu = 0.205) allocation failure <--- JS stacktrace ---> ==== JS stack trace ========================================= 0: ExitFrame [pc: 0x74a93fcfc5d] Security context: 0x2278e6f9d9f1 <JSObject> 1: set [0x2278e6f90e49](this=0x3761b559ca91 <Map map = 0x25fbd318f631>,0x0cb69decfb61 <String[18]: 641460083536166924>,0x213f149e8db1 <Base map = 0x25fbd31c9471>) 2: get emojis [0x11abef4390e9] [/home/thenoob27/Starboard/node_modules/discord.js/src/client/Client.js:~170] [pc=0x74a94a11eea](this=0x180e40782931 <EventEmitter map = 0x560032857c1>) 3:...
// client has to log in again
everything that it shows
that smells like an error thrown becuz u ran out of memory
it does look like an out of memory, but idk why it doesnt show the report after it
yeah
ok nvm
pretty sure it actually saves a report of it
.report-1212221112.json or aomething
what does the report say lol
my only guess is iterating every guild for the client.emoji getter too often
i cant read it
actually wait
what version of node are you on? is it 32 bit or 64 bit?
think this is what you need - ```json
{
"header": {
"event": "Allocation failed - JavaScript heap out of memory",
"trigger": "FatalError",
"filename": "report.20200508.174903.2751.0.001.json",
"dumpEventTime": "2020-05-08T17:49:03Z",
"dumpEventTimeStamp": "1588952943749",
"processId": 2751,
"cwd": "/home/thenoob27/Starboard"
}
}
the only meaningful line in that is the event
lol
memory leaks are an absolute pig to fix
must be pretty significant for the heap to run out of memory though
also, it seems its crashing at around 1.5gb
could be related to node's max-old-size
try running node with --max_old_space_size=4096
to set it at 4gb
is that rlly smart
yeah its around 1.5, never seen total memory usage go past 1.4 lol
so should i do that?
I'm currently working on music commands for my bot and I got it up and running with no errors but when I attempt to do ?play and then my song link it says that I must be in a voice channel (which I am). My code is listed below, no errors in console either.
play.js: https://pastebin.com/ghVJbpys
index.js: https://pastebin.com/V39Z8Nat
show your message event
Is it more efficient to make a class in a separate script and request it if multiple scripts needs it
How can I post image with bot, not url. Only image?
from url that doesn't end with .png or any file format
You want to post an image which doesn't have an image format?
more efficient as opposed to what?
@rare tangle you mean generate an image inside the program and send it directly?
having the same class in every script
or use an url that doesnt end with a format?
because I have big brain atm and need to make it more efficient
oh yeah will --max_old_space_size=4096 work with pm2 and others?
if you can reuse the class instance, declare is somewhere, initialize it and attach it to somewhere that you can access from all files
if you need multiple instances, then do the same but initialize it on each file where you use it
yes
and it would be more efficient wouldn't it
as in does crap faster and uses less RAM?
because it ain't needing to load the same crap multiple times
yes
@grizzled raven probably yes
pm2 has specific options to pass node arguments
you need to check their docs
okay
yep
.send({files:["url"]})
I've tried
message.channel.send("Whatever words you want here, can be nothing", {files: [file]});
but it worked on links ending with .file format which my url doesn't end
It gives a download url instead with no format
try this then: .send({files:[{attachment:url,name:"image.png"}]})
It worked, thank you!
Hi
Does anyone know how long it takes for a bot to get approved?
@earnest phoenix
Question, how can I have the bot see what type of status i have? ex: online, idle, dnd
Discord.js (v11)
(if you can answer, please ping me)

hi
hi
with mongo, what can i do to update the guild in the db, what i have to do is delete it on compass and then use a command, then set the guilds config up and stuff, what can i do to not do that?
like, when i add something onto the model to add it to the guild and for it to actually work in the guild, i have to delete it on compass
Hey, is this working?
is what working @lapis ocean
Sorry, this server was having connection issues I think
Hey guys, I have an error with my music bot, it throws an error when trying to place a song, the error marks me in these lines;
async function buscar_video(args, message) {
let respuesta = await doRequest("https://www.googleapis.com/youtube/v3/search?part=id&type=video&q=" + encodeURIComponent(args) + "&key=" + yt_api_key);
let json = JSON.parse(respuesta);
if (!json.items[0])
message.reply("No se encontro ningúna canción.");
else {
let id = json.items[0].id.videoId;
reproducirYoutube(id, message);
}
}
Hi, I am getting such a mistake. Does anyone know the solution?
npm install quick.db
I Know And I Don't Install It Gives An Error Again
@limber flume
I still take into account the error, in what I mentioned before
(node:2067) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token u in JSON at position 0
at buscar_video (/app/server.js:263:21)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:2067) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2067) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
let respuesta = await doRequest("https://www.googleapis.com/youtube/v3/search?part=id&type=video&q=" + encodeURIComponent(args) + "&key=" + yt_api_key);
let json = JSON.parse(respuesta);
in this lines, set "respuesta"
how do you git ignore a config.json file cos i want to put my bot code on github
is that even possible
just add your config.json to your gitignore file
how do you do that
k
do you have a gitignore file?
no
then create one
its text file that has to be named .gitignore
now open it, and write config.json
and save it
do you use github desktop?
no
you use the git command line?
ye
can you make it preview which files will be pushed?
how do you do that
idk, i use the desktop version, it does that for you automatically
oh
but anyway, you can make a test
delete your important stuff from your config.json
and try pushing it
see if your config.json is properly ignored
if it works and your config.json is not sent to github, put your important stuff back in it
ok
very quickly
will this if statement in my code
if (message.member.roles.has(ownerRole) || (adminRole) || (adminBotRole))
ownerRole, adminRole and adminBotRole are all consts
false?
could you tell me why?
if (command === "blackjack") {
let a = 11;
let card = [2, 3, 4, 5, 6, 7, 8, 9, 10, a];
let c1 = card[Math.floor(Math.random() * card.length)];
let c2 = card[Math.floor(Math.random() * card.length)];
let cardtotal = c1 + c2;
let ct = cardtotal + c1;
await message.channel
.send(
"Your cards are a " +
c1 +
" and a " +
c2 +
", with a total of " +
cardtotal +
". Do you want to hit (:white_check_mark:) or stand (:x:)?"
)
.then(sentMessage => {
sentMessage.react("✅");
sentMessage.react("❌");
const filter = (reaction, user) => {
return (
["✅", "❌"].includes(reaction.emoji.name) &&
user.id === message.author.id
);
};
sentMessage
.awaitReactions(filter, { max: 1, time: 10000, errors: ["time"] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === "✅") {
message.reply("You decided to hit your new score is " + ct);
} else if (reaction.emoji.name === "❌") {
if(cardtotal > 21){
message.reply("You decided to stand with a score of " + cardtotal + " you lost")
}
message.reply("You decided to stand with a score of " + cardtotal);
}
})
.catch(collected => {
message.reply("You didn't do anything, so now the game's over.");
});
});
}```
how could i make it so they can hit again
because right now they hit and cant hit again
Which type of actions (for a bot) can require administrator permissions ?
in what context
None
I just saw that admin perms are prohibited
But a few bots are declined because they need admin perms
So
I ask to avoid mistakes
k
well
i mean
if a mod has come up to u and said that you dont need any perms
than hes prob right
Does anyone know if there's a way to dynamically subscribe to new messages in guilds? Parsing every single message in every guild is quite expensive
I see a lot of bots getting declined because they have certain web search function, which could be misused for nsfw. In my case I have made a bot in the queue with which you can add any number of wikis to an server. Is that any reason to be declined?
wikis as in from wikipedia?
i think they have nsfw images in there for some specific wikis lol
or at least used to
Any wiki basically, as long as it uses the mediawiki api (which wikipedia, but also every gamepedia and fandom wiki is based on). So f.e. nookpedia.com, minecraft.gamepedia.com, scpcb.gamepedia.com.
can the wikis be directly searched by users with no setup? if yes, should be nsfw only
the wikis need to be explicitly enabled by admins before users are able to search them? if yes, should be fine
Yeah, only the owner of a server is able to add and remove wikis
thats fine then
Okay 🙂
i have a rlly edge case where my bot can screenshot websites
and it uses cf to clock nsfw content but ofc it isnt perfect
im yet to find a nsfw site that isnt blocked but it can happen someday
@brave thorn How To Show How Many Servers The Bot Is In IN Python
Have You Tried Reading The Docs
could anyone help
Just Ask
ive got an error with my bot
hey guys , i reached 75 server
i sent a id cart but it didn't works
when i want to verify it again he says
rn im trying to make a role coammdn
how it will work
specified roles will be able to use the bot to grant role
obv not like admkns grant people owner
but
i keep getting an error
the error is
@pale vessel whats the problem
TypeError: Cannot read property 'first' of undefined
ive got my code here
then you will be able to see where the error points too
if(args[2] == "admin")
{
if(member.roles.cache.has(ownerRole) || (member.roles.cache.has(adminBotRole)))
{
message.mentions.members.first().roles.add(adminRole)
}
}
if(args[2] == "moderator")
{ if(member.roles.cache.has(ownerRole) || (member.roles.cache.has(adminRole) || (member.roles.cache.has(adminBotRole))))
{
message.mentions.members.first().roles.add(moderatorRole)
}
}
if(args[2] == "trial")
{
if(member.roles.cache.has(ownerRole) || (member.roles.cache.has(adminRole) || (member.roles.cache.has(adminBotRole) || (member.roles.cache.has.add(moderatorRole)))))
{
message.mentions.members.first().roles.add(trialModRole)
}
}
if(args[2] == "tester")
{
if(member.roles.cache.has(ownerRole) || (member.roles.cache.has(adminRole) || (member.roles.cache.has(adminBotRole) || (member.roles.cache.has.apply(moderatorRole) || (member.roles.cache.has(trialModRole))))))
{
message.mentions.members.first().roles.add(testerRole)
}
}
any
anyone?
yes
Epoch time continues to increase in numerical value right
so a statement like
if(time1 < 1588367795)
would accurately represent before/after?
assuming time1 is an epoch value as well
Hello, 14 hours my bot is closed, not working.
1 | shard | Error [SHARDING_READY_TIMEOUT]: Shard 0's Client took too long to become ready.
I get the error, anybody know about it?
14k servers - 900k users
@slender thistle then what do you call it when you make a bot public
Listing it
@wind snow to clarify a few points:
top.gg is not a hosting service, they do not host bots, they just list them. All bot owners need to provide their own hosting service or host it somewhere.
top.gg is a place for public bots, so if your bot is supposed to be used only in your server, not point for it being public.
and honestly, i dont think $5 would be enough, even for a simple job like that
sure some people might do it even for free, but a quality developer with some experience will likely charge more than that
Even if they had a template to start something basic
I'd valuate a "custom bot" at $50 minimum assuming debugging and being asked to do this and that
More rewarding to spend a few weeks learning and be able to do whatever you want
also there is an issue with the role logic
afaik the current role limit is 250
so with enough players having a unique number of wins, you would reach that limit eventually
Yep, the role limit is 250
updates are scary when your shit breaks
are you completely resetting your bots db?
lol I think I've poked the djs11/12 syntax enough
tired of 2 different schemas overwriting each other
Well, I'm gonna delete anyone inactive
give anyone thats played recently a new profile
I think of 1000ish players in the db maybe 32 are active?
lel
honestly, a complete reset of progress would cause me to not invest further time and energy, because there is no guarantee of it not happening again
Yeah its a morale dinger for some
but the "old version" of my game had way too much grinding attrition
of evrey server it went to, eventually only 2-3 people played
i have almost 20k user-generated db entries, many of which have been abandoned for maybe 2 years lol
nope
actually speaking of paying stuff
I found a number of useful artists on fiverr
paid a guy $20 for 20 discord emojis of respectable quality
that's about as cheap as I've ever seen labor
damn
tbh if i need pixel art i would do it myself
but discords compression is like hahahahahahahahahahahahahahahhagaahahahahahah fuck you
I consider myself capable of doing pixel art but some people are much better at shading
discord just kills pixel art
ye that looks nice
downscale it to 32x32 in photoshop before uploading to discord
then it will be 1:1 scale
i upscale 16x/32x to 512x lul
I think that's the best part of pixels is that they always downscale well
yes but 32x looks even shittier somehow
idk, last time i uploaded a 32x32 emoji, it looked exactly like it did in photoshop
aka, nice and sharp
a 32x32 png should be identical
aseprite > *
run it through pngquant before uploading
to help lessen the load on discord's servers
:^)
wouldnt pngcrush work too?
mm dank asset pipeline here
16x16 aseprite image -> upscaled to 32x32 -> pngcrush/pngquant -> dicksword
on an unrelated topic
what are some popular ways to deal with command spam?
behind the curtain ignoring?
messages to tell them they have a CD?
I was doing this for awhile
so i have this error right
at Server.setupListenHandle [as _listen2] (net.js:1270:14)
at listenInCluster (net.js:1318:12)
at Server.listen (net.js:1405:7)
at Function.listen (/rbd/pnpm-volume/8026e4ea-29c1-4714-8479-5e7241f9946b/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/app/src/index.js:6:5)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
code: 'EADDRINUSE',
errno: 'EADDRINUSE',
syscall: 'listen',
address: '::',
port: 3000 }```
and this is where it's erroring
var app = express();
app.get("/", (request, response) => {
response.sendStatus(200);
})
app.listen(process.env.PORT)```
so why is this happening and how do i fix it
well quite literally it seems the port your using is in use?
has this worked before?
indeed it has worked before
I'm not familiar with express syntax but all I can imagine is you have 2 instances of the bot open
or something else is using the port
can anyone give me some cool idea about Dashboard
any reason why it would destroy the client randomly?
excuse my horrible logging skills 
so ^eval message.channel.send(client.emojis.cache.first(20)) would give me the first 20 emojis but is there anyway i could just get the 20th
turn it into an array then index it
Two ways are turning it into an array and accessing the index 20 or using the find function and checking the index to be 20th.
Help?
{
“name”: “greeter-bot”,
“version”: “1.0.0”,
“description”: “proyect”,
“main”: “bot.js”,
“author”: “MejoreXs”,
“dependencies”: {}
just send the whole package.json
so... i have def. prefix defined in index and what so. but i need help making a command that when you ping it, it returns default (k/) if no prefix is set in a json.. so far i have it able to send it when it is changed but when its default is the issue.
guild.members.cache.filter(member => member.user.presence.status === "online").size
Its not showing the correct numbers of online members.
did you use message?
yes
presuming you wish for a certain guild?
message.guild.members.cache.filter(member => member.user.presence.status === "online").size
?
yes
what are you getting?
its showing 31 when there is 120
So I am trying to create a /me command for my bot, and I am not sure exactly what to do, I did however get it to do what I want and take the message content and put it into an embed, but I want it to disregard the command prefix (which in this case is //me because discord already has a /me function and wouldn't work with my bot).
var embed = new RichEmbed()
.setTitle('In Game Action!')
.setColor('#a1ee33')
.setDescription(<@${message.author.id}>+ ': ' + message.content)
message.delete()
message.channel.send(embed)
break;
This is my current code.
@earnest phoenix Can you mix all there is not "offline" togehter?
uh....
Like "online, dnd, idle" in one number
hmm i supose you could make.it hard and make it like a math... and add it if you dont want OFFLINE to show
But i thinked it could count like discord does?
not sure..
what you can do
?
one sec
message.guild.members.cache.size - message.guild.members.cache.filter(member => member.user.presence.status === "invisible").size
try that?
lemme recheck
should be accurate
What should that do
it will get all members and subtract all invisible (offline) members
300?
260
send the code line?
message.guild.members.cache.size-message.guild.members.cache.filter(member => member.user.presence.status === "offline").size
@blissful karma ur using the wrong "s
try that above ^^@smoky cedar
yw!
@blissful karma ur using the wrong "s
@white anvil which is the correct one?
what device did u write this package on
@blissful karma I'd change ur name before it's too late
Also, download notepad++ at least
notepad++ it's the solution?
No
But it'll save u some hassle later on
Paste that text here https://jsonlint.com
JSONLint is the free online validator and reformatter tool for JSON, a lightweight data-interchange format.
See if it gives u some error
That doesn't look like a normal "
When you guys use a DB and make a connection in JS, do you store it in like client.xyz?
Because if I want to do that, such as
(async () => {
try {
const result = await mysql.createConnection({
host: process.env.DB_IP,
user: process.env.DB_USER,
password: process.env.DB_PASS,
database: process.env.DB_NAME,
});
client.con = result;
// The rest of the index.js file inside of here
} catch(e) {
console.error("DB ERROR: " + e);
};
console.log(client.con);
``` I need to put all of my code inside that try statement
Right
Afterwards u just need to retrieve it to create queries
I know what it does, but in order for client.con to save globally, I need all of my code inside the try statement
No you don't
its undefined because its an async function
and you're trying to access it from sync
Because you're printing before it's set
@blissful karma use these quotes " everywhere
the ones u use are weird fancy ones that json doesnt support
it needs to be the straight ones
So do I .then() of the async function?
Yes
And put the rest of my index.js file inside of the .then?
no
Also, it'd be better if u run that code BEFORE you start your bot
Like, store the connection as a sole variable
You might run into issues later on if your bot starts before your db connects
I mean I put the connection before client.login
the reason your console.log is returning undefined is that all code inside an async function has a bit of delay to complete, but this delay does not block the rest of your code, so your console.log is executed before the async function is finished
Ah gotcha
So then I thought I would put all my code inside the .then for it to work
Just dont bro
Then how am I gonna wait on that to finish
Put only the login inside .then
you dont need to, because the discord client also takes a while to initialize, and by the time the client is ready, that async function already finished a long time ago
Or that
Ooooooooh @lyric mountain
Honestly, I just want to do this the same way bigger developers do it
I want to learn the right way
So if that is to .login inside the .then so be it
That's the right spirit
Actually, kudos to you for even trying db as first persistence method
if you're gonna use .then, you dont need the async function lol
Most just go to json as it's the easier path
@quartz kindle the connection is an async method afaik
Thanks. I mean I've done D.JS for about a year now and I'm working with someone and this came up
I always used promise-mysql, then put ALL my code inside the .then
Now I use mysql2
You just need to pay attention to code flow
Also, one thing I HEAVILY recommend u is to make a global functions file
For example
Let's say you use doSomeMath() in a lot of places in your code
Instead of declaring it everywhere, you could put it inside a file, export it and call it in other places
Yeah I'm doing that with my dbqueries
This way you'll have a more organized code, probably a lighter one and debugging will be a cake
I make a function for getting user's data, etc. Then this is also my first time I am actually storing mysql data in the client. For example, I will map everything I need to in the client. Then for things that change, such as a user's points, a guild's config, etc, I just have to updated both the map and the DB
"organized"
Why bowsie lol
That way if all I am doing is checking a user's points, checking a config, etc, it doesn't query
lol bowser
lol
Heres mine
- indexFake. Last night bud and I were up until 2am trying to figure this shit out
I must say, you have a great future in development
Thank you!
Consider yourself one of the top 30% bot devs

Bowsie, I'll still beat that doggo
I appreciate it! I'm 15 and hoping to get a career in the future that I'll enjoy
I'm probs gonna go with web dev
anyone able to assist with?
[ https://discordapp.com/channels/264445053596991498/272764566411149314/709546477806026776 ]
So, the only thing i see there is you sending the stored prefix
right... but id like to send default if no stored prefox is there
You could just do prefix === undefined ? "k/" : prefix
Or just do an if else clause
i did attempt an if else but always messup when i get an error:
cannot read prefixes of undefined
@turbid bough hey, can you believe I made a bot myself already and it already generates a link with the query parameters when the user joins
The Error
(node:12276) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
The Code
case 'me': {
if(!args.length) {
var emebd = new RichEmbed()
.setTitle('⚠️ Error in: User Arguments')
.setColor(0xFF0000)
.setDescription("You didn't provide any arguments, so I can't send the message you wanted me to, sorry!")
message.delete();
message.channel.send(embed)
} else {
var embed = new RichEmbed()
.setTitle('In Game Action!')
.setColor('#a1ee33')
.setDescription(<@${message.author.id}>+ ': ' +\n ${args})
message.delete();
message.channel.send(embed)
}
break;
}
I don't know why its saying the message is empty however....
I want to put it in an embed is the deal. I don't want it outside of the embed.
Third line dude
emebd
You're sending embed, but declared emebd
Brain 404
EXACTLY!
Lol you're welcome
It works now.... damnit.... The struggles of Coding, mess up on one thing and THERE GOES THE PROGRESS!

Now I just gotta figure the next problem out, how tf do I get rid of the commas? Because I followed a tutorial for this one and it didn't mention how to get rid of the commas for my user args.
@stable nimbus I'd recommend intellij
But only ultimate edition has JS support
It does help u find a lot of hidden or overlooked issues
I use VSC, and its nice. I need to send it as an array instead of a string though.
Gl
Did I do something wrong?
There's supposed to be 23 bots
Can anyone assist me with Samba on Ubuntu?
the only thing wrong in that image it the white theme
I am a bit confused with "guildMember.roles.set([])", how do I use it if I have the username of the user?
I am reading documentation and it uses methods that depend on the user either being mentioned or sending a message
I just want to add a role from the username
you fetch the user
and get an user object from there
don't post dots for fucks sake
you use <guild>.members.cache.find, you can't fetch with a username
@bitter sundial Hey mate, can you join voice for a moment if you're here? I have a few samba questions.
global codes
global role
codes = []
if message.content.find("$addcode ") != -1:
if message.author == message.guild.owner:
arg = message.content.split(' ')
codes.append(arg[1])
role = arg[2]
else:
await message.channel.send("You are not the owner")
if message.content.find("$code ") != -1:
arg = message.content.split(' ')
if arg[1] in codes:
codes.remove(arg[1])
await message.author.add_roles(role)
await message.channel.send("Code accepted!")
else:
await message.channel.send("Code does not exist")
that is part of the code for my join codes bot
i wanted new server members to be able to claim a few hours of ranks when they join but
$addcode works properly
$code keeps saying that the codes added with $addcode dont exist
to see if $addcode was the problem i added a print(codes) function after it adds the code
@copper cradle @smoky spire any example code that I can see?
<guild>.members.cache.find(member => member.user.username === 'nameHere');
tbh ..username should be renamed to name
unless the user object has a name property already
other than that it's very redundant
but it's called a username
are u trying to find a specific member by name?
if ur doing python i can help
but if you don't call ur user var "user" than that doesn't work
Also just name could be confused between nickname and username for new devs
¯_(ツ)_/¯
Sorry guys, maybe it's better I ask in the DiscordJS server
what did you try?
i think it would be the same
put all members in list
loop through that list and check wether the name matches the one your looking for
in python:
members = message.guild.members
for x in members
if x.name == name:
do whatever
David show the code you have
ik ur using JS but i cannot do loops in JS
and any the error log if you're getting one
I don't have any code for this function @copper cradle
I gave you an example david
im not sure why u need the member name try finding by member object
filter returns more than one result
that's what I was gonna say
@copper cradle I'm not even sure how to start implementing, I'm processing the info
Ideone is something more than a pastebin; it's an online compiler and debugging tool which allows to compile and run code online in more than 40 programming languages.
But I didn't implement that yet
i think it would be the same
put all members in list
loop through that list and check wether the name matches the one your looking for
in python:
members = message.guild.members
for x in members
if x.name == name:
do whatever
this is the python code
im sure its the same principle
create list with all member objects
loop through that list and check if name matches
@viscid goblet are you talking about what I asked?
There's no way to just refer to the userid ?
I thought this would be easier
yes there is
if you don't know where and how to implement that piece of code it's maybe a sign you should backtrack and learn a bit about programming and the language you're working with
I have User#1234, this is not enough? I have to search for the user by creating some list? sorry guys a bit lost here
the member object contains most info about member: name, tag, id and mention
dude this is code for creting list
members = message.guild.members
Can you explain the logic to me step by step? So
do you need the author id? blind
The way to do this is to create a list of all members right?
can you explain what you're trying to do?
find the member
i gave u the list code then u need to use loop code
for x in members
if x.name or x.id == name or id:
do whatever
you don't really need that if you're looking for a specific member
But you guys lose me completely when you say find the member
do not use both use if x.name == name: or if x.id == id:
you can use methods such as .find or .get
Again, I will ask because I am confused. The way to do this is create a list of members?
and then I have to find the member that has that user id right?
you might want to learn basic javascript and read discord.js documentation
so u want to know how to add a role to message author?
@north crane I think my challenge now is referencing a user from a userid
But ok, I will try some stuff now
two options: A) use my bot verify (ive made this code before) B) message.author.add_roles(role)
I don't want to get it from the author
I want to get it from a command!
!member User#1234
ok so ur command is !member @ user
u will need to account for args so here help with that
if message.content.find("!member ") != -1:
arg = message.content.split(' ')
Let me start with that
now do u think you know how to get the member from the first argument
I think that's exactly the part I am most lost with
dude thats the easiest part member = arg[1]
You mean that..., that yeah I could figure out
member is your user and it takes that from the first argument (arg[1])
It creates a list right? So yeah.
arg is your list
Split on spaces, nice.
arg is the list of arguments included with the command
however this means u can use a command inside a message
Sounds good, not a problem
I see, but not so worried about it.
ok
now u need to actually give the role
the function for this is add_roles(role)
yes
i tried and failed making bots with JS so i switched to python cos ive used for 2 years
yeah what role do u want to assign to the user (I assume the member role)
Yes, I want to assing a role called Member
It's part of a whole workflow
People signup on a form, the form sends a webhook to discord, the bot should grab that webhook and assign a role to a member
I already did the whole thing
if u didnt define the role earlier i REALLY hope i have some old Verify code on my system
So registered users get the role automatically
yeah i dont BRB
I learned a bit of python in the past
So that's why your code was sounding very right
ok i hope this works
roles = message.guild.roles
for x in roles
if x.name == "Member" or "member":
role = x
await member.add_roles(role)
But this is python right?
yes
I understand it, not sure if I can translate it though
in case u need, heres how u do post requests in python
import request
#add to top ^
a = request.post(url, content)
i have my own bot to fix
make that two bots a bunch of people have been DMing me about my free nitro generator not working for them but i tried and it worked perfecty
Tough shit
@lapis ocean why do you need to send 'n catch a webhook?
Because I want to give people that signup on a form get a role automatically @lyric mountain
Sure but, the bot that'll send a form is the same bot that'll give the role, right?
?
So, why don't you just create a webserver and send the data there?
Then listen to requests made to it and give the role directly
Because that sounds like I have to build a universe from scratch
Using webhooks would be very iffy, since you can't detect which user is a wh and which is a real bot
No you don't
2 min setup with express
I have everything working already, a website a form, everything integrated with each other
You telling me I would need a new form, maybe coded from scratch or something?
As a http request
Yeah, I would have to build my own form system or use another solution that doesn't have the same integrations
Just not figuring out clearly how to give a role to a user
I'm using Discord JS
Diamond already gave me some hints using python
Have you read the docs?
I've skimmed :eyeroll:
It's like, right there
I've read that @lyric mountain , but not sure how to implement due to low IQz or something
guild.member.roles.set
Guild can be gotten from the message object
The message object is returned from onMessage event
message object?
But what if the user doens't send a message?
I wanted to do a command like !member User#1234
Aren't you getting user id on the form?
Yes, actually I am getting user.tag
really?
Never ever use it for checking
But it's almost in real time
I believe you
Isn't that murphy's law or something?
LOL
The users are very removed from the process
Like, just get the id from the mention
Hence why I built it this way, my other solution relied on users typing in their own user IDs
Then use it for user manipulation
The mention is a user object
You can get the id from it
Which mention? The mention generated by the command?
@lapis ocean <--- user object
The problem is that if I asked for a Userid on the form I don't have a manual fall back
Where in case the bot doesn't work or isn't compatible with some feature at least the user could input their ID manually
User IDs are already complicated enough on Discord
Yeah, but that's more complicated, I just have a form really
User ids are as simple as it can get
Ok, I am not trying to argue with you.
A number = a user
Email is complicated
ID doesn't have any #09348
Everyone remembers their email, that's my point. That's what complicates this
On form submission the user submit their email anyway
But this is all beyond the point.
You're trying to reinvent the wheel, the user doesn't need to know their ID
if i have this
Ok, I have realized the best way to do this is to not force the user to get to know his ID or even User Tag
Ok, it's bad right?
If I wanted to store DB rows in a variable should I use maps or is there another approach? I hate having to do .get("rowName");. I'd rather just do .rowName like a regular query
