#development
1 messages · Page 1210 of 1
so the user object is how discord.js represents a user
the object contains properties such as name, avatar, etc, and contain instructions for how to send them a message
in order to obtain a user object you can
- get it from the user cache if it exists:
client.users.cache.get(user id here) - fetch it from discord:
await client.users.fetch(user id here)
i thought this would be easy, but now im 2nd guessing
When you know classes you'll know objects
yes
so in your code, you need to use let user = await client.users.fetch(id here)
its like i stole their ID card irl, i feel like a villain
so is that making the thing go through for the command?
hmm?
idk-
Do i put these in the same lines, and just add ('message')
Can anyone help me? (Glitch)
Do i put these in the same lines, and just add
('message')
CMON
how about you show some code
Tim, can you help me?
try running enable-pnpm
Not working
[Union[Role, Member], PermissionOverwrite] please help how to use it
in order to obtain a user object you can
- get it from the user cache if it exists:
client.users.cache.get(user id here)- fetch it from discord:
await client.users.fetch(user id here)
I did all of this with user id, what do i do now, and how do i send a message
Use type annotations..?
Those literally just point at what an argument/variable is supposed to be
"Union" is "either"
hm
Aka Role or Member
so should i type role id or role name
Not sure why there's a list of that and PermissionOverwrite
What are you trying to do?
lock and unlock the channel
@earnest phoenix those were either one or the other, not both
eitherway you have to show your code, otherwise i have no idea what you're trying to do
yea
Eh...
Ah
You can technically go the fuck-all way and create a discord.Object with id=role_id
any solution @slender thistle
eitherway you have to show your code, otherwise i have no idea what you're trying to do
I'm trying to send a message to a user
from my bot
then show your code
You can technically go the fuck-all way and create a discord.Object with id=role_id
@slender thistle RIP
ohk
Where the key is an object with .id property and the value is a PermissionOverwrite object
aye np
Should I censor my friends user ID? I feel like i need to censor it
not really
@quartz kindle
ids are strings, not numbers
thought u ment user ids ;-;
When i copy a user ID it number
"673273042399415137" is a string (more specifically a snowflake)
673273042399415137 is a number, one too big for JS to handle
Yeah, thats how i thought about it when he said it
second, when do you want to send the message to this user?
because your code right now makes no sense, you're trying to get a user when the bot didnt even login yet
The user i logged in ;-;
it needs to be in a message event or a ready event
the client isnt logged in when you're fetching
Yayyy
So? uhh, what do i do
you're trying to do things blindly, without understanding how it works. its gonna be very hard for you if you keep doing it that way
i'd suggest you learn some basic javascript
@quartz kindle yknow lua
I did
console.log() and the other things including console.log, thats it from the place i learned'
Its literally like python and js had a kid
never used it
Lua is pretty underrated
I need some help on that
embed.add_field(name=f'Roles ({len(roles)})', value=" ".join([role.mention for role in roles]))
I want to list the Roles a member has in an embed message, although it looks like this
How can i make a filter for the everyone role? so it will only show the other 2 for example
If statement?
Append if role == role.guild.default_role else role.name at the end of the list comp
Are you using the api.
yes
So basically, my bot bypassed the bot check twice by now and I still don't know how or why. I use - if(message.author.bot) return as bot check, maybe I've done it wrong?
Yayyy
@slate oyster enjoy the +50d queue of verification
Can anyone help me with something i am trying to figure out, im writing a discord js bot and i have set up a server join message so whenever it joins a server it will send a helpful embed but im not sure how to determine which channel to send the embed into. Right now it just finds the first channel it has permission to send messages in but i feel like that is not the best way to do it

