#development
1 messages · Page 851 of 1
i have 6 BOT in my server
{client}.fetchUser("ID_HERE")
That no longer works @elder vine
fetchUser is v11
use fetch then
<GuildMemberManager>.fetch is v12
I tried using that fetch but it always gives undefiend @sudden geyser
show code
How do you do that
what is
Use async/await
What is wrong with this
Alright
Is that even a thing in js?
learning js would help
Ok nah I'll just loop over all members
no
you don't have to, as you've already done so by using .then all you need to do is log member
alright
js is complicated
hello, i want to make a git pull command thats pull from the git repo, how do i make like that
lib: discord.py
using subprocess module ?
how to update node js under linux?
@earnest phoenix try apt upgrade nodejs -y maybe...
Thanks 😉
Np
What does guildMember.partial mean? That the object does not contain every property?
is my bot ping between 60 and 105 good?
?
You gotta provide email and password when pulling.
How do I do that?
Well, Im already logged in Heroku in the terminal
What does guildMember.partial mean? That the object does not contain every property?
@nocturne grove from the docs: https://discord.js.org/#/docs/main/stable/topics/partials
@sudden geyser that's what made me ask it. I looked at that first
It does mean an object may not contain every property.
okay thank you!
can you already use server templates in discord.js or at any api endpoint
I don't think it's safe to allow bots to use server templates
well my friend has a bot which can load server templates
Xenon 
[python] is there any way to add ; before every , in a tuple?
The comma that separates tuple elements?
yes
Uhh...??? Add ; to every element in a tuple?
@elder vine Do you know how I can avoid the error?
What error?
syntax error
\nServer Created at: ${message.guild.createdAtTimestamp} i want it to show the time when the server was created
any idea
isnt it just createdAt
Yup it's
message.guild.createdAt
xD
Np... But 15 minutes on this?...
Damn...
Or you could display it nicer with moment module
createdAt or createdTimestamp
but then you have to use the timestamp
then you can display in which order you want, and the information you want.
yeah for example Thu Nov 08 2018 20:32:42 GMT+0100 (Central European Standard Time)
Well, that is kinda, you know - filled up with a lot
just slice it off
thank you!
no need for extra deps
use moment package
installing it rn
Well with moment, you customize more - in my opinion it works better
yep i'm reading abt it rn
I have set it to delete the message within 10 seconds but will not delete it CODE ```js
let van = new Discord.MessageEmbed()
.setColor('#30acff')
.setDescription("Ilyen felhasználó van már az adatbázisban\nHa elfelejteted a jelszavad a weboldalon az elfelejtet jelszó fülön megváltoztathatod\n Website")
.setFooter(Ez az üzenet 30 másodperc mulva törlődik, bot.user.displayAvatarURL())
message.author.send({embed: van}).then(msg => msg.delete(10000))```
What is the error?
not deleted message 10 sec
Do you get any error in console?
not error
elfelejtett* btw
English please :P
okey
what version of d.js
nvm i see from MessageEmbed
message.delete({timeout: 10000})
they changed the api for that
@earnest phoenix
keep the arrow function
no
@earnest phoenix try it and see
message.author.send(van).then(msg => {
msg.delete({timeout: 10000})
});```
Working TANKS 😉
Good.
I can delete the private message sent so far
how?
use the fetchMessages()
for v11 ^
idk about v12
then just delete them for each message using forEach
messages.fetch
why is it so slow it downloads slowly for half an hour
so far it hasn't been 10 seconds for him
sammy what version of djs are you on
stable
also internal sharding
is what i want to try
also doesnt this mean i have to put an event in an event or is there a better and less dumb way
tim said that all you had to do was just shards: "auto"
.forEach(role => counter+=1)
confusion
works too
@knotty steeple you need the raw event for shard ready
nice
but you can do js client.on("raw", p => { if(p.t === "READY") { console.log(p.d) } })
you will see the contents of the shard ready packet
it includes the shard ID and number of guilds it holds
t = type
d = data
o
so is it that i set totalShards to auto
@quartz kindle would each shard's connection ready event be different to the client ready event?
on the ShardingManager
How would you play a file using ffmpeg in a voice channel (discord.js) without the stock functions because I dont think they use pure ffmpeg
would I use connection.play(ffmpeg(path))?
- login
- get recommended shards
- shard 1 connects (raw shard ready event)
- shard 1 receives list of guilds (guildcreate events)
- shard 1 ready (shardReady event)
- shard 2 connects (raw shard ready event)
- shard 2 receives list of guilds (guildcreate events)
- shard 1 ready (shardReady event)
.... repeat for N shards - client ready event
the shardReady event fires at the end
when it receives all guilds
updated the list above
also wym the second ready
the discord API itself only sends one ready event, that is when a shard connects
then discord.js fires all those additional events when it finished getting all guilds
shardReady for individual shards and ready for all shards
yea thats what im looking at
so if im using internal sharding also
broadcastEval and stuff doesnt work right
Tebrik ederim @knotty steeple! Seviye atladın ve 8 seviye oldun!
level up message?
oh possible
yeah thats a level up message and they had a fucked twitch status
yeah broadcasteval doesnt work with internal
Can anybody explain why my await functionOne(args) is not working, when functionOne() is async and the await functionOne(args) is located inside an async function? It's really irritating me and working with promises is far from ideal.
speaking of i probably should make my eval command
@nocturne grove error?
Show code
@nocturne grove are you calling the method correctly? what error does it throw?
I don't get an error. It's just executing in the wrong order
oh yes also
and that's not the intention
show code
how do i make it to it loads my commands first
I will explain it really quick
cuz im just reading a directory to see what commands are there then putting it into a collection
ok but it's long, I can just say how it works maybe
sometimes it doesnt events first and sometimes it does commands first
use hastebin
oh yea i wasnt using that
This is executed when my bot is starting:```js
client.guilds.forEach(guild => {
con.query(SELECT * FROM rolecounterdata WHERE guild_id = ${guild.id}, async function(err, guildrolecounters) {
if (err) return consolelog.execute(err);
if (!guildrolecounters[0]) return;
await log(guild, ':unlock: I am back online! I will continue counting role members for your server.', ['startup'], ' when I was offline');
checkpermission(guild, ' when I was offline', guildrolecounters);
startupcounters(guildrolecounters, guild);
});
});```
It's all about those 3 functions in the end. I will show them entirely, they should be fully (or for 80% at least) executed before the next one will be executed.
async function log(guild, message, logtype, messageaddition) {
con.query(`SELECT * FROM logpreferences WHERE guild_id = ${guild.id}`, function(err, logpreferences) {
if (err) return consolelog.execute(err);
con.query(`SELECT * FROM serverdata WHERE guild_id = ${guild.id}`, function(err, serverdata) {
if (err) return consolelog.execute(err);
if (serverdata[0].logchannel == 'off' || serverdata[0].logchannel == 'custom' && [0, undefined].includes(logpreferences[0][logtype[0]]) && [0, undefined].includes(logpreferences[0][logtype[1]]) && [0, undefined].includes(logpreferences[0][logtype[2]])) return;
const logchannel = guild.channels.get(serverdata[0].logchannel_id);
if (!logchannel) {
adminloop(guild, messageaddition, 'Log channel deleted', 'My log channel was deleted', 'I deleted it from my database and turned logs off.');
return insertdata.execute('serverdata', 'logchannel', guild, 'off', undefined, 'logchannel_id', null);
}
if (!logchannel.permissionsFor(guild.me).has('SEND_MESSAGES') || !logchannel.permissionsFor(guild.me).has('READ_MESSAGES') || typeof message == 'object' && !logchannel.permissionsFor(guild.me).has('EMBED_LINKS')) {
adminloop(guild, '', 'Can\'t send message in log channel', `I am not able to send my log in ${logchannel}`, 'I turned logs off for now. Make sure to give me the \'Send Messages\', \'Read Messages\' and \'Embed Links\' permissions in that channel. Then, reactivate logs.');
consolelog.execute('off automatically', guild, 'setlogs');
return insertdata.execute('serverdata', 'logchannel', guild, 'off');
}
logchannel.send(message);
});
});
}```
function checkpermission(guild, messageaddition) {
con.query(`SELECT * FROM rolecounterdata WHERE guild_id = ${guild.id}`, function(err, result) {
if (err) return consolelog.execute(err);
if (!result[0] || !client.guilds.get(guild.id)) return;
const deletedpermsembed = new Discord.RichEmbed().setColor('#FF0000');
if (messageaddition) {
deletedpermsembed
.setTitle('Manage channel permission has been removed')
.setFooter('When I was offline');
}
else {
deletedpermsembed
.setTitle('Manage channel permission was removed')
.setTimestamp();
}
result.forEach(function(rolecounterdata, index) {
const counterchannel = guild.channels.get(rolecounterdata.counterchannel_id);
if (counterchannel && (!counterchannel.permissionsFor(guild.me).has('MANAGE_CHANNELS') || !counterchannel.permissionsFor(guild.me).has('CONNECT'))) {
deletedata(guild, guild.roles.get(rolecounterdata.role_id));
deletedpermsembed.addField(rolecounterdata.counterchannel_name.replace(/\\/g, '\\\\'), `role name: ${rolecounterdata.role_name.replace(/\\/g, '\\\\')}\nrole size: ${rolecounterdata.rolesize}`);
}
if (index == result.length - 1 && deletedpermsembed.fields.length > 0) {
deletedpermsembed.setDescription(`I stopped counting for the following counter${deletedpermsembed.fields.length > 1 ? 's' : ''}:`);
log(guild, deletedpermsembed, ['counterchannel_delete'], messageaddition);
}
});
});
}```
the last one doesn't matter though, and that's a really long one
@nocturne grove you want each guild to await for all three functions to resolve before proceeding to the next guild?
hastebin please :P
no, wait
The problem is that in some cases, the log function will turn the log channel from the guild off. And it should wait for that to happen, because in the checkpermission and startupcounters function, the log function will be executed again. Now, it just executes the log functions in checkpermission & startupcounters before the the first log function was fully executed
How would you play a file using ffmpeg in a voice channel (discord.js) without the stock functions because I dont think they use pure ffmpeg
would I use connection.play(ffmpeg(path))?
instead of connection.play(path)
so it could be that the log function in the first code blocks toggles the log channel to off, but the log function referred to in the checkpermission function still thinks the log channel is on (but it should already been toggled off then)
@nocturne grove because you're working with callback functions
promises do not affect callbacks
I hope I've made it clear, but it's still really vague I guess
can't I use await/async for this? As promises are making the code longer and not really nicer
async function() {
bla(bla,function() {
return 10
})
return 20
}``` this function will return 20 no matter if you await it or not, because the callback function from the bla function starts a whole separate block of code that is completely independent from the async function
so it's because of the fact I have (for example) a con.query thing in the function?
since you are working with a database that uses callbacks, you cant await them like that, you need to create a new promise for each callback in order to correctly promisify it
for example
function() {
return new Promise((resolve,reject) => {
bla(bla,function(result){
resolve(result)
})
})
}```
the function returns a promise, instead of the function itself being async
and this promise contains the database query and only resolves when the callback is resolved
yeah that's what I did with the log function, but I should resolve it at multiple places then, because the functions won't always be executed until the last line
one promise worked, but I have to put the resolve() every time there's a 'return' in my code, so 5 times (and a resolve in the last line)
Is there no better way?
you can make one promise resolve only the very final value
but then my code never continues to the functions underneath it, right?
if I never resolve them
not until the promise is resolved
so I'd have to resolve it on 6 different places
you'd have to resolve or reject all possible outcomes of it
in order to avoid it getting stuck waiting forever
and reject just stops the function?
yes, reject throws an error
oh that's not what I want. So for me, I won't use reject
you can resolve the error instead of rejecting it
so the error will be returned instead of thrown
ah okay
for example, if the database gives you an error, you can simply return resolve()
which is the same as return undefined in a normal function
okay okay thank you! (I really have to go now) but thanks for your help!
Hope it will work eventually
👍
This is gonna sound stupid but whatevs, what would I add to my softban command to clear messages for the past 7 days?
because I'm having trouble understanding the documentaion from discord.js.org .-.
k thx
https://oliy.is-just-a.dev/laszc9_3413.png it's also the example
getting this error plz help
can you help me fix it ? @pale vessel
there’s no endpoint there’s some problem there is no route
it might be on glitch's end
show code?
might as well be an express server
@quartz kindle does the client guildCreate event get emitted for every guild the shard has?
so then would you have to make it return if the client isnt ready
I can't put something to be executed in between resolve(here), right?
But can I do js resolve() console.log(true);for example?
@grizzled raven when the client connects, discord sends you all the initial guild information in the form of GUILD_CREATE packets. these packets are identical to the packet send when a guild is joined, but discord.js takes care of that and wont emit its own guildCreate events until the client is ready, which only becomes ready after all the initial GUILD_CREATE packets are received
so you will only see the initial GUILD_CREATE packets through the raw event, they will never show in the guildCreate event
@nocturne grove resolve() doesnt imply return, so you actually can run code after you call resolve()
what you put inside the resolve arguement is what will be returned by the promise
so in my case, I do have to return ánd resolve()?
I'm sorry but I don't really understand things like that, but I guess I'd have to do them both
plese help me console log ```js
/home/dc/node_modules/mysql/lib/protocol/Parser.js:437
throw err; // Rethrow non-MySQL errors
^
TypeError: Cannot read property 'client' of undefined
at new MessageEmbed (/home/dc/node_modules/discord.js/src/structures/MessageEmbed.js:13:60)
at Query.con.query (/home/dc/commands/help.js:61:21)
at Query.<anonymous> (/home/dc/node_modules/mysql/lib/Connection.js:526:10)
at Query._callback (/home/dc/node_modules/mysql/lib/Connection.js:488:16)
at Query.Sequence.end (/home/dc/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
at Query._handleFinalResultPacket (/home/dc/node_modules/mysql/lib/protocol/sequences/Query.js:149:8)
at Query.EofPacket (/home/dc/node_modules/mysql/lib/protocol/sequences/Query.js:133:8)
at Protocol._parsePacket (/home/dc/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/home/dc/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/home/dc/node_modules/mysql/lib/protocol/Parser.js:43:10)
client is undefined
@earnest phoenix send the code where it went wrong
show help.js 61th line
help.js 61 line js let hhelp = new Discord.MessageEmbed()
@nocturne grove in the first example i did r(10), which returns 10 but doesnt exit the function, so the console.log right after will still work
in the second example i did return r(10) which returns 10 and exists the function, so the console.log right after will not run
what is your djs version 
newlest
Show code
whats your node.js version?
const Discord = require("discord.js");
module.exports = {
name:'help',
description: 'help!',
status: 'on',
async execute(bot, message, args, con) {
con.query(`SELECT * FROM prefix WHERE id = ('${message.guild.id}')`, async (err, rows) => {
if(err) throw err;
if (rows[0].help === 1) {
let coff = new Discord.MessageEmbed()
.setColor('#ff5930')
.setAuthor(`${bot.user.username} - ERROR`, bot.user.avatarURL())
.setThumbnail(bot.user.avatarURL())
.setDescription(":no_entry: Ez aparancs ki van kapcsolva! :no_entry: ");
message.channel.send({embed: coff})
} else {
con.query(`SELECT * FROM prefix WHERE id = '${message.guild.id}' `, (err, rows) => {
if(err) throw err;```
const anime = rows[0].anime
const baka = rows[0].baka
const cute = rows[0].cute
const fox = rows[0].fox
const hug = rows[0].hug
const kawaii = rows[0].kawaii
const kiss = rows[0].kiss
const neko = rows[0].neko
const pat = rows[0].pat
const slap = rows[0].slap
const food = rows[0].food
const smug = rows[0].smug
const tickle = rows[0].tickle
const poke = rows[0].poke
const help = rows[0].help
const website = rows[0].website
const uptime = rows[0].uptime
const mutecommand = rows[0].mutecommand
const unmute = rows[0].unmute
const clear = rows[0].clear
const boobs = rows[0].boobs
const cum = rows[0].cum
const hentai = rows[0].hentai
const kitsu = rows[0].kitsu
const lewd = rows[0].lewd
const lick = rows[0].lick
const pussy = rows[0].pussy
const trap = rows[0].trap
const yuri = rows[0].yuri
const stats = rows[0].stats
const howgay = rows[0].howgay
const love = rows[0].love```
const prefix = rows[0].prefix;
let hhelp = new Discord.MessageEmbed()
.setColor('#30acff')
.setAuthor(`${bot.user.username} - Commands List`, bot.user.avatarURL())
.setThumbnail(bot.user.avatarURL())
.setDescription('**Prefix: ``' + prefix + '`` <command>** ')
.addField(`:information_source: Core`, `| ${help ? "" : "``help`` | "} ${website ? "" : "``website`` | "} ${uptime ? "" : "``uptime`` | "} ${help ? "``ping`` |" : "``ping`` | "} ${stats ? "" : "``rank`` | "} `)
.addField(`:shield: Moderation`, `| ${mutecommand ? "" : "``mute`` | "} ${unmute ? "" : "``unmute`` | "} ${clear ? "" : "``clear`` | "} `)
.addField(`:musical_note: Music`, "| ``play`` | ``skip`` | ``stop`` | ``volume`` | ``np`` | ``list`` |")
.addField(`:gear: Util`, "| ``verify`` | Webpanel")
.addField(`:u6e80: Weeb`, `| ${baka ? "" : "``baka`` | "} ${anime ? "" : "``anime`` | "} ${cute ? "" : "``cute`` | "} ${fox ? "" : "``fox`` | "} ${kawaii ? "" : "``kawaii`` | "} ${neko ? "" : "``neko`` | "} ${smug ? "" : "``smug`` | "}`)
.addField(`:ideograph_advantage: Tag`, `| ${howgay ? "" : "``howgay`` | "} ${love ? "" : "``love`` | "} ${hug ? "" : "``hug`` | "} ${kiss ? "" : "``kiss`` | "} ${pat ? "" : "``pat`` | "} ${poke ? "" : "``poke`` | "} ${slap ? "" : "``slap`` | "} ${tickle ? "" : "``tickle`` | "} `)
.addField(`:underage: NSFW`, `| ${boobs ? "" : "``boobs`` | "} ${cum ? "" : "``cum`` | "} ${hentai ? "" : "``hentai`` | "} ${kitsu ? "" : "``kitsu`` | "} ${lewd ? "" : "``lewd`` | "} ${lick ? "" : "``lick`` | "} ${pussy ? "" : "``pussy`` | "} ${trap ? "" : "``trap`` | "} ${yuri ? "" : "``yuri`` | "} `)
.setFooter(`Chino-Chan | All rights reserved`)
message.channel.send({embed: hhhelp});
});
}
});
},
};
whats your node.js version? do node -v from your terminal
v8.10.0
thats a very outdated version
omg that embed
@quartz kindle oh wow of course, r is just resolve and you changed the function a bit, didn't see that. Thanks!
O_O
you need to install node.js v12 or later
owo
@finite bough SQL
not that
what
hedi lewd
^
1 horus update ndoe js linux
Hedi very lewd
1 hr O_O
@earnest phoenix you need to install node.js from the latest binaries, or using nvm
using apt will not work
what linux commad node js update?

When passing a variable through a constructor such as client through a command constructor, why does the variable in the constructor update when the one outside does?
@earnest phoenix https://www.ostechnix.com/install-node-js-linux/
check method 1, using nvm
@crimson vapor non-primitives such as arrays and objects are passed by reference not by copy
that make a lot more sense
does it do that for functions as well? like if you were to require a file and run one of the exports with client?
it should
ok
So passing client through a command by run() or this.client shouldn't effect the amount of ram used?
nope
control your caches
the single source of all discord.js memory issues is the caching it does
users, guilds, channels, members, presences, voice states, roles
all of those fill your memory up
hmmm very good code js sudo npm cache clean -f sudo npm install -g n sudo n stable
What is the best way to clear it?
alright thanks for your help
noooo
error
/home/dc/node_modules/mysql/lib/protocol/Parser.js:437
throw err; // Rethrow non-MySQL errors
^
TypeError: Cannot read property 'client' of undefined
at new MessageEmbed (/home/dc/node_modules/discord.js/src/structures/MessageEmbed.js:13:60)
at Query.<anonymous> (/home/dc/commands/help.js:61:21)
at Query.<anonymous> (/home/dc/node_modules/mysql/lib/Connection.js:526:10)
at Query._callback (/home/dc/node_modules/mysql/lib/Connection.js:488:16)
at Query.Sequence.end (/home/dc/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
at Query._handleFinalResultPacket (/home/dc/node_modules/mysql/lib/protocol/sequences/Query.js:149:8)
at Query.EofPacket (/home/dc/node_modules/mysql/lib/protocol/sequences/Query.js:133:8)
at Protocol._parsePacket (/home/dc/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/home/dc/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/home/dc/node_modules/mysql/lib/protocol/Parser.js:43:10)
root@otamoon:/home/dc#
:'((
please help all command error ```js
(node:22522) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'client' of undefined
at new MessageEmbed (/home/dc/node_modules/discord.js/src/structures/MessageEmbed.js:13:60)
at Query.<anonymous> (/home/dc/commands/fox.js:33:26)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:22522) 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:22522) [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.
try this console.log(process.version) in the beginning of your code
in your main file
what does it show?
nothing
it should show something before the error
try with eval command
root@otamoon:/home/dc# node index.js
v12.16.1
ok so im trying to increment a number and you might be thinking its pretty simple right?
if (page !== max) {
await m.edit({ embed: pages[page] });
awaitReactions(msg, m, options, filter);
}```
pages is basically something like
```js
const pages = {
1: {title: "first page", description: "first page!"},
2: {title: "second?", description: "thats right boi"}
}```
and page is the number of the current page its on (this is for a help command btw)
if i try to put `page++` anywhere it doesnt make the other functions run
oof
if u need more stuff from me ill send it
the awaitReactions function just runs it over again
root@otamoon:/home/dc# npm ls discord.js ota-chan@1.0.0 /home/dc └── discord.js@11.5.1
that is RichEmbed on v11.5
v11 doesnt have MessageEmbed, use ^
shit
also newest version is 12.1.1
npm update will not work
o shit
npm i discord.js
npm wont let you update major versions
u dont have to use stable
you need to uninstall and reinstall, or install with a forced version discord.js@12.1.1
#memes-and-media for turkish
but pay attention, discord.js v12 is VERY different from v11
you need to fully rewrite your bot to use v12, if you want to upgrade
not exactly
does it eat less ram
just a lot
also can u answer my qustion
whyyy?
/home/dc/index.js:31
let guildArray = bot.guilds.array();
^
TypeError: bot.guilds.array is not a function
guilds.cache
like
also, why not use message.awaitReactions?
instead of calling the function directly
hold up
async function awaitReactions(msg, m, options, filter) {
const { min, max, page, limit } = options;
m.awaitReactions(filter, { max: 1, time: limit, errors: ['time'] }).then(async c => {
const r = c.first();
if (r.emoji.name === '⏩') {
await removeReaction(m, msg, '⏩');
if (page !== max) {
await m.edit({ embed: pages[page] });
awaitReactions(msg, m, options, filter);
}
}
else if (r.emoji.name === '🗑') {
await m.delete();
return;
}
else {
awaitReactions(msg, m, options, filter);
}
}).catch(e => console.log(e));
}
intendation is kinda hecky
and this is options ```js
let options = {
limit: 15 * 1000,
min: 1,
max: 4,
page: 1
}
@quartz kindle
const gayUser = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));``` cache???
guild.members.cache
client.user.setActivity(`Serving ${client.guilds.size} servers`);
umm this is the command that i give for my activity but it comes out as Serving Undefined servers
what is your djs version
show error
it doesn't give error
client.guilds.cache.size? idk I've not used v12
client.guilds.cache.size maybe then?
it worked!!
Good :)
Yea, no problem.
i shouldn't update to this version lol
I've not yet updated :P
Neither have I
ok thanks tim
does anyone know how to add a video to an embed?
i tried with webhooks but that didn't work
even tho in the docs they say you can and that it works
ping me if you have an answer
you cant
but mee6 did it somehow
probably it's a website video's preview
like when you put a youtube link in the chat
^
wish discord allowed bots to use goLive
wish discord would just press alt + f14
f14
f35
@knotty steeple if you destructure options into individual variables, they will be copies, not references, so if you do page++ it wont affect the page in options
wait what
suddenly...
process.env.MONGODB is undefined
Well..
It should be working, as token was working out for you
Ehh..
I'm not sure.
````${message.guild.owner}``` it comes out as null uwu
hol up le me try
@slender wagon that means the owner is not cached
``` .addField("Owner", ${message.guild.cache.owner})
^
TypeError: Cannot read property 'owner' of undefined```
how can i fix that
idk how this v12 works
Read docs
yep i'm there too
oh xD
@slender wagon if the owner is not cached, you need to cache it
await client.users.fetch(guild.ownerID)
then you can do guild.owner
OHH okay!
you might need to also do await guild.members.fetch(ownerID)
Works now, right? @earnest phoenix
ohh alright
Good.
i need help im trying to host a python discord bot with heroku it gived me errors
what error
get embed from a message and send it to somewhere else
d.js v11.5
wdym
like see https://discordapp.com/channels/264445053596991498/661244601910296576/661313029698355233 has embed
I wanna copy that embed as that is to somewhere else
@gentle arrow hmmm well it looks like the error looks like you didn't use the git commands to get the bot up and running, also did you put all of the imports that you installed via pip into the requirements.txt?
how did you get the files? @gentle arrow
How can I make the bot send a message to a channel when it crashed
aka is there an oncrash event
LOL
thats impossible
the only way to do that would be to use another bot to monitor your main bot
i found a good way
L
client.channels.get('694728750197112932').send('P.A.E.T. has hit an error!: ' + error);
});
process.on('beforeExit', function (error) {
client.channels.get('694728750197112932').send('P.A.E.T. has hit an error!: ' + error);
});
idk but it works
for most of my errors
that will not work for all errors, but it may work for some
wouldnt it be easier to use a webhook manager
because then if your bot goes offline you can send to a channel the error
I'd make an "online monitor" program in go to check the status of my bot and if the process exits with a non 0 exit code then, with a webhook, I send a message to a channel in my server
how is this picture added?
Idk, maybe for certified bots?
its a banner for certified bots yes
how do we get certified
what kind of mail
- you need to have a bot submitted and approved & follow certification requirements
It isnt email?
No
You can send a real letter to them with the application
And you get it sent back, and might be lucky and receive socks back :P
You can send your application to:
Certification Applications
Dbots B.V.
Weesperplein 4B, 5th Floor
1018 XA Amsterdam
Netherlands
is there a way to write something in the user's text box? like suggest a command?
text box where
the text box in which we write to send a message
a clickable text that suggests a command for the user and write the command here:
you cant put anything in the box
All you can do is type {prefix}suggest <suggestion> and the bot posts it to a channel
¯\_(ツ)_/¯
does ```js
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
how can I get my mongodb npm package version?
Look in package.json?
I mean how I can get it with code
Um it's a json file so
@barren swallow what
@summer torrent dunno about a property but you would do it with a console command
I know it. I want to get it for my versions command.
require('../package.json').dependencies.mongodb``` worked
👍
ty titan for idea
how do you enable that thing that warns you leaving the page if there might be unsaved changes
also check https://stackoverflow.com/questions/7317273/warn-user-before-leaving-web-page-with-unsaved-changes
iirc there's a built in way to do it not just in javascript
Discord.js
Why do I get the error Cannot send an empty message when checking the name/ID of a custom emoji in an await reactions function? It works perfectly fine with default Discord emojis, just not custom ones.
show code
let r = [
"this is just so that r[1] actually shows a 1...",
"\u0031\u20E3", // 1
"\u0032\u20E3", // 2
"\u0033\u20E3", // 3
"\u0034\u20E3", // 4
"\u0035\u20E3", // 5
"\u0036\u20E3", // 6
"\u0037\u20E3", // 7
"\u0038\u20E3", // 8
"\u0039\u20E3", // 9
":no:670828327518339097", // No / 10
":yes:670828144168796172", // Yes / 11
":err:671011561417998368" // Error / 12
];
let filter;
filter = (reaction, user) => {
return ([r[1], r[2], r[3], r[10]].includes(reaction.emoji.name) && user.id === message.author.id);
};
msg.react(r[1]).then(() =>
msg.react(r[2]).then(() =>
msg.react(r[3]).then(() =>
msg.react(r[10])).then(() => {
msg.awaitReactions(filter, {
max: 1,
time: 60000,
errors: ["time"]
}).then(async collected => {
const reaction = collected.first();
if (reaction.emoji.name === r[1]) {
// Do something.
} else if (reaction.emoji.name === r[2]) {
// Do something else.
} else if (reaction.emoji.name === r[3]) {
// Do something else again.
} else if (reaction.emoji.id === "670828327518339097") {
// This doesn't work when trying to do something.
// I've tried:
// reaction.emoji.name === "no"
// reaction.emoji.name === r[10]
}
})
})))
msg is the message sent by the bot.
msg.react(r[1]).then(() =>
msg.react(r[2]).then(() =>
msg.react(r[3]).then(() =>
what the fuck is this
Excuse me?
Because another developer used that instead of await, I just transferred some of the code to a new command file.
where are you even trying to send the message?
The message sends, but when I click the reaction, I get the error Cannot send an empty message, when the output doesn't even send a message. I can do the same function with a Discord emoji, it's just the custom emoji that doesn't work for some reason and that's the error it gives me.
can you even msg.react(':err:671011561417998368')
dont you gotta fetch the emoji ?
wait no
does anyone know about the different types of serverQueue.songs. example serverQueue.songs.url
@earnest phoenix 🤔 what?
Okay, I have an array of emojis. It has numbers 1-9 and three custom emojis. All emojis are added to the message fine. When using the Discord emojis, the functions work fine. But when trying to click a custom emote to preform the same function, I get the Cannot send an empty message error.
console.log() it
^
Log what, exactly?
what you're trying to send
} else if (reaction.emoji.id === "670828327518339097") {
// This doesn't work when trying to do something.
// I've tried:
// reaction.emoji.name === "no"
// reaction.emoji.name === r[10]
}```
what exactly are you doing in this block
separate server ids with , (comma)
ok
example 264445053596991498, 275047183055847439
console.log() it and see which properties it has
@earnest phoenix serverQueue is an object created by yo, you must know each property
^

that's what happens when you don't acually know what you're doing and you're just following tutorials
send your code
and I'll tell you the properties
console.log(serverQueue.songs[0])
or do that lol
not work @summer torrent
when you're doing serverQueue.push you're pusing an object into it
...

do you know what you're doing?
I've seen that var naming somewhere else
you're following plexi dev's tutorial aren't you?
what you're trying to send
@summer torrent
what exactly are you doing in this block
@knotty steeple
I'm having the bot edit the message that the reactions are on. When I use, for example, 1️⃣ as the reaction that will trigger the edit message function, it works. But when using the custom emoji, it gives me theCannot send an empty messageerror.
yep but i cant get the video's author for some reason
Oh dang, pings.
no tutorial
wdym
just pure docs
there's no way
if you don't know how to get those props
send your code and I'll guide you
no i do but some dont work
@earnest phoenix are the server(s) on https://top.gg/servers ?
which one
the file you're working on
Using
as the example for the custom emoji, this should work, correct?
if (reaction.emoji.name === "zoomeyes") {
// Do something.
}
where you have serverQueue
Or should this work?
if (reaction.emoji.id === "390046883281633290") { // ZoomEyes ID
// Do something.
}

k one sec
const discord = require('discord.js');
module.exports = {
name: "np",
description: "Show the music now playing.",
execute(message) {
const serverQueue = message.client.queue.get(message.guild.id);
const vurl = serverQueue.songs[0].url;
const vidid = vurl.split('v=')[1];
const secondsToHms = d => {
d = Number(d);
var h = Math.floor(d / 3600);
var m = Math.floor((d % 3600) / 60);
var s = Math.floor((d % 3600) % 60);
var hDisplay = h > 0 ? h + (h == 1 ? " hour, " : " hours, ") : "";
var mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes, ") : "";
var sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : "";
return hDisplay + mDisplay + sDisplay;
};
if (!serverQueue) return message.reply("There is nothing playing.").catch(console.error);
else{
let embed = new discord.MessageEmbed()
.setColor('RANDOM')
.addField(`Now playing:`,`**${serverQueue.songs[0].title}**`)
.setThumbnail(`https://img.youtube.com/vi/${vidid}/maxresdefault.jpg`)
.addField("Duration:",secondsToHms(serverQueue.songs[0].duration))
.setTimestamp()
return message.reply(embed)
.catch(console.error);
}}
};
where did you define client.queue
send play.js with https://hasteb.in
add author: songInfo.player_response.videoDetails.author to song obj
hmmm k
song = {
title: songInfo.title,
url: songInfo.video_url,
duration: songInfo.length_seconds,
vidid: songInfo.video_id
};
the object you're pushing is this, as you can see, you never added an author property, add it as Titan said
hmmm i tried author before author: songInfo.author but it dint work
ofc
author: songInfo.player_response.videoDetails.author i will try this
you never added it to the obj thats why
that would've saved this time
add it to both https://titandev.is-inside.me/0f72lTBR.png
^
...
perfection would be only using one
Debugging node applications on Cloud9 is easy because the functionality is built directly into the IDE. Using this feature, you can step over, step into, and step out of your code as you debug it.
watch that
and learn to debug
if you knew this before you could've saved us this short but tedious talk
oof i never knew about this
btw is there an windows ver?
hmmm 100% vs code will have it
...
dude
to debug
you can literally console.log any object and it'll log the object and it's properties
just try it
lemme show you what I mean
as long as you catch everything the correct way, debugging should be relatively easy
yeah
k
I console log every other line and see which line is causing the issue by the amount of console logs there are
recorder?
rip
wait whats the function to add stuff to an object
must be too big
wdym add stuff to an object
^
how do you make money in a econemy bot seperate for each person
maybe like js obj = { var = 1 }; obj.vari = 2; console.log(obj) -> { var: 1, vari: 2};
makes sense
well i tried doing that anyway cuz the key is a number
I forgot that you could to that tbh

let obj = {};
obj['whoami'] = "you're gay";
console.log(obj); // { whoami: "you're gay" }
do you mean js obj.1 = 2
or
obj['1'] = 1```
or ```js
obj.x = 1```
that way you can use user input to add values
the first one isnt valid
^
I know, im trying to clarify
yes
I wish it worked tbh
you can name 'em '1' but not 1
ye ik
n o
o k
I dont think so
are you sure
ummm
thats completely valid btw
that shouldnt work I thought
and you access it the same way
I literally have that written in my example code
well
had
bc I made some debugging examples for atom-dragon
also the example u put here
maybe like
js obj = { var = 1 }; obj.vari = 2; console.log(obj) -> { var: 1, vari: 2};
isnt valid
it turns it into a string
thats valid
it isn't
yea
shit u right
you don't assign values using =
you cant use =
you use :
look calm down I low IQ
it's big brain time
let obj = {
'not': 'anything'
};
obj[1] = 'test';
console.log(obj);```
`{ '1': 'test', not: 'anything' }`
so it turns the 1 into a string there
yea because js
not a string btw
wait srsly
huh?????
that shouldn't work
{ '2': 'test2', var: 'test1' }
If only you knew
bc x.var works
lemme shou you something guys
ive done js for too long to know its dumb
let obj;
obj.var = 'string?'
obj[1] = '1'
console.log(obj) -> { var: 'string?', '1': '1' }
well this turned into a learning course
but its fun
[] == ![];
Do that
js can interpret brainfuck cant it
nothing == !nothing
well, kinda
the process is this
[] == ![]
0 == !0 // false
0 == false
0 == 0 // true
0 == false -> true
this is what i needed btw
const pages = {}
for (var i = 0; i < violet.commands.categories.length; i++) {
const categories = violet.commands.categories;
const cmds = violet.commands.filter(c => c.settings.category === categories[i])
.map(c => `${c.info.name} - ${c.info.description}`)
pages[i] = {
title: `Command category: ${categories[i]}`,
description: cmds.join("\n")
}
}
but for the description it only does 1
bc 0 is false and 0 <= true < +∞
sorry, my mind is broken rn
xd
simplified to
change === to ==
fuck can you not
what
lul
my brain cant rn
can you help me with my problem
{ x / 0 < x <= 30}
honestly, give me a few mins to fix my brain
lol
its also supposed to show the ping command
for some reason it isnt
i logged cmds to check and it does include it
but when to actually include it in the function it just doesnt
alright I know
if commands is a map idk if it will work correctly
so, you need a way to join every command
const cmds = violet.commands.filter(c => c.settings.category === categories[i]).map(c => `${c.info.name} - ${c.info.description}`)```
this is what cmds is btw
alr
it does filter to find commands in a specific category then maps it out
when i send the embed i just join it
or is it just the way im actually mapping it
are you getting any errors?
what does cmds log?
ping - See how long it takes for me to respond.
help - Shows all the commands that I have.
what its supposed to be
does it log as an array or an object? or wut?
its that
if its a string then you dont need to join and you would get an error
would it be breaking Discords ToS if i made a command that allowed people in servers with the admin permission to send out an announcement to all the server members via DM?
Yup
kinda
It's a mass DM
ok thx
yes
oh YES
mass dm bad
then how do i send it
just send cmds
i cant just put the variable in the description like that cuz its an array
its just ping command?
banana
fuck my name looks peasant like
lmao
back
Why this is not a thing anymore..
client.on("guildCreate", guild => {
let defaultChannel = "";
guild.channels.forEach((channel) =>{
if(channel.type === "text" && defaultChannel ==""){
if(channel.permissionFor(guild.me).has("SEND_MESSAGES")) {
defaultChannel = channel;
}
}
})
This sucks.... can someone help me?
https://mineko.is-inside.me/WpUTZzsw.png
what is not a thing anymore
Why this is not a thing anymore..
client.on("guildCreate", guild => { let defaultChannel = ""; guild.channels.forEach((channel) =>{ if(channel.type === "text" && defaultChannel ==""){ if(channel.permissionFor(guild.me).has("SEND_MESSAGES")) { defaultChannel = channel; } } })
@peak dirge Cuz It's spam I think...
I'm on glitch
well that explains a lot
TypeError: guild.channels.forEach is not a function
whereas it has the same issues instaling everything else as well
https://mineko.is-inside.me/lYm0DPYv.png
u just updated right
They removed it, no?
they didn't remove it
I am just trying to find first text channel that my bot can send message about commands etc.
@peak dirge console.log(guild) and see what you get
you shouldn't do that
no one likes bots that do such thing
it's spammy and unnecessary
Imagine you add a bot with, for some reason, admin perms and the first thing it fucking does it send a message in your #announcements channel
or even better
your #rules-and-info channel
@peak dirge forEach is not a method on the manager. You must call it on the collection (.cache)
im pretty sure it resets every month
Help
@earnest phoenix data.lyrics is undefined
Also why join sync code with async?
because they don't know what they're doing
Makes sense.
Lol xd I was on the wrong channel the entire time?!?!?!
Hi, so I managed to get my output on heroku to work. But the thing is that my bot isn't running.
I checked on the terminal by running the bot and It shows that I dont have errors.
Not sure
And yeah, discord is slow.
Whenever I clicked deploy, it was installing the modules and stuff.
Discord API Outage
But the bot wasn't running.
client.shard.id dont work, as well as client.shard.broadcastEval('this.shard.id').then(result => console.log(result)), both returns undefined or null
(djs v12)
Guys, just to know, how many persons are against Discord Bot Maker ?
discordjs version?
@tight plinth 12.1.1
.cache then
it's members.cache.filter
message.guild.members.cache.filter...
@tight plinth

how would i log when a shard has connected


sadly ik only title url and duration
i need perfection
ok then