#development
1 messages · Page 873 of 1
so i know this is completely far off but a ui change is supposedly coming for bots
you could wait until then and just use inline/non-inline for now
gui*
.addField("title", "body", false)
.addField("title", "body",true)
.addField("title", "body", false)
that gave every field it's own line
true, true, false, true?
how does that work
uuh, lemme test it myself
ight
afaik it is not possible to delegate two fields a row
you gotta put a empty field to break
really? yikes
yep
what do you mean by empty? like literally has no content at all, or blank strings for the title + value?
at least for JDA there's a addBlankField() method
it's not like a field with nothing
i'll have to check what that does
field inlining is cursed
that is not at all how that should work lol
it's because true true put fields together, but false true and true false not
if one is not inline, then it'll not be in front nor behind ANY field
even inline ones
okay, looks like addBlankField is:
https://i.imgur.com/XD6Vjo6.png
which is equivalent to:
{
"name": "\u200E",
"value": "\u200E",
"inline": true
}
that is so cursed
lol
sometimes the blank field works
are you just passing two normal inline fields then a blank field like the one i put above?
you gotta do it like field field blank field field blank etc
cant add a true-inline with false-inline 😦
that is what i did
the property inline should just get replaced with some property named like reset-row or something
and fields should be inline by default
or a row index
that would solve this issue
like, all fields with row 0 would be together
lol yeah while we're at it let's just enable CSS grid for embeds 
yeah i think this was beacuse of discord changed some ui stuff again smh
i think i was able to do it before
and then i gotta reprogram all embeds again?
well unless they add something similar to embeds for displaying data i think they'll be relevant
hopefully they do the former
it seems there would have to be some kind of code execution or injection for that to work
nahhhh
or events
i'd assume you just send some JSON metadata and perhaps websockets will be used to handle input
or maybe you send the entire menu payload in one go
well, you need to program it somewhat right
like a whole game you can make with it
so i dont think you would be sending everything
yeah, i have no idea where they're going with it
that's a convincing looking animation LOL
has some neat concepts and i'm interested to see how they do it
im expecting 5 seconds delay each action
if it does become reality there will be like infinite customization options
great ideas terrible execution
well maybe
well that isn't execution
for me it looks like it just spams embeds to me just with return messages on embeds
i'm talking about other features over the course of the past year and a half
oh lol
ive barely even seen useful features
they had really good ideas but they executed them so poorly that discord devs started being a meme within the community
well nonetheless it's a platform we use and develop for
so when this UI change drops, you take what you can get
at least they're finally implementing it
"its time to drop discord, join <this random other discord clone>"
they promised contextual menus in 2016, 4 years ago
i meant what was shown in the concept, custom contextual menus* my bad
@slow capeupload to giphy and use an embed with the link to it
if they implement those contextual menus its gonna fuck me over after i spent so much time developing my reaction menu lmao
does someone know why
SELECT * FROM groupparticipants WHERE groupid = comp.group.id AND comp.group.tournamentid = "1"; seems to fail with Unknown column 'comp.group.id' in 'where clause'
despite the column clearly existing https://luca.is-inside.me/ZBwDFA4p.png
Do an inner join
You gotta select that table to use its columns
if they implement those contextual menus its gonna fuck me over after i spent so much time developing my reaction menu lmao
@quartz kindle don't think that way, it'll be fun
What about me that have an entire library made just for pagination? Lol
But I can't wait for those features
Lol
Intresting thing about those interactive menus too is that people can't really userbot automate them such as game bots and bots where you have to claim stuff in chat that randomly spawn
Yep
It'll fix A LOT of selfbot issues
Well, if developers are willing to update their code, obviously
not for long probably
people will figure out how to selfbot the interactions since discord will have to make a API for it
if discord introduces clickable elements, bots should never have access to it
who in the world would make bots be able to "click" on embeds and why lol
Just like the context menu, which probably will be unavailable to bots
but selfbots made with userscripts on client side will still be able to
you could just use selenium
theres no way to stop those
Well, yes
for semi automation of your account
But it'd be a really complex code simulate user interaction
At least not the level that majority of people here would be able to achieve
i played a browser game once, mobamanager, which had an event where random easter eggs would pop on the screen and move around, and you had to click them to get points
and i ruined the event for the whole player base
buy automating it?
i made a script to automate it, and released it to my guild members
and one of them reported me
lmao
lmao
at first, the points were hidden
so nobody knew who was ahead
when the leaderboard was released, i was in first place by like 10x more than the second place, and all the top 10 were my guild members lmao
we were collectively ahead of our rival guild by like 100x more points
it was stupidly obvious we were cheating
went broke
a couple times
i mostly used it with shitcoins so no real loss
if you're using v12, delete requires an options object
client.on("message", message => {
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]) {
case "give":
if(!coins[message.author.id]){
return message.reply("You do not have any coins")
}
let puser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[1])
if(!coins[puser.id]){
coins[puser.id] = {
coins: 0
};
let pcoins = coins[puser.id].coins;
let scoins = coins[message.author.id].coins;
if(scoins < args[1]) return message.reply("You do not have enough coins")
coins[message.author.id] = {
coins: scoins - parseInt(args[2])
}
coins[puser.id] = {
coins: pcoins + parseInt(args[2])
}
message.channel.send(`${message.author} has given ${puser} ${args[2]} coins`)
fs.writeFile("./coins.json", JSON.stringify(coins), (err) => {
if(err) console.log(err)
})
}
break;
}
});```
I have one its 3000
if i do the give command it only works once so if i do ^give @ a user 5
for some reason the command wont work again
You're not doing anything for users who have a coin balance. Look around your coins[puser.id] {...} code.
if(scoins < args[1])
You're comparing against the user instead of how much you want the user to give.
@heavy anchor it requires an object, you gave it a number
an object is like this: {}
for example {timeout:3000}
@sudden geyser how could i do thta
Do what
i changed the args[1] to args[2] but now the command doesnt work at all
Where did you change it. Do you know what args[1] and args[2] are supposed to be?
if(scoins < args[2]) return message.reply("You do not have enough coins")
args[1] is a person
Bump to kinolite's question
args[2] is coins
If nothing's happening, did you check your statement?
You're not doing anything for users who have a coin balance. Look around your
if(!coins[puser.id]) {...}code.
oh forget to fo that
i dont see anything wrong there if they are not in the file already add them too it
The issue is you're doing that for users if they don't have a balance. If they do, you don't do anything. In short:
if (!coins[puser.id]) {
// all your code
}
// Nothing's happening to users with a balance.```
Cinnamon roll, all you need to do is make that if only add a property to the coins object.
You should move the rest of the code under it outside that if statement.
isnt that where it is
client.on("message", message => {
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]) {
case "give":
if(!coins[message.author.id]){
return message.reply("You do not have any coins")
}
let puser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[1])
if(!coins[puser.id]){
coins[puser.id] = {
coins: 0
};
it ends right here then the code starts
let pcoins = coins[puser.id].coins;
let scoins = coins[message.author.id].coins;
if(scoins < args[1]) return message.reply("You do not have enough coins")
coins[message.author.id] = {
coins: scoins - parseInt(args[2])
}
coins[puser.id] = {
coins: pcoins + parseInt(args[2])
}
message.channel.send(`${message.author} has given ${puser} ${args[2]} coins`)
fs.writeFile("./coins.json", JSON.stringify(coins), (err) => {
if(err) console.log(err)
})
}
break;
}
});```
Unless I'm not seeing something, I think you're missing a } where you said it should end.
"No closing } here" as in you're missing another }
I always had a question on my mind and it's tumbling around in my head...
It's that how can make the bot find users/members with their usernames aside of mention or ID...?
@earnest phoenix get user array and filter by name
Hmm...
you can find members by username in members.fetch() as well
Or use getUsersByName
@lyric mountain in which function?
Lol
the one that says no closing isnt that a closing
getUsersByName is not discord.js, maybe another lib
Ik
Hmm true that
So like
await message.guild.members.fetch(f => f.user.username.toLowerCase().includes(args[0])) or something? @quartz kindle
Oh...
will work fine for cached members
so i need another braket
The best way to find bracket errors is to format the code
If everything is not aligned, then you missed one somewhere
well if im missing one then why when i add one do i get a error
@earnest phoenix if the member is cached, use .find()
if the members you want are not cached, then this
if i add a bracket i get a error
All will be cached but I'm still wondering like find them with this?:
await message.guild.members.cache.find()
?
@queen needle you need to remove whatever bracket you added before
basically your brackets are in the wrong place, you need to remove the wrong one to add that one
@queen needle you can't simply add one anywhere
You gotta find the right place to add it
@earnest phoenix cache functions are not async, not need to await them
Oh ok
But I'm confused about what to put inside the find() function lol (to find them by their username) @quartz kindle
Wait a second... Brb
fixed it
gj
@quartz kindle wait that function i wrote was good?
yeah looks fine
K lemme try it...
@quartz kindle wait...
Will the ones like this that includes 3 things like:
let user = message.guild.members.cache.find(m => m.user.username.toLowerCase().includes(args[0]) || bot.users.cache.get(args[0]) || message.author;
Work or only the ones that include 2 of them works?
OK
cant use .get because its not an id
and you didnt properly close the .find
but yes, you can do guild.members.cache.find(m => m.user.username.includes()) || bot.users.cache.find(u => u.username.includes())
although its kinda redundant, because if the member exists, the user will also exist
so it should be safe to find only from users
if(args[1] === message.author.id) return message.reply("You can not give coins to yourself")```
i can still give coins to myself?
what did you pass as args[1]
a person
as in the text
what did you pass when you ran the command (e.g. !annoy 264811613708746752)
mentions look like <@userid> with a ! if the member has a nickname
What you're really comparing is <@userid> === userid
i thought it would be $@{message.author}
wat
what would i use to make it so i cant mention myself
if your command only accepts mentions, then use something like message.mentions.users.first()
if your commands accept both mentions and ids, you can use a replace function with a regex for numbers only like .replace(/\D/g,"")
well like args 1 is the first user that was mentioned
so
if(args[1] === what would go here to make it so i cant mention myself
but args[1] is not a mention, its just the mention in text form
if you use message.mentions.users.first() you use the mention object which gets the id for you
let puser =
message.guild.member(message.mentions.users.first()) ||
message.guild.members.get(args[1]);```
so
Just do
if (CoinM.id === message.author.id){
return message.channel.send("blah blah blah");
}```
if(message.mentions.users.first() === message.author.id)
if you already have puser, then use puser.id === message.author.id
Yup
thank you it worke
@queen needle
Also that one on the bottom should use the cache function before the get(args[0])
Np
time to try to do a xp system
Good luck
Waitaminute
Custom prefix is something almost initial nowadays
Just make a simple table in sqlite
Even json db would do it
It told me I had a free quota
The site said nothing about having to enable billing
Looks like I can't use that API then
Would have been nice had the site told me before I put it in my code
for anyone who used rethinkdb before, which is better rethinkdbdash or rethinkdb-ts?
The type thing you just need to call the typing method
@lyric mountain How do I do that?
I already know how to delay it, so we don't need to go over that
@autumn quarry in jda I just call sendTyping() method
There must be something similar in js
So because it won't let me use the API, I can't have my bot filter data
Would have been nice if the site had told me that I had to enable billing before
Rather than telling me I had an already-available quota
oh
@lyric mountain im using json
You're not connecting to it anywhere in that code
true
yeah at first i thought it was slightly outdated but then i looked at it's docs and realised it makes way more sense that rethinkdb-ts
or rethinkdb lol
rethinkdb has promises too, if you dont specify a callback
but one key thing is that you dont have to have conn as a param when using query.run()
and that
Why are you writing in alternating caps?
The bot does not join the vOicE ChANnEl hElP
how did u define voiceChannel?
const db = require("megadb");
const warns = new db.crearDB("warns");
module.exports = {
nombre: "check",
alias: [],
categoria: 'Moderación',
run: async (client, message, args) =>{
const user = message.mentions.users.first() || message.author;
if (!user) return message.channel.send("Mencione a un usuario porfavor");
if(!warns.tiene(`${user.id}`)) {
warns.establecer(`${user.id}`, 0);}
let cantidad = await warns.obtener(`${user.id}`);
const embed = new Discord.RichEmbed()
.setTitle("Strikes de: **" + user.username + "**")
.addField("Cantidad de advertencias:", cantidad)
.setColor("#13ec12")
.setTimestamp();
message.channel.send(embed);
}
}
I have this command, but it doesn't show how many strikes the person has
Any ideas why it doesn't work?
show me the full code, since i can't help you with that screenshot u took earlier
@vivid cargo try voiceChannel.join()
no?
just add voiceChannel.join() after that permission check
are you in v12
he is
ok
um hey so its about my time to prepare for sharding cuz i have like 1.3k server now...
the lib i use is discord.js. i saw alot of people that is using external libs and not the default one off discord.js.
is that worth a look? and if it is, what lib?
@vivid cargo you didn't make the bot join the channel
run what tuan said
he gave you the function
jesus
Stop alternating caps dude

what
jeez
i need
can someone help me https://pastebin.com/ZETvr4Dn thats my code its supposed to change the prefix for that server but it doesnt
to
Put
voiceChannel.join()
Under that permission check in the bottom @vivid cargo
kill mysel
@vivid cargo this has nothing to do with permissions

Sorry i don't speak enchantment table
N WORD
WE HAVE 23-19 HERE
[Visible CONFUSION]
@vivid cargo don't use the n-word
<@&364144633451773953>
https://pastebin.com/ZETvr4Dn cough cough i need a lot of help
N word case
Got banned... Nice
I warned him
Handled. No need to ping the whole role for it tho. One person is enough.
Ok boss
lmao he got banned
I think we should mute them for at least 3 days and make them understand to not use it again instead of banning them in the first time lmao
I mean
He was warned
But if it happens again just ban
Yeah i guess
We moderate at our discretion and using the n-word is strictly prohibited here. If you don’t need any development help, please leave this channel.
cough cough
Uh... Ok...
N-word very against tos therefore ping all mods is ok
im having trouble with my prefix command could anyone help me https://pastebin.com/ZETvr4Dn thats the code
Ya I realized that. Again please stick to the channel topic.
Sir yes sir
yo, so i got all of the code to use the api, but i cant find any good apis to use for memes, does anyone have suggestions?
random-puppy
how would i get it from reddit?
@lucid pasture best module to use to fetch memes from Reddit is snek-fetch
^
any http library works but that's not the point
ok thanks! but how should i get a link to do so
@sudden geyser how can i use the snekfetch then lol?
Hmm
it just means it won't receive updates/disbanded
like request was recently marked as deprecated on npm
hey um if i looped through all the shards and found the guild, do i need to loop through all the shards to find a member from this guild? or the member is in the cache already?
so how do i get a link to the api?
To the module you mean? Or what? @lucid pasture
uhh just to pull random images or however that works
npm install node-fetch
Then
Just store in some random subreddits and Math.random() it so it would choose a random subreddit then pull the image...
However... Idk how node-fetch works...
so i got all of the fetch stuff but how should i store the subreddits
in an array
then when pulling a meme
"meme",
"dankmemes",
"other",
"Other"
];```
@lucid pasture
take a random subreddit out of the array
ok so if i put that code into a math.random, it would choose between those and then post an image from a random link?
your array should be a const variable somewhere and not inside of a function otherwise you'll be creating the variable every time the function is ran which is a nono for your memory
tbh thanks for you guys help but im just gonna watch a video on it
if(message.content.startsWith(`${p}mute`)) {
if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send("You do not have manage messages.")
let toMute = message.guild.member(message.mentions.users.first()) || message.guild.member(args[0]);
if(!toMute) return message.channel.send("You didn't specify a user!");
if(toMute.id === message.author.id) return message.channel.send("You can't mute yourself.");
if(toMute.roles.highest.position >= message.member.roles.highest.position) return message.channel.send("You cannot mute a member that has a higher or same role as you.")
let role = message.guild.roles.cache.find(r => r.name === "FrontierMuted");
if(!role) {
try {
role = await message.guild.roles.create({
data: {
name: "FrontierMuted",
color: "#000000",
permissions: []
}
});
message.guild.channels.cache.forEach((channel) => {
if (channel.type == 'text') {
channel.updateOverwrite(FrontierMuted, {
deny: ['SEND_MESSAGES', `ADD_REACTIONS`],
})
} else if (channel.type == 'voice') {
channel.updateOverwrite(FrontierMuted, {
deny: [`SPEAK`],
})
}
})
}catch(e) {
console.log(e.stack);
}
}
console.log(role);
if(toMute.roles.cache.has(role.id)) return message.channel.send("This member is already muted!")
await toMute.roles.add(role);
message.channel.send("I have muted them.")
return;
}
for my mute command
it creates the role
but doesnt add any perms
anyone knows why
@ me if you have any ideas
so, console.log(role) outputs right?
in documentations i read, it says it does not need an await for the addRole
if you have .catch(console.error) with
@turbid bough theres no error and it add the role
its jsut that the role does not mute the person
oh, then thats what you have to check with your server settings
or channel settings to be precise
ye
hmm
it doesnt have it there
does the bot have manage channels?
and manage roles?
cause you wouldnt be able to change role settings on a channel without those permissions (iirc)
it has admin
so, the channel overrides are not getting applied right?
can you do a console.log on the if statements within the foreach?
just add one under the overrides
btw, where is FrontierMuted from?
in js channel.updateOverwrite(FrontierMuted, { deny: ['SEND_MESSAGES', `ADD_REACTIONS`], })
should it not be role?
@daring sun How Do You Put A Discord Bot Online With Node.js
ask it nicely
what lib
yea
i checked them
Is that latest?
set_permissions is a function, not a property, but that isn't what you're looking for anyways
i tryed has_permissions
rip
Try looking at channel.permissions_for(self) my phone literally cant load these docs because of how poorly it's made lmao
Would be like channel.permissions_for(member).send_messages I think
Returns true or false
Wait
Are you trying to set perms or check them
i need to return for None or True
It will return False or True
A permission is either given or not. I don't think it can ever be None
Never
That's inherit
and why this command is working
await ctx.channel.set_permissions(ctx.guild.default_role, send_messages=None)
It's none and it's working
Because you can set it to inherit
okey
um i get this error when im starting my bot with a selected amount of shards, cuz currently its spawnning me only one shard if i use the recommended amount.
any idea of how can i fix it?
erorr: Error [SHARDING_READY_DIED]: Shard 1's process exited before its Client became ready.
code:```js
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./bot.js', { token: token});
manager.spawn(2);
manager.on('shardCreate', shard => console.log(Launched shard ${shard.id}));
How do I shard? Any help? The infos ive read are outdated
lib?
um i get this error when im starting my bot with a selected amount of shards, cuz currently its spawnning me only one shard if i use the recommended amount.
any idea of how can i fix it?
erorr: Error [SHARDING_READY_DIED]: Shard 1's process exited before its Client became ready.
code:```js
const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./bot.js', { token: token});manager.spawn(2);
manager.on('shardCreate', shard => console.log(Launched shard ${shard.id}));
@pallid marsh Same issue here
Discord.js
idk
(node:15833) UnhandledPromiseRejectionWarning: Error [TOKEN_MISSING]: Request to use token, but token was unavailable to the client.
at Function.fetchRecommendedShards (/home/inspiralgt/node_modules/discord.js/src/util/Util.js:241:23)
at ShardingManager.spawn (/home/inspiralgt/node_modules/discord.js/src/sharding/ShardingManager.js:175:27)
at Object.<anonymous> (/home/inspiralgt/index.js:4:9)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
(node:15833) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:15833) [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.
```And this issue along with it
@turbid bough u might be right
if i use the recommended amount its working but what if ill need more than one shard?
Now, my cmd is flooded with shard death logs
Halpp
SyntaxError: Unexpected end of input
at wrapSafe (internal/modules/cjs/loader.js:1063:16)
at Module._compile (internal/modules/cjs/loader.js:1111:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
at Module.load (internal/modules/cjs/loader.js:996:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
(node:15896) UnhandledPromiseRejectionWarning: Error [SHARDING_READY_DIED]: Shard 0's process exited before its Client became ready.
at Shard.onDeath (/home/inspiralgt/node_modules/discord.js/src/sharding/Shard.js:155:16)
at Object.onceWrapper (events.js:422:26)
at Shard.emit (events.js:315:20)
at Shard._handleExit (/home/inspiralgt/node_modules/discord.js/src/sharding/Shard.js:371:10)
at ChildProcess.emit (events.js:315:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
(node:15896) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 359)
@coral trellis Help
Check if your token is correct
It is
the second one is the bigger issue
const Discord = require('discord.js');
const config = require('./config.json')
const manager = new Discord.ShardingManager('./bot.js', {token: config.token});
manager.spawn();
manager.on('shardCreate', shard => console.log(`Shard ${shard.id} connected!`));
couldn't even spawn one
And it's flooding my console
What d.js version
12
It does say unexpected end of input at wrapSafe
Is that a file you require
At some point?
can i pass a db connection to all the shards instead of creating a mysql connection for each shard?
@high bough can you tell me the output of node -v?
https://github.com/nodejs/node/issues/31284 just because this
My internet is at 200kbps rn so its slow patience is needed
do u know how can i pass a connection to all the shards? @amber fractal
like a db connection
every process can have its own db connection
Run one db and form a new connection to the same db each shard
Idk of any other way
it shouldnt be any different from if you didnt shard your bot
ok
@amber fractal 13.12.0
opening multiple connections shouldnt be an issue too much
um as i see the ready event executed to each shard im creating, but i change my status on ready and i dont wanna change it everytime a shard is created cuz it can be an api abuse if i use alot of shards, then how can i make so it happens just when the bot starts?
and not like for each the amount of shards?
Each shard has seperate rate limits I'm pretty sure
Also
I believe each shard can have its own status as well
Don't quote me on that though
Yes mb
I don't want to be spoonfed, but could someone help me with setting a bots status to mobile? I don't really know where to start...
What lib
You cant
djs
Set to mobile
Oh I see what you mean
Ya, you cannot set to mobile
Thought you meant the set the status in general
They arent
...
Your cache has issues prob
Try to downgrade to node 12. @high bough (I really don't know if it will do anything, but it is the LTS)
@ember atlas what about this @quasi cloak thats what I meant
INSERT INTO votes (`user`, `created_at`, `updated_at`, `vote_count`) VALUES ("33", current_timestamp, current_timestamp, 1) ON DUPLICATE KEY UPDATE votes SET `updated_at`= current_timestamp , `vote_count`= vote_count + 1 WHERE USER = "33";
Anyone know why this errors, both statements work without the ON DUPLICATE KEY UPDATE
um wen i try to shard all of my shards are responding...
like i get a response 3 times
how can i fix it?
Do any of you guys have any suggestions of what i should add into my discord bot? It's based around moderation
-ideas
Find something that you would like in a bot, and has also not been done before. Try and come up with a list of things you are interested in, and think up ways you could make the task easier with a discord bot. Eg. I like fishing -> I'm in a fishing discord group -> I'll make a bot that has fishing data and gives fishing advice. or I like a certain cartoon/anime/tv show. -> Why not make a bot that reminds me when new episodes are released and their watch dates? Once you have a fair amount of concepts down, try and look for those bots on bot listing sites like this one. If you cant find a bot that does what you laid out before as a bot concept, then feel free to write it! Who knows? Maybe a lot of people would like what you create...
kk
but see
i like coding
so do i make a bot that codes
YES
FUCK YES
ILL BE A SEC
machine learning?
a bot which learns to code
yes
thats, something I haven't seen yet
haha goodbye next 6 months.
Oh I'm talking about learning it
Good ones train for a long long time
teaching
some guy on 2bt2 created a minecraft bot which trains on Mircosoft Azure with really highend graphic cards. (3k each)
(node:5856) UnhandledPromiseRejectionWarning: TypeError: client.guilds.forEach is not a function
why
does some1 knows why all my shards respond at the same time when i execute a command?
@earnest phoenix
How could I get it if I mention my bot and the command name run it in discord.js v12?
okey i understand
no one?
i download need 15.1.1
@clear island I'm confused, what are you referencing to?
are you trying to have your bot's mention as a prefix?
yes
check if your bot is mentioned within the message.
Don't need to map guilds, a collection extends a map, map has forEach https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach. Just need to use guild.members.cache
you can also use each()
a method which does the same thing but returns the collection instead of undefined.
I tried, but it doesn't run the command I don't know why.
MySQL keeps disconnecting every minute causing my bot to restart all the time
Not sure how to fix it
does some1 knows why all my shards respond at the same time when i execute a command?
It's <@id> (such as <@353782817777385472> but this wont account for nick names)
like i got 3 shards so i get 3 responds
@pallid marsh
https://github.com/discordjs/guide/tree/master/guide/sharding
I haven't done sharding in js yet but this should help.
@golden condor is your MySql local?
i watched this tutorial
No
it's text @pallid marsh
It's remote
It's mostly best to have your database local anyway to keep latency down.
@pallid marsh show your sharding file
const manager = new ShardingManager('./bot.js', { token: secrets.token});
manager.spawn();
manager.on('shardCreate', shard => console.log(`Launched shard ${shard.id}`));
const db = require("megadb");
const warns = new db.crearDB("warns");
module.exports = {
nombre: "check",
alias: [],
categoria: 'Moderación',
run: async (client, message, args) =>{
const user = message.mentions.users.first() || message.author;
if (!user) return message.channel.send("Mencione a un usuario porfavor");
if(!warns.tiene(`${user.id}`)) {
warns.establecer(`${user.id}`, 0);}
let cantidad = await warns.obtener(`${user.id}`);
const embed = new Discord.RichEmbed()
.setTitle("Strikes de: **" + user.username + "**")
.addField("Cantidad de advertencias:", cantidad)
.setColor("#13ec12")
.setTimestamp();
message.channel.send(embed);
}
}
I have this command, but it doesn't show how many strikes the person has
@pallid marsh your starting that file only once correct?
yes
@earnest phoenix what does the command show
In the console?
...
.___.
I need learn english.
https://anidiots.guide/understanding/sharding
const Discord = require('discord.js');
const Manager = new Discord.ShardingManager('./bot.js');
Manager.spawn(2); // This example will spawn 2 shards (5,000 guilds);
@pallid marsh
Wait
give that a go
@earnest phoenix say it in spanish
sends the embed, but if a person has 5 strikes for example, it shows that he has 0
nop
lol
still the same
what does warns.tiene return
@pallid marsh are you using latest?
latest what
discordjs
ill try
what does warns.tiene return
@copper cradle como?
what's the return value of it
console.log(warns.tiene()) and tell me what the console shows
I'm pretty sure values.tiene() doesn't return the amount of strikes, I guess it returns a bool
on wether or not the """""""""database""""""""" has the value in it
@earnest phoenix so
what did it show
Can someone help me with making a ticket system in my bot, i want to find a channel by name in my server and if it is not found then create one with the name as the userid of the message author in dm of the bot and all further messages from the author should come in the text channel with his userid and if anyone types a message in the text channel of the user it sends a message to the userid in the channel name..... I am bad at explaining this and i am really dumb at programming.... Help me plzz or the bots will come to kill me...
Did you try to do it yourself?
ummm yes for 2 days then i just gave up
i made a basic bot that does dm and stuff but i can't figure out the more complex stuff...
@obsidian sky
map/each through this collection. It returns a GuildChannel class for each channel which contains the name property
you can find mostly all you need within the docs.
If you're really not up for the task, you can probably find someone on fiverr or even get a job posted within #434058442764714002
Thanks😅 @stray wasp
np
Hi! I'm having some trouble with making a request to a REST Api
i was following along with the Discord.js guide on this
What i'm confused about is that.. fetch() is a promise? so why wouldn't await work on it?
you're welcome 
so I have an array with some chunks
[{pos: 0, size: 4, url: 'someurl'}, {pos: 4, size: 7, url: 'someurl'}, {pos: 11, size: 5, url: 'someurl'}, {pos: 16, size: 10, url: 'someurl'}, {pos: 26, size: 9, url: 'someurl'}, {pos: 35, size: 15, url: 'someurl'}]
What function can I use for .filter to get the chunks needed to get the bytes from pos 15 to pos 30?
just do object.pos >= 15 && object.pos <= 30?
uh... yes?
are you blind
Probably
you don't have a pos 15 in your array
there is no object with pos 15 in there lmao
you have pos.16
.-.
so I have an array with some chunks
[{pos: 0, size: 4, url: 'someurl'}, {pos: 4, size: 7, url: 'someurl'}, {pos: 11, size: 5, url: 'someurl'}, {pos: 16, size: 10, url: 'someurl'}, {pos: 26, size: 9, url: 'someurl'}, {pos: 35, size: 15, url: 'someurl'}]
What function can I use for .filter to get the chunks needed to get the bytes from pos 15 to pos 30?
read again
i know there is no obj with pos 15
????
I want to get the elements to get the 15 byte too
so the element before the element with pos 16 too
But there's no element with pos 15 that you can get when filtering the array 
exactly lol
again
Asking about your attempted solution rather than your actual problem
i don't want to get the element with pos 15. I want to get the elements needed to get the chunks with POSes between 15 and 30
but thats what the code is doing, you just dont have any more objects that fit the condition in the array
I
don't
want
to use all elements
for my actual code
that array is much bigger
okay can you just tell us what the actual problem is that you are trying to solve?
yes and
http://alex.is-bad.com/9CGbpbX.png
What can I do to get the element before the one with pos 16
argh
just reduce the number from 15 to 7...?
Let me explain from the start to the end.
I have an big array with elements as objects that have a pos, size and a download url property.
By fetching each element's download url then writing the data to a file will result to a bigfile.extension
I also get automatically a pos and a size of the only data I need from that bigfile. So, to not download all the chunks, I try to get only the needed elements from the big array needed for the data from pos to pos+size
It's hard to explain but I know what I want and what I'm doing
and this is ladies and gents xyproblem in it's true form
you have to fetch the element before too, take the last byte the response (which is at pos 15) and then you can continue what you were doing, if the last element is not at pos 30 you'll also have to fetch the next element from the last one and grab the amount of bytes needed to get to 30
I said I don't want to fetch the element
the max size for Buffers is 2gb
around 2gb
too bad you have to
I don't
there's no other way going around it, you need to fetch those two extra elements to get missing bytes
help me
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('', client);
dbl.hasVoted(`message.author.id`).then(voted => {
`Please vote for the bot to use this command`
})```
this command can be used by non-voters also
please help
please me if you can help
@earnest phoenix show your code
please help me also
@earnest phoenix you're passing straight up a string
so what should i do ?
take a guess
idk

we love it when help vampires don't want to use their brain 🙈
i'm trying to figure out what to send in ws in eris' client options to get a mobile status on my bot
there's no information on what to send and i've looked around, how do i do this?
tried sending this already as well
ws: {
properties: {
$browser: "Discord iOS",
$os: "darwin"
}
}
There's difference message.author.id and `message.author.id`
but it shows error if i remove it
because you don't have a message object
could someone help me implement a bearer authentication scheme in my header
i've been trying to use fetch
@valid frigate i dont think that is what the ws property is for
yeah i didnt think so either
i went off of a youtube video around how to do it in djs
Where are you going to get a message from
supposedly it also has a ws option you can pass to the client
i thought it would have worked the same
i need author id @slender thistle
And if there's no message, there's no author
And where do you think you can get a message object
I need you to think here for a sec
then who will use command ?
on which event do you execute commands?
??
hint: you receive messages
hey, im trying to implement this in my bot .. however im failing to do so using "node-fetch".. i have my api-token
help vampire lol
You're trying to access a message object where it doesn't exist
Think of trying to find an apple in a store that sells only soup. 
so what should ido ?
What's the point
Access the variable directly - message.author.id
Stringify a variable - `${message.author.id}`
which is easier to do?
Considering IDs are string anyway
to give error if non voter is using the command
you need to be able to logically resolve problems yourself, the whole point of programming is being able to do it yourself, to use your own brain to resolve a logical problem however you want - this is a simple structural issue which can be resolved in about a thousand ways, if you can't think of a correct one yourself, well,
train yourself to use common sense and logic to resolve problems
if-statement for voted 
not everyone should code
bruh
so i should stop codding
you decide ¯\_(ツ)_/¯
coding requires logic and mostly common sense
and calling us idiots won't help
nor give you those I mentioned
@finite bough const Discord = require("discord.js"); const client = new Discord.Client(); const DBL = require("dblapi.js"); const dbl = new DBL('', client); dbl.hasVoted(`message.author.id`).then(voted => { `Please vote for the bot to use this command` }) command can be used by non voters also what should i do ?
if (!voted) ...
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('', client);
if(voted(`message.author.id`)).then(voted => {
`Please vote for the bot to use this command`
})``` @finite bough like this ?
nah
then ?
can u tell me what exactly u r trying to do if possible
dbl.hasVoted(message.author.id).then(voted => {
if (!voted) return message.channel.send(`Please vote for the bot to use this command`)
})```
don't spoonfeed
@earnest phoenix if(!voted) means if not voted
please understand the code before using it
it will help u in future
it says message is not defined
learn about scopes and functions
define message
that'll help you
How can i get a bot's guild names that the bot is in them?
discord.js 12.1.1
and to use a message object you must define it some way, aka put the thing inside a message event
@copper cradle thats for you
as I said
@finite bough what should i define message ?
I don't really care what you call me
It's not idiocy
They're giving you an advice how to prevent situations like this in the future
mysql db keeps disconnecting in node.js
@earnest phoenix map
I don't know how to fix
client.guilds.map(..)
@finite bough k thx... I got it
@golden condor any errors
Yes
@finite bough also cache is needed
You don't define message
then ?
You get it from an event that sends message
@earnest phoenix maybe put that event inside a message event?
and I remember telling you which event it is
error when connecting to db: Error: Cannot enqueue Handshake after already enqueuing a Handshake.
at Protocol._validateEnqueue (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/protocol/Protocol.js:221:16)
at Protocol._enqueue (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/protocol/Protocol.js:138:13)
at Protocol.handshake (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/Connection.js:116:18)
at Timeout.handleDisconnect [as _onTimeout] (/home/cxllm/Bots/Corynth/db/con.js:20:14)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7) {
code: 'PROTOCOL_ENQUEUE_HANDSHAKE_TWICE',
fatal: false
}```
@finite bough
They don't have to see your full code if all you need to do is paste your code snippet into an event
@earnest phoenix thats my whole code
var mysql = require('mysql');
var con = mysql.createConnection({
host: '',
user: '',
password: '',
database: ''
});
con.connect(function (err) {
if (err) {
console.log(`Db failed to connect Ouput:${err.message}`);
setTimeout(con.connect, 2000);
}
});
con.on('connect', () => {
console.log(`Connected!`)
})```
this is my code for connecting to mysql
it connects then disconnects after a certain time
you arent meant to stay connected
Error: Connection lost: The server closed the connection.
at Protocol.end (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/protocol/Protocol.js:112:13)
at Socket.<anonymous> (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/Connection.js:94:28)
at Socket.<anonymous> (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/Connection.js:526:10)
at Socket.emit (events.js:323:22)
at endReadableNT (_stream_readable.js:1204:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on Connection instance at:
at Connection._handleProtocolError (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/Connection.js:423:8)
at Protocol.emit (events.js:311:20)
at Protocol._delegateError (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/protocol/Protocol.js:398:10)
at Protocol.end (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/protocol/Protocol.js:116:8)
at Socket.<anonymous> (/home/cxllm/Bots/Corynth/node_modules/mysql/lib/Connection.js:94:28)
[... lines matching original stack trace ...]
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
fatal: true,
code: 'PROTOCOL_CONNECTION_LOST'
}```
connect, execute query, disconnect
Yeah but it exits the code
^
yeah i understand that
@earnest phoenix i think you should put that event under a message event... That should define the message automatically
your code is built expecting to stay connected
But it then exits the code
u should disconnect after the end of a code
people dont do it
but
its a good practice
says the docs 
@earnest phoenix hmm now it dont show error
u can connect when u need to connect
why are you depending on a database connection to block your app from exiting lol
use mongodb then lmao
go to their website
mongo is easier than SQL
Cos I wanna connect to a remote db
yea
they don't need to migrate
Ya but it isn't gonna be hosted on the same machine
Ya that's what I am saying
Should I install mongodb compass on linux?
@earnest phoenix now my bot send both messages
Or should I connect to a remote db
mongodb compass helps u to see ur data
with atlas
Hmm... Can i see your code now? @earnest phoenix
I would recomend downloading it
can i dm you ?
u can also manipulate with the data manually using compass
@earnest phoenix sure
ok make acc
Not where my bot is hosted
just download it then
I have it
On my pc
it doesnt matter
I wanna use mongo
u can see ur data from ur pc as well
k
ok do u have an acc?
I have made one with my google acc
yea fair enough
You wanna take this to dms or something?
Already have
:3
@earnest phoenix Don’t attack beginners. Suggesting to « use their brain » or to « stop coding » doesn’t helps here. If you don’t have enough patience to explain things to people starting to learn programming, please mute this channel or don’t reply to people asking very basic questions. Thanks.
you're putting words in my mouth
To be fair, he didn't say that (to me at least)
they're a help vampire and there's no other way to help other than either spoonfeeding or encourage them to think for themselves
encouraging help vampirism is the worst thing you can do in development, and that was 40 minutes ago damn you are fishing
Shouldn't I connect compass?
Should I get mongoose or mongodb in npm
@finite bough where do I find the password for the cluster
We neither encourage spoonfeeding, and people doing that will be warned aswell. However, please try, instead of attacking them, to redirect to correct ressources. I can understand that they can leave it with a « I don’t understand », « It’s hard » or « Can you show me first how you do it? ». In this kind of situations, you can simply try to explain that they need to learn themselves and understand their mistakes. People begging for codes or looking for spoonfeeding even after warnings will be muted 👍
We neither encourage spoonfeeding, and people doing that will be warned aswell. However, please try, instead of attacking them, to redirect to correct ressources. I can understand that they can leave it with a « I don’t understand », « It’s hard » or « Can you show me first how you do it? ». In this kind of situations, you can simply try to explain that they need to learn themselves and understand their mistakes. People begging for codes or looking for spoonfeeding even after warnings will be muted 👍
@flat pelican ❤️
Mongo won't let me connect to the cluster aa
❤️
that's fine
I am in no rush
ok
I used the sample code to connect
and it worked
@summer torrent This channel is intended to help people, please don’t spoonfeed (giving the code directly instead of explaining the error is called spoonfeeding).
@golden condor add these { useNewUrlParser: true,
useUnifiedTopology: true}
const MongoClient = require('mongodb').MongoClient;
const uri = "My login stuff";
const client = new MongoClient(uri, { useNewUrlParser: true });
client.connect(err => {
const collection = client.db("test").collection("devices");
console.log(collection)
});``` i did this
I tried to show him an example, but okay
also add
useUnifiedTopology: true