@ionic dawn Will do
client.on("guildCreate", guild => {
let defaultChannel = "";
guild.channels.forEach((channel) => {
if(channel.type == "text" && defaultChannel == "") {
if(channel.permissionsFor(guild.me).has("SEND_MESSAGES")) {
defaultChannel = channel;
}
}
})
defaultChannel.send(BotJoinMessage)
});
this is how i am doing it atm
@ionic dawn Anyways, those 50d aren't as bad as another thing I'm waiting out
So basically, my bot bypassed the bot check twice by now and I still don't know how or why. I use -
if(message.author.bot) returnas bot check, maybe I've done it wrong?
@tidal marlin no, that is generally the right way to do it.
Hey, this is all the keys that the TEST webhoost post give me : _readableState,readable,_events,_eventsCount,_maxListeners,socket,connection,httpVersionMajor,httpVersionMinor,httpVersion,complete,headers,rawHeaders,trailers,rawTrailers,aborted,upgrade,url,method,statusCode,statusMessage,client,_cons. Where is the user value stored ?
if(oldMember.user.bot) return;```
```UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'bot' of undefined
at module.exports (C:\Users\Utilisateur\Desktop\Détente [FR]\bot juzoo bot v12\events\voiceStateUpdate.js:7:21)```
@slate oyster whats that
if(oldMember.user.bot) return;```
```UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'bot' of undefined
at module.exports (C:\Users\Utilisateur\Desktop\Détente [FR]\bot juzoo bot v12\events\voiceStateUpdate.js:7:21)```
@wicked pivot wat
Where the fuck is the property for body
Hmm, maybe the order is somehow twisted when using the event. It firstly checks for bot not async then later I use async await to get PFX for certain server so that it would only check if person typed that and the bot appears to typed the PFX @misty sigil
but it really shouldn't happen cause it should be stopped before it reached that
What does your code look like
@solemn merlin where did you get that from
(First of all, I'm not node developper)
http.createServer(function(request, response) {
if(request.headers['authorization']==process.env.apiKey){
Do some noob shit things
}
}
Someone got an idea ?
(this is not really random but u get it)
yea
random doesn't exist
is it possible to make the automatically created role for the bot be at a specific position in the role list?
but like a number from between 2 numbers
you're trying to do things blindly, without understanding how it works. its gonna be very hard for you if you keep doing it that way
Well teach me ;-;
rxp = randint(10,20)
^
TabError: inconsistent use of tabs and spaces in indentation
wtf
rxp reminds me of assembly
is that... basic java
Exactly what the error says
You used tab or space which wasn't used in your code before to indent lines
like for no f***ing reaosn
It matters which one you use in Python
@solemn merlin the request that comes from httpServer is a readable stream
ooooooooooooooh
in order to read it you have to listen to the data event
like this
(request,response) => {
let data = "";
request.on("data", d => data += d.toString());
request.on("end", () => console.log(data))
}
const server = http.createServer((req, res) => {
let data=""
req.on('data', chunk => {
data+=chunk.toString();
})
req.on('end', () => {
fs.appendFile('console.txt',data,function (err){if(err){throw err;}});
})
})
}).listen(8443);
``` like this @quartz kindle ?
(And ty)
learn base JS first
@misty sigil
Where
should work, try it
Okay, just (I'm a total noob in js, I just need to send a message to my Discord server on vote), how to I send an answer (like Hello World) using this system ?
@solemn merlin i'm sure there's a bot called DBL vote and it can do that
you're not sending an answer back to dbl in this case
you want to redirect an answer to discord
so you just add your bot logic inside the end event
yes but my I use it also for another things
like client.users.fetch(data.user)
let data=""
req.on('data', chunk => {
data+=chunk.toString();
})
req.on('end', () => {
fs.appendFile('console.txt',data,function (err){if(err){throw err;}});
res.writeHead(200, {'Content-Type': 'text/html','connected':false});
res.end("<p>Acces refuse</p>") ;
})
})
}).listen(8443);```
you probably need to json.parse it
Yep, In fact I send it to a channel (using my website) then my bot reads this cannel
channel *
Yeeehh that's working !
Ty !
does anyone know if its possible to make the automatically created role for the bot be at a specific position in the role list?
does anyone know if its possible to make the automatically created role for the bot be at a specific position in the role list?
@charred geyser toggle this in server settings -> roles -> the role you want
@viral spade #development message
oh. i have tried exactly that with .destroy() and .end(). but doesnt help
@charred geyser toggle this in server settings -> roles -> the role you want
@steel tapir what i mean is when my bot joins a server a role is created for the bot, as iis for any bot. But the role that is created is at the bottom of the role list and therefore lacks permissions over other roles.
async def purge(ctx, amount : int):
await ctx.channel.purge(limit = amount)
await ctx.send("Purged {amount} messages from this channel.)
Can I make it delete the "ctx.send" after a short time? I don't want it to be left permanently - just as a "response" for 5 seconds for example
@acoustic bridge .send(...) has a delete_after parameter.
Give it a number in seconds.
Hello can you help me?
I am making a captcha system and wrote this:
module.exports = async (client, member) => {
const db = require("quick.db");
if (member.user.bot) return;
let number = randomInteger(100000, 1000000);
let verifyChannel = member.guild.channels.cache.find(ch => ch.id === "750651944237793330");
await db.set(`verification.${member.user.id}`, number);
const dm = new Discord.MessageEmbed()
.setColor(0x7289DA)
.setTitle(`Welcome to ${member.guild.name}!`)
.setDescription("Hello! Before you get started, I just want you to verify yourself first.")
.addField("Put your code into the channel.", `**This is your code:** ${code}`)
await member.send(dm).catch(() => {
verifyChannel.send(`<@!${member.user.id}> Hey, I guess your Dms are locked. How about unlock it first and type \`resend\` here.`)
.then(i => i.delete({timeout: 10000}));
})
}
function randomInteger(min, max) {
min = Math.cell(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}```
And this:
const db = require("quick.db");
let codeExist = db.get(`verification.${member.user.id}`);
if (codeExist) db.delete(`verification.${member.user.id}`);
}```
yes?
And this:
if (message.content.startsWith("resend")) {
let code = db.get(`verification.${message.author.id}`);
await message.delete();
const dm = new Discord.MessageEmbed()
.setColor(0x7289DA)
.setTitle(`Welcome to ${message.guild.name}!`)
.setDescription("Hello! Before you get started, I just want you to verify yourself first.")
.addField("Put your code into the channel.", `**This is your code:** ${code}`)
await message.author.send(dm).catch(() => {
return message.reply("Your DM is still locked! Unlock your DMs first.")
.then(i => i.delete({timeout: 10000}));
})
return message.reply("Check your DM,").then(i => i.delete({timeout: 10000}));
}
if (!client.fonfig.owners.includes(message.author.id)) {{
if (!message.author.bot) {
let verify = parseInt(message.content)
let code = db.get(`verification.${message.author.id}`);
if (verify !== code) {
message.delete()
return message.reply("Are you sure that is the code that you typing it?").then(i => i.delete({timeout:10000}));
}
if (verify === code) {
message.delete();
db.delete(`verification.${message.author.id}`);
message.reply("You are not a robot! Please wait, 5 seconds okay?").then(i => i.delete({timeout: 7500}));
setTimeout(function() {
message.member.roles.add("750426065922424912")
}, 5000)
}
} }}
}```
in index.js
I run it but this error pops up:
at wrapSafe (internal/modules/cjs/loader.js:1053:16)
at Module._compile (internal/modules/cjs/loader.js:1101:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47```
How can I fix it?
make it an async function
why are you using async/await without knowing how it works
^ why are you making a bot without basic js knowledge
for (const guild of client.guilds.cache) {
if (guild.members.cache.get(newUser.id)) { inGuilds.push(guild.id) }```
I need some help
i dont understand why it isnt getting the members
client is defined correctly
client.guilds.cache.values()
cache is a collection and iterating over a collection returns [key, value]
so you need to iterate over the Collection.values()
oh okay
thank you
but now it cannot find the id values
client.on('userUpdate', async (oldUser, newUser) => {
const inGuilds = [];
for (const guild of client.guilds.cache.values()) {
if (guild.members.cache.get(newUser.id)) { inGuilds.push(guild.id) }
}
const guild = await getGuild(client.guilds.cache.get(inGuilds));```
this is what i am doing.
trying to get the guild from a user object
(Not a member object a User Object)
i know
Is the user cached within the guild?
im trying to get an array of all the guilds that the member shares with Duke
the guild id's to be more specific
If you're using gateway intents and don't have GUILD_PRESENCES then members will not be cached on load
only the ClientUser will appear in guilds
you need to either cache all members in all guilds (djs will heavily eat your ram) or check with fetch() if they exist in the guild (which is heavy on ratelimits)
so there's no reliable way to check for mutual guilds
the only reliable way i can think of is to go through oauth2 to get user's guilds and then see if your bot is in any of the guilds that the user is in
that would work but oauth is a pain. Probably what could be less painful is to store related data in a persistent cache
do you supply gateway intents when you are constructing a new Client

I have never worked with discord.js partials so that's another can of worms I don't understand so idk.
How many guild members are in the guilds your client is in on load? > 1?
i have 113 guilds right now
and the amount of members on them
half of them have over 100k members :/
not the guild.memberCount
The guild.members.cache.size
ill check it out
oh wait. I think I see an issue with your code. inGuilds is an Array<string>
and you supply client.guilds.cache.get(inGuilds)
which only accepts a string
probably something like
await Promise.all(inGuilds.map(id => getGuild(client.guilds.cache.get(id)))
then the return value of that Promise.all will be an Array<T>
Where T is the return value of getGuild
but you already get the guild from the client guild cache so I'm not sure what the getGuild function does
euhhhh
getGuild gets it from the database
and what should i replace with await Promise.all(inGuilds.map(id => getGuild(client.guilds.cache.get(id)))
(Sorry im not good at understanding stuff)
const guild = ...
should be const guilds = ^
guilds would be the Array<T>
not literally ^ btw
wait euhhh
i cant replace const guild = await getGuild()
that gets the guild from the ID and checks the database to see if something is enabled
but im trying to get the id's so i can check
if that makes sense
It really does not. The point was to get all of the guilds the user is in, correct?
correct
and then log them into an array
const inGuilds = [];
for (const guilds of client.guilds.cache.values()) {
if (guild.members.cache.get(newUser.id)) { inGuilds.push(guild.id) }
}```
this is the only part that needs help
Your code, if it even worked, is getting a single Guild from the database. Which defeats the purpose of getting all of the guilds a user is in
replace
const guild = ... with const guilds = await Promise.all(inGuilds.map(id => getGuild(client.guilds.cache.get(id)))
then you can for (const guild of guilds) {} and put your code that depends on individual guilds inside of that for of
you want me to replace this?
yes
Then I cannot help you any further. I gave you a solution
its my database thing not the actual guild getter
I perfectly understood getGuild is getting data from the database
hey so im pretty new to bot making and ive run into a problem with the jda builder... its deprecated
import net.dv8tion.jda.api.JDABuilder; <-- says this is deprecated
it returns a Promise<T>
inGuilds.map(id => ...) uses your getGuild function and if the expected argument_0 in getGuild is a Guild then it passes getGuild a valid Guild and the return value of the inGuilds.map would be Array<Promise<T>>
Promise.all waits for all Promises to resolve and returns the values of the supplied Array of Promises
which would turn the return value into Array<T>
you can then for of that resolved Array of Guilds from the database and declare individual items of the array to be casted to const guild and put your guild dependent code inside of that for loop and it'll be like nothing changed
does anyone know the d#+ lib for C# i need help with a command not doing what i want
C# bot / Asp.net Webhook for voting
Controller:
[HttpPost("~/runwebhook")]
public ActionResult runwebhook([FromHeader]string Authorization, [FromBody]DBLVote vote)
{
var AuthKey = "";
if (Authorization != AuthKey)
return Forbid();
_logger.LogInformation($"{Authorization} Authorization Header");
_logger.LogInformation($"{vote.bot} {vote.user} {vote.type} {vote.isWeekend} {vote.query}");
return Ok();
}
DBLVote Object:
public class DBLVote
{
public string bot { get; set; }
public string user { get; set; }
public string type { get; set; }
public bool isWeekend { get; set; }
public string? query { get; set; }
}
Sorry wanted to place this here incase someone else looks for info on webhook vote posts for C# discord bot
do you have fetchAllMembers?
loop over?
that will only work with fetchAllMembers:true
can somone help me with d#+
you guys can deconstruct btw
@remote ivy remember how you told me to fix my problem with "Cannot send empty mesage"? I am getting the same error, except this time it's when I try to send an embed with a webhook:
return channel.send({embeds: [e]})
This worked fine before I updated to the latest version of discord.js ^
let guilds = [...client.guilds.cache.values()];
for (const guild of guilds) {
// put your code here
}
That is not related, Erwin
de structuring Collection.values() is useless since the return value already is an Array<V>
SRSLY
collection.values() returns an iterator, not an array
does anyone know c#
you can loop through it, ye, but a lot of methods are missing
ok. Iterable<T> is close enough and for of statements treat it as ArrayLike
but thank you for clarification
what do you need to know about C#?
hey so im pretty new to bot making and ive run into a problem with the jda builder... its deprecated in 4.2.0 and i dont know how to fix this
go for it
alright so I did this
Google clarified that so that's a mistake on my part but in Creepa's case, destructuring values would have been useless since it's used in a for of
it gives no errors, but euhm, it doesnt recognize when a user update happens in an allowed guild now :/
i see
You can also do for (let [key, value] of map) to iterate thorugh a map
can anyone give me some help with my discord js bot?
be more descriptive @charred geyser
so im running into a problem where the JDA builder is deprecated, im extremelly new to this so any help is appreciated
well i dont have an issue as such, what i want to do is create some commands that configure things like autorole and join/leave channel
but i'm not sure how to do that when dealing with multiple servers
ok so you completely removed the Promise.all I told you to add in.
underneath the first for of, you'd put that const guilds = await Promise.all(...
then right underneath that, do
for (const guild of guilds) {
}
and put the code like if (guilds.logging)
inside of the second for of statement and replace guilds to guild
since guilds is an Array
@sweet ruin i pretty need to make commands that configure things specifically to one server rather than globally across the whole bots config
when was JDA 4.2 released?
that's not the proper place to put it. That first for loop should be
for (const guild of client.guilds.cache.values()) {...
then const guilds needs to be underneath the first for statement
@charred geyser easiest way to do that is ```js
if (message.guild.id === ( "ID OF THE GUILD YOU WANT HERE" )) { YOUR CODE HERE } else {}
so like this?
something about that looks wrong
no lol
very wrong
@charred geyser easiest way to do that is ```js
if (message.guild.id === ( "ID OF THE GUILD YOU WANT HERE" )) { YOUR CODE HERE } else {}
@sweet ruin but how would i get the bot to store information that is configured using commands, like how MEE6 can be configured to give a specific role when joining. Where would this info be stored?
well if you are putting it for one server itself
just grab the role id
if it is custom
then you need a database
so like this @lament rock
do you know anyone that can help me set up a database and wallk me through shit/ help me when i get stuck?
@sweet ruin
No XD. One sec
wheres the best place to ask like really beginner questions? i just wanted to make a bot out of boredom and could use the help
you can ask here, but if you're really really beginner, we usually advise to learn some basic coding first
oh i know java and stuff, just setting up a bot
wheres the best place to ask like really beginner questions? i just wanted to make a bot out of boredom and could use the help
@forest phoenix stackoverflow/youtube
youtube guides are pretty helpful for basic command handlers and stuff
except when they're wrong or outdated lul
yeah ive been doing youtube videos up until i ran into problems with deprecated stuff
yeah
mostly problems with the JDABuilder
for (const guild of client.guilds.cache.values()) {
if (guild.members.cache.get(newUser.id) inGuilds.push(guild.id)
}
const guilds = await Promise.all(inGuilds.map(id => getGuild(client.guilds.cache.get(id))))
for (const guild of guilds) {
if (guild.logging) ...
}
can anyone help me set up a database for my bot
what kind of database
a simple mongo one would do fine for you
first you need to chose a database, there are dozens of them out there
popular ones include sqlite, mysql, postgresql, mongodb, rethinkdb, and many more
what should i look for when choosing?
They all are good at different things. Databases like Redis are super powerful for temporary storage for key value pairs but is not good for persistent data
im not stupid lol
anyone willing to help me with a d#+ command that i'm struggling with
so like this @lament rock?
@charred geyser any of those databases will work, the differences between them is what style they operate under. for example, sqlite and mysql are relational databases that use SQL to interact with it, which is like a whole new language for you to learn, but very powerful, flexible and works in many databases.
On the other hand, a database like Mongodb uses a document model that is not SQL based, so it has a different way of using
alg br ?
well considering im new to databases would Mongodb be best?
another difference is that most of these databases are fully featured servers as well, which run in a separate process and can be installed in any computer, except SQLite, which is unique because its the only one that is embedded inside your program
yes @sweet ruin
personally i like SQLite better because its simpler to use, requires very little resources and is more than good enough for discord bots
but many people here use and prefer mongodb, mysql or even postgre
i use mongo tbh
another thing is that each of those databases require a library to use them in your code
and sometimes this library does much more than only interact with the database
for example, sequelize and mongoose are not only drivers, they are ORMs which create another layer on top of the database in way that you dont even feel like you're using the database directly
if you plan to shard, you cannot use sqlite unless you have a database worker your shards connect to to query from.
So, using MySQL or MariaDB or some other DB which implements SQL or other NoSQL solutions are good
shard?
I thought sqlite imposes file locks.
So what happens when you write from multiple shards
learn something new every day
so which would be simplest
i dont think my bot is gonna be huge
i think im going for simplicity
if you're an absolute beginner, and dont feel like learning how to use a database directly, you can use an orm/framework
thank you for dealing with my stupidness @lament rock
for example, enmap or quick.db
quick.db is a simple framework built on top of sqlite which makes it as easy to use as a Map object in js, and it does all the database code for you behind the scenes
i dont think my bot is gonna be huge
@charred geyser That's what I thought aswell, and now I'm at ~650 servers - You'll be surprised
i know who you are 😄
👀
god damn, 2b2t players everywhere - but too much offtopic we should stop 😛
lmao
is ${member.guild.name}; for v12 is there supposed to be a .cache infront of name?
no
Not for name
kk thx people
You'll learn it
yes, you can store any data in that
so for example
if i were to make a command that when i say %door #channel it will set the channel to send join/leave messages to #channel
how would i store that
euh @lament rock.. it dont work. it again doesnt submit an error but it doesnt send an msg to the channel I specified when I change anything about my user :/
if my bot is in lots of servers
show code
it needs like a seperate configuration for each server
you create a configuration object for each guild
and store it using the guild id as the key
Could someone tell me how to make the bot command show on how many servers it is currently on?
ok that makes sense
the simplest form of storage is called a "key value" database, which is essentially what objects and Maps are in js
https://paste.mod.gg/fetotovugo.js @lament rock
something.set(key,value)
@earnest phoenix What library are you using?
quick.db uses sqlite in the background and offers a key value storage system on top of it, so basically you use it the same way
database.set(key, value) / database.get(key)
Eris @nimble kiln
👀 Ok sorry I'm out
lmao
also is there anything i can do to make my bot more likely to be verified?
apart from wait
still nothing @lament rock
Just don't do anything absurd with your user's data
Could someone tell me how to make the bot command show on how many servers it is currently on?
@earnest phoenix client#guilds#size
@earnest phoenix Actually, look here:
https://abal.moe/Eris/docs/Client
Maybe something like client.guilds.size or something?
Eris, a NodeJS Discord library
oh, flazepe wrote it 😄
i accidentally got temp banned from using the discord api the other day
it is supposed to be an array i thought
try using console.log to see where things break
idk if they check that
just don't do that, then
There is usually a client event to tell you when you're being rate limited and what bucket you're being rate limited in
so guilds gets the database file for the guild
just console.log everything
and so does guild
easy way to debug
so i have to create a dir for my database to run from
does that have to be linked to the bot at all or can that just be separately on my pc
MongoDB
ah
ah shit should i do quick.db?
but all i need inside of the get guild is all of the IDs of the guilds that Duke and the member Share
@lament rock
are you installing mongodb as a selfhosted, or using atlas?
ill do quick.db
mongodb has an online service called "atlas" which basically they give you something like 500mb of storage for free that you can connect to, without having to install it
yeah i saw that
getGuild accepts an Array of IDs?
but you dont need that with quick.db right?
no, quick.db uses sqlite
what is the eval for discord.js to delete a message with the messageID
i have no clue @lament rock
Well. It's your code so
i should probably go with quick.db
or use a paid database like me
what is the eval for discord.js to delete a message with the messageID
@indigo flax
You should probably try to grasp an idea of Object types and what types mean. TypeScript is a good way to figure that all out. TS is js compatible as well :)
ok
oh so quick.db is really different
i kinda understand now
i think ill use mongodb
so ive been working at this thing for like an hour and i cant find a fix for this deprecated JDABuilder. all im trying to do is launch the bot, and this is the only thing messing me up
@quartz kindle if i am using atlas do i create a cluster?
so far everything ive found online is outdated from 3.8 and import net.dv8tion.jda.api.JDABuilder; is deprecated. what was this replaced by in 4.2.0?
sexy Tim man UwU if i am using atlas do i create a cluster?
@charred geyser yes, or download mongodb community server to host on your machine
i created a cluster
and im just doing the stuff they tell me to
trying to connect to it
bruh
i think i have a database
yay
@quartz kindle are these things i will edit or should they not be there?
how do you get a certain role to be assigned to a constant with its id?
example:
const verifiedRole = client.roles.cache.get('ID')
``` would this work?
how do i also check if a member has a role?
whenever someone uses the ;stock command it doesnt reply and it says this in console (node:24) UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body embed.fields[0].value: Must be 1024 or fewer in length. at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:170:25) at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:24) 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: 105)
the command works in other servers tho
it also has worked before
your embed exceeds the allowed character limit
OH
try to add a field or even create a 2nd embed
lol
It's not your embed sticking out. But the field ( .addField () )
i easily fixed it by doing ;eval storage['750470743556620359'] = { nils: [] } in that server
i have this iframe here set to height: 100%. but how do i get it to work
because from the borders there, it ain't 100% high
maybe use min-height with 100vh? or lower
for xp in exp:
UnboundLocalError: local variable 'exp' referenced before assignment
i keep getting this error
guild_id = ctx.guild.id
author = ctx.author
user_id = {"_id": author_id}
if ctx.author == client.user:
return
if ctx.author.bot:
return
if(collection.count_documents({}) == 0):
user_info = {"_id": author_id, "GuildID": guild_id, "Level": 1, "XP": 0}
collection.insert_one(user_info)
if(collection.count_documents(user_id) == 0):
user_info = {"_id": author_id, "GuildID": guild_id, "Level": 1, "XP": 0}
collection.insert_one(user_info)
exp = collection.find(user_id)
for xp in exp:
cur_xp = xp["XP"]
new_xp = cur_xp + 1
collection.update_one({"_id": author_id}, {"$set":{"XP":new_xp}}, upsert=True)
#await ctx.channel.send("1 xp up")
lvl = collection.find(user_id)
for levl in lvl:
lvl_start = levl["Level"]
new_level = lvl_start + 1
if cur_xp >= round(5 * (lvl_start ** 4 / 5)):
collection.update_one({"_id": author_id}, {"$set":{"Level":new_level}}, upsert=True)
await ctx.channel.send(f"{author.name} has leveled up to {new_level}!")```
and its the mongo db stuff
sql.get(`SELECT * FROM blacklisted WHERE id = ? AND word = ?`, [MessageGuildId, MessageContent]).then(row => { if (MessageContent.toLowerCase().includes(row.word)) message.delete() })
This works but only if you say JUST the word. Let's say a blacklisted word is "test" and you type "testt", it won't do anything. But if you type the blacklisted word, it'll delete it. Anyone know what I can do?
This is for Discord.js.
@lament meteor yeah but i want it to be the height of the container it has, doing that works but it goes off page
because its got the container it should cut off
ah
lemme do some testing real quick
https://jsfiddle.net/cryh53L7/ @sick cloud i found this i presume its smthn similar to what u need?
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
it uses a flexbox
How can I do if someone mentions my bot, then he says something xDD
@earnest phoenix either regex or hard coded mention detector
boa @earnest phoenix
How can I do if someone mentions my bot, then he says something xDD
@earnest phoenix on mention?
Yep
on_mention
await send('YO SIMP')
@drifting wedge oxi tu é brasileiro
@lament meteor doesn't work

i did it like that basically
but nothing worked
<div class="container">
<div class="area">
<div class="toolbar mt-4">
content buttons
</div>
<hr />
<div class="mb-4">
<iframe id="pdf"></iframe>
</div>
</div>
</div>
body, html {
width: 100%;
height: 100%;
}
.area {
display: flex;
flex-direction: column;
height: 100%;
}
#pdf {
width: 100%;
flex: 1;
border: 1px solid #c0c0c0;
}
Hi, whats your error or what are you trying to do?
var numb = numb.toUpperCase
if (numb.includes('K' || 'M' || 'B')){
numb = numb.replace("K", "000");
numb = numb.replace("M", "000000");
numb = numb.replace("B", "000000000");
}
return numb
}```
err: numb.includes is not a function
help help help
at the top you defined numb to a function you should instead call the function with numb.toUpperCase()
@sick cloud -webkit-fill-available afaik
for height
I think the normal css value is fill-available
funtion lengthen(numb)
um ok
throw new _mongoose.Error.OverwriteModelError(name);
^
OverwriteModelError: Cannot overwrite `Guild` model once compiled.
anyone help me with this
im setting up a MongoDB database and this is the guild schema
const mongoose = require('mongoose');
const guildSchema = mongoose.Schema({
_id: mongoose.Schema.Types.ObjectId,
guildID: String,
guildName: String,
prefix: String
});
module.exports = mongoose.model('Guild', guildSchema, 'guilds');
guild collection already exists probably
im pretty certain it doesn't
oop
?
ill make that nicer to read hold on
just the first few lines
/Users/--/Documents/GitHub/MEE69-Development/node_modules/mongoose/lib/index.js:536
throw new _mongoose.Error.OverwriteModelError(name);
^
OverwriteModelError: Cannot overwrite `Guild` model once compiled.
at Mongoose.model (/Users/--/Documents/GitHub/MEE69-Development/node_modules/mongoose/lib/index.js:536:13)
at Object.<anonymous> (/Users/--/Documents/GitHub/MEE69-Development/models/guild.js:10:27)
at Module._compile (internal/modules/cjs/loader.js:1075:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1096:10)
at Module.load (internal/modules/cjs/loader.js:940:32)
at Function.Module._load (internal/modules/cjs/loader.js:781:14)
at Module.require (internal/modules/cjs/loader.js:964:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/Users/--/Documents/GitHub/MEE69-Development/events/guildCreate.js:2:15)
at Module._compile (internal/modules/cjs/loader.js:1075:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1096:10)
at Module.load (internal/modules/cjs/loader.js:940:32)
at Function.Module._load (internal/modules/cjs/loader.js:781:14)
at Module.require (internal/modules/cjs/loader.js:964:19)
at require (internal/modules/cjs/helpers.js:88:18)
oh
welp
thats what i get after running node bot.js
show line 10 of models/guild.js
const mongoose = require('mongoose');
const guildSchema = mongoose.Schema ({
_id: mongoose.Schema.Types.ObjectId(),
guildId: String,
GuildName: String,
prefix: {
default: '%',
type: String
}
})
module.exports = model('Guild', guildSchema, 'guilds');
this is the whole thing
where?
in ur database?
its already been compiled before, you’ve obviously done something
you’ve got collections in ur db
oh right
so when i made the database i had to create a collection
i need to name it something else
it seems like ur modelling it twice for some reason, thats what people on stackoverflow says anyways: https://stackoverflow.com/questions/19051041/cannot-overwrite-model-once-compiled-mongoose
yeah it was
i restarted and it was fine
still getting the OverwriteModelError: Cannot overwrite `Guild` model once compiled. thing
and u need to use the new keyword
new mongoose.Schema...
instead of
mongoose.Schema...
since its a class
like that?
yeah
still getting the same thing
this should be going into a collection called guilds right?
If I declare const Guild = message.guild.id and use the declared statement, I get an error. But if I just use message.guild.id, I don't. Anyone know what might be causing it?
const backwards = msg.createReactionCollector(backwardFilter, {setTimeout: 1000 });
why doesn't the time out work
i set it for 1 sec to try it
help
how to install canvacord
this.client.guilds.cache.filter(x=>x.id != "264445053596991498").sort(function(a, b){return b.memberCount ? b.memberCount : 0 - a.memberCount ? a.memberCount : 0}).map(x=>`${x.name} - ${x.memberCount} Members`).slice(0, 10).join("\n")```
Anyone knows an alternative to sort guilds from ascending to descending?
If b.memberCount ? b.memberCount : 0 - a.memberCount ? a.memberCount : 0 is supposed to sort the guilds by their member count, I recommend you replace that with b.memberCount - a.memberCount. You can then flip the order to switch between ascending and descending (a.memberCount - b.memberCount). The reason I recommend it is because it would do the same thing but be more concise and easy to read.
oh well i added ternary because of unavailable guilds
ill remove it
that was during v11
how to install canvacord
Apollo I'd consider either filtering out unavailable guilds in the .filter() method, or checking for unavailable guilds and returning -1 instead.
To put that in a statement
npm i --save canvacord @clever vector
npm install canvacord no work??
npm i --save canvacord@clever vector
you can always find the command to install on the npm page
<Collection>.sort((a, b) => {
if (b.available) {
return b.memberCount - a.memberCount; // ascending
}
return -1; // Indicates it was not found.
});```
You can read more on how they like to sort stuff in JS here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
lol
https://sourceb.in/7739e08bb6 it wont' remove reactions or console log end
does the other stuff fine
@heady fable Don't advertise please

oh, woops sorry,
~~bruh it's common sense ~~
https://sourceb.in/7739e08bb6 it wont' remove reactions or console log end
@stark abyss is the other stuff working, such as reacting and it editing the original message.
It's not removing reactions because you never tell it to. The only time you tell it to is in your end event, which is not working because it's nested in another event emitter
oh
So you should move your end event outside the forward event function block.
Also do you mind if I give feedback about some of your code
???
does someone know how to get the base emojis for those
- There's no need to re-create the client at the top of your file. It wouldn't be the same instance, so it wouldn't be useful in the first place. If you need the client, you could use
message.clientto get it (which is the actual client). - Are you sure you need to re-define
args? What are you doing with the currentargsparameter? What does that contain? - You don't need to create three separate reaction event collectors. You can have one, check if the emote is the specified emote of the three and the user ID is the same as the message author.
- Line 29 and 30 are not guaranteed to be run first, if you know async/await. If not, I recommend you search it up.
@fringe seal number emojis are actually two different characters so they don't escape properly
oh
i am learning slowly
@sudden geyser still gives me TypeError: msg.removeAll is not a function
use a bot like robo danny to view what you have to send or just go to the fileformat website, Afely
msg is a Message instance and has no removeAll method.
thanks
no problem
(node:26780) UnhandledPromiseRejectionWarning: TypeError: client.guilds.forEach is not a function
console.log("SERVERS:");
client.guilds.forEach((guild) => {
console.log(('-') + guild.name);
});
getting this error for this function
oh cache maybe
yeah
i forgot i updated to v12
If I declare const Guild = message.guild.id and use the declared statement, I get an error. But if I just use message.guild.id, I don't. Anyone know what might be causing it?
can anybody tell me how do i make a website for my bot
const user = message.mentions.users.first() || message.author;
if (!user) return message.channel.send("Please specify a user!")
const avatarEmbed = new Discord.MessageEmbed()
.setColor(0x333333)
.setAuthor(user.username)
.setImage(user.avatarURL);
message.channel.send(avatarEmbed);
supposed to return the mentioned users username + avatar
this is all i get
But use .displayAvatarURL() instead to support non-avatar users
html css and js trickery
@charred geyser
boom you got a website
how
Learning the basics of html and css
html css and js trickery
@earnest phoenix what the hell is this
Learning the basics of html and css
@ionic dawn i know html
i dont know css
if you want to do oauth logins or displaying bot stats, you're going to need a fuck ton more
ok
you can't have bot stats without backend
which is very likely out of their scope
I supposed he have a bot
i have a bot
So he know node
So he know node
@ionic dawn yep
Theres your backend
i use vs code
No.. I mean
visual studio code
You need node to get bot info
No.. I mean
@ionic dawn i know what you mean
You need node to get bot info
@ionic dawn yes i know
https://github.com/kamranahmedse/developer-roadmap i suggest checking this out regardless, has all of the concepts you should learn for making a secure website
Running on the back of the websitep
thanks @ionic dawn 🥰


yay it works once more!
im upgrading my bot from v11 to v12 and a few things are annoying but its ok
You can define the avatar format
I think if you dont define it is the base one, but you can specify to be png or jpg, useful if you doing anything with canvas
its ok
im working on the more important commands of my bot lol
if there is an issue in the future with that i will address it but i dont wanna spend too much time on it

Does anyone know what dependabot does, got an email from GitHub about it
P
Does anyone know what dependabot does, got an email from GitHub about it
@karmic compass it checks your dependencies for vunerabilities and tells you what you need to update and stuff
. P yummy
internal server error
aka
discord broke
or you're doing smth wrong
idk
one of the two
I bet on discord breaking
what happens if I JSON.stringify a string?
like: JSON.stringify("wait this ain't a valid object");
Does anyone know what dependabot does, got an email from GitHub about it
@karmic compass heard about build a bot never heard about dependabot
uhhh
İngilizceden başka dillerde sohbet etmek için #memes-and-media kanalını, top.gg hakkında (Türkçe olarak da) destek almak için #support kanalını kullanın.
Bu kanalda Türkçe konuşmayın.
raid
Stop spamming
gawd
okay
Fuck it
@sage ermine olm turkiye başımızda ama olmaz
what flag is that
Turkish
oh
turkey turkey
I was tryna explain we respect turkish flag but ull get banned
So :/

Turks rlly respect their country and i like that
he definitely a patriot
😂
Dont know what he was doing
lol
I am having trouble running my bot after switching to discord.js v12.
16|alpha | at require (internal/module.js:11:18)
16|alpha | /root/ProjectAlpha/node_modules/discord.js/src/client/voice/util/Secretbox.js:30
16|alpha | } catch {} // eslint-disable-line no-empty
16|alpha | ^
16|alpha | SyntaxError: Unexpected token {
16|alpha | at createScript (vm.js:80:10)
16|alpha | at Object.runInThisContext (vm.js:139:10)
16|alpha | at Module._compile (module.js:616:28)
16|alpha | at Object.Module._extensions..js (module.js:663:10)
16|alpha | at Module.load (module.js:565:32)
16|alpha | at tryModuleLoad (module.js:505:12)
16|alpha | at Function.Module._load (module.js:497:3)
16|alpha | at Module.require (module.js:596:17)
16|alpha | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39)```
There was also another problem that occurred but I fixed it, but I assume this will come up after refreshing node_modules
15|alpha | /root/ProjectAlpha/node_modules/discord.js/src/client/Client.js:41
15|alpha | } catch {
15|alpha | ^
15|alpha |
15|alpha | SyntaxError: Unexpected token {
15|alpha | at createScript (vm.js:80:10)
15|alpha | at Object.runInThisContext (vm.js:139:10)
15|alpha | at Module._compile (module.js:616:28)
15|alpha | at Object.Module._extensions..js (module.js:663:10)
15|alpha | at Module.load (module.js:565:32)
15|alpha | at tryModuleLoad (module.js:505:12)
15|alpha | at Function.Module._load (module.js:497:3)
15|alpha | at Module.require (module.js:596:17)
15|alpha | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39)
15|alpha | at require (internal/module.js:11:18)```
nodejs and npm is up to date.
Did you just update it directly from where you coded your bot
Directory I think
v8.10.0
And thats up to date...?
You need atleast v12
hmm
root@infernobot:~# sudo apt-get install nodejs
sudo: unable to resolve host infernobot
Reading package lists... Done
Building dependency tree
Reading state information... Done
nodejs is already the newest version (8.10.0~dfsg-2ubuntu0.4).
0 upgraded, 0 newly installed, 0 to remove and 100 not upgraded.```
is there a problem?
iirc, that } catch { error occurs if you update your bot straight to v12 from where you coded it. I only ever heard of people either making a new project or rewriting their commands to fix it
well, it only occurs in my VPS not locally.
- thats inside the discord.js package
so this is how it works
a mention when taken in a string or converted into a string
wdym
testing lol
root@infernobot:~/ProjectAlpha# node -v
v12.18.3```
Updated node to v12 but its still having problems with the try catch
i mean
when a user mention or channel mention
is taken in form of a string
That has always happened when it gets updated from v11 to v12 @earnest phoenix
The only ever solution I have found was to make a new project, install v12 version there and copy over the commands
Idk if there is any other way
Maybe someone else knows a way to fix it without making a new project
project by new file? or project by recode everything.
i already rm -rfed the project file and copied everything over
BUT node_modules
ran npm i and tried
still threw me errors
You missed a variable (error) after catch. This is basic JS shake my head...
Project as in recode everything. But I feel like there are other ways to fix it instead of recoding
} catch (e) {}
That aint the problem Timo
Interesting
This happened to everyone when they updated discord.js to v12
i'm sort of dumb rn but if i store when i added something to db how do i filter by that date to only return ones where that date (item) has been there for say a minute
js
i can't work the logic out
object, i have a field cachedAt which is new Date() when added
throw err;
^
Error: Cannot find module 'C:\Users\Pujya Kumar\Desktop\Tansen'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
whats this
i want to filter so i only have items that have been in there for a minute or longer
to delete them
#topgg-api help me ther
If it's a known issue shouldn't djs made at least a post about it in their server
I didn't have it when I upgraded though

idk what your object looks like, but i would object use either keys, values, entries and check if ((newDate - oldDate) > 60000) { // deleteus }
my brain just can't figure out the logic today
so ty
i'm building a cache and want to delete items that have been there for a minute or more
np

@weak rain what are you trying to do
i want to start my bot
so you're running node . or node [file.js]
can i see your package.json
The path you specified doesn't lead to an existing file
^ its in your package.json
"//1": "describes your app and its dependencies",
"//2": "https://docs.npmjs.com/files/package.json",
"//3": "updating this file will download and update your packages",
"name": "hello-express",
"version": "0.0.1",
"description": "A simple Node app built on Express, instantly up and running.",
"main": "server.js",
"scripts": {
"start": "node ."
},
"dependencies": {
"express": "^4.17.1",
"discord.js": "^12.2.0",
"fs": "^0.0.2",
"path": "^0.12.7",
"simple-youtube-api": "^5.2.1",
"ytdl-core": "^3.1.2",
"ytdl-core-discord": "https://github.com/CTK-WARRIOR/ytdl-core-discord",
"@discordjs/opus": "^0.3.2",
"genius-lyrics": "^3.0.0",
"moment": "^2.27.0",
"ms": "^2.1.2"
},
"engines": {
"node": "12.x"
},
"repository": { "url": "https://glitch.com/edit/#!/hello-express"
},
"license": "MIT",
"keywords": [
"node",
"glitch",
"express"
]
}```
WOW WOW, i really need help rn
start server.js
I listed all the servers id where my bot is in
and one shows undefined
how is that possible?
"scripts": {
"start": "node server.js"
}
lib being dumb dumb
^
happens sometimes
my lib done it too
pog moment
lol
honestly server outage?
its api sometimes also
filter it out, fuck that guild
oh yeah a server outage fucked my bot on v11
thats why i moved to v12 today
and now i am stuck
with this stupid try catch issue
😐
Could be that the server is unavailable
so libs are going brrrr?
For a few days now, my bot has been pinging higher than usual. I use Heroku for the host and MongoDB Atlas as a database. By the way, are any of you having this problem too?
If any my ping has been lower the last weeks, how high is your ping?
My bot has about 3000 ping on average, usually has always had 150/200 on average
How do I make my own bot?
Is this just during start up or even when it's been running for some hours
I also changed the database server, but apparently that's not the problem
Thanks
yw
It always has the highest ping during start-up. But for a few days now, the ping is always so high without ever coming down
Yes it is true the host is free, but I have never complained about the 200ms ping average as it is more than acceptable for a free thing. I don't understand why the bot now reaches such high pings
So I have a bot (still awaiting review) but it has a feature to make a captcha, how long did you think a friend of my took to make a program to decipher it?
Do any of you know how to change region on Heroku?
are there any random modules on npm that pick out the primary/dominant/main colour in an image
The Colorado is completely random tho
Well except that it needs to be above 55 green for the captcha itself
can the bot track dbl votes
using webhook
i mean can i put the webhook code in the bot code
will it work
const fetch = require("node-fetch");
module.exports = {
name: "phub",
category: "image",
description: "PornHub Quote",
run: async (bot, message, args) => {
let user = await message.mentions.members.first()
let text = args.slice(1).join(" ")
if(user){
text = args.slice(1).join(" ");
} else {
user = message.author;
}
if(!text){
return message.channel.send("**Enter Text!**");
}
let m = await message.channel.send("**Please Wait...**");
try {
let res = await fetch(encodeURI(`https://nekobot.xyz/api/imagegen?type=phcomment&username=${user.username}&image=${user.displayAvatarURL({ format: "png", size: 512 })}&text=${text}`));
let json = await res.json();
let attachment = new Discord.MessageAttachment(json.message, "phcomment.png");
message.channel.send(attachment);
m.delete({ timeout: 5000 });
} catch(e){
m.edit("Error, Try Again! Mention Someone");
}
}
};
Whats the cause?

} else if (isEmbed === true) {
this.client.shard.broadcastEval('if (this.guilds.cache.get("724602779053719693")) this.guilds.cache.get("724602779053719693").channels.cache.get("'+channelid+'").send('+message+')').catch(err => console.error(err));
}
I am unable to send a embed through this. I've tried multiple things, but I couldn't figure out how to send an embed already defined through a shard eval. This is the only error I get
a. already using fields
b. why would having random rainbow colours help
not even sure if 'random' exists tbh
"RANDOM" exist
why is my canvas working on my local, but not on my vps

Error: /blablabla.../Release/canvas.node: invalid ELF header
y
Okay, my mistake is that I moved the bot etc and installed canvas
but missed the gyp dependencie
Uh, the error message is wrong
You might want to console log the error inide the catch block
to see the actual error
that error doesn't appear because you didn't mention someone
Also unneccessary await let user = await message.mentions.members.first()
@sick cloud this is the code for RANDOM in djs #commands message
but still doesnt answer the question "how does making it rainbow make it better"





