#development
1 messages · Page 1627 of 1
im now seeing this.. seems fun
How Do I Redo This, Im Trying To Log When The Command Is Used, It Logs The Guilds Yes, But It Logs All of Em At Once Even If The Command Came From One Server
exports.run = (client, message, args,) => {
let channel = message.mentions.channels.first();
let announcement = args.slice(1).join(" ");
channel.send(announcement);
client.guilds.cache.forEach(guild => {
console.log(`${announcement} Has Been Said In ${guild.name} | ${guild.id} By ${message.author.username}`);
})
message.delete({timeout:10});
Yea,
/**
* @param {...any} keys
* @returns {Array<{ key: boolean; }>}
*/```
Still confused of what to replace `key` with so it can be anything
try this. This is just speculation
/**
* @template P extends Array<K>
* @param {P} keys
* @returns {{ P: V }}
*/
deleteMany(...keys) {...
Hmm, let's see
oh nvm. That would be a literal object with a property P
This is jank
{ [P[keyof P]]: V }
I'm just throwing shit out there
let me actually sit at my desk and code
they will begin running almost at the same time.. if you wait for the async to finish, then do the then.. they change dramatically.. so may I ask why you make them run when the other is running?
@lament rock
Yeah. That's what I thought. Trying something
What does the customisable behaviour tag mean?
@viscid gale use this
ik bru ik
the mere thing that i'd be using that many promises would be insanely off
it's called experimenting
and thanks btw u guys
experimenting with what?
when u were little, didnt u race paper boats down the drain to see which was faster? u weren't applying it in anything but u were doing it for fun
same thing different context i guess
I feel like my question was drowned out in this discussion. Does anyone know how to access the bot's client? I've tried initializing it like it shows in the discord.js documentation, but when I try to do, ie.```js
const BaseCommand = require('../../utils/structures/BaseCommand');
const Discord = require(discord.js);
const Client = new Discord.Client();
const config = require(../../../slappey.json);
Client.login(config.token);
module.exports = class ChannelsCommand extends BaseCommand {
constructor() {
super(channels, utility, []);
}
async run(client, message, args) {
try {
const listedChannels = [];
const Guild = await client.guilds.fetch("guild_key_here");
Guild.channels.cache.forEach(channel => {
if(channel.permissionsFor(Client).has('VIEW_CHANNEL')) listedChannels.push(channel.name);
});
message.channel.send(You have access to: ${listedChannels.join(', ')});
} catch (err) {
console.log(err);
}
}
}
it gives this error:txt
TypeError: Cannot read property 'has' of null
So I fear that the client isn't actually initialized.
I don't know if it's development question but how to make new bot? 5k people has bot developer role. :/
well anyway
idk if you have heard of it but the bot is called
yukari
and there is nothing about in on the discord bot page so doing it manually is the only way
Learn a programming language, develop a bot using the Discord library for that language, post the bot on top.gg and get it approved. That's how you get the Bot Developer role
Am I asking a common question here?
You cannot and should not ever create a new client in another file.
async run(client, message, args) { <--- is this client not sufficient?
Could you elaborate on that?
I've tried using that in the past, and it did the same thing.
What I mean is, ```
const Discord = require(discord.js);
const Client = new Discord.Client();
const config = require(../../../slappey.json);
Client.login(config.token);
Remove all those lines. They do not belong here in this command code.
Now, whether the client is actually available in this file depends on how that command is called
as in, how is command.run() being called from your message handler.
const BaseEvent = require('../../utils/structures/BaseEvent');
module.exports = class MessageEvent extends BaseEvent {
constructor() {
super('message');
}
async run(client, message) {
if (message.author.bot) return;
if (message.content.startsWith(client.prefix)) {
const [cmdName, ...cmdArgs] = message.content
.slice(client.prefix.length)
.trim()
.split(/\s+/);
const command = client.commands.get(cmdName);
if (command) {
command.run(client, message, cmdArgs);
}
}
}
}
well that should be fine then, assuming client.prefix isn't causing an error the rest should be fine
So now, what is the actual issue in your command trying to access the client?
what issue were you trying to solve?
Accessing its permissions.
the ```js
if(channel.permissionsFor(client).has(VIEW_CHANNEL))
It doesn't?
Then maybe I'm confused on what a client is.
no, the client is the application itself, not the bot user
think of the client exactly like the discord application
the discord application is not you, the user, and you are not the application
What you're looking for is client.user which is the bot's user object.
ah
yeah, that fixed it. just started with bot development two days ago. still learning the conventions
thank you

@earnest phoenix I tried the best I could to match the return type you had originally planned, but I cannot get it to work.
This is the sample that I got closest to working:
/**
* @template K
* @template V
* @extends Map<K,V>
*/
class Thing extends Map {
constructor() {
super()
}
/**
* @template {Array<K>} P
* @template {P[keyof P]} EoP
* @param {P} keys
* @returns {{ [typeof EoP]: boolean }}
*/
deleteMany(...keys) {
return keys.map(key => ({
[key]: this.delete(key)
}));
}
}
However, I don't think you can do this unless there was a keyword which gets only entries of an Array
Another thing I've noticed when looking at say, StackOverflow / Reddit, is that people use a different method```js
const Client = new Discord.Client();
Client.on(message, ...
It's mostly a question of preference
There's always more than one way to skin a cat, when it comes to programming.
skinCat(cat);
const Cat = require('./cat')
const cat = new Cat.skinned();
const cat2 = new Cat();
cat2.skin();
yes
you should rename your Client variable to client just to follow js conventions
Yeah, it was just an example. I had it capitalized originally to differentiate between the client var in the async run(client, ... line, only to find out that client is the bot client.
Thanks for your help guys, I'll probably be back lol.
Yea i don't think it's possible 

Extra comma
I thought trailing commas were ok
Not in json
Is anyone familiar with bulk fetching and deleting message history by message content (if its even possible). Not too bothered about the lib but preferably JDA or discord.js
The only way to do is
fetch 100 messages -> loop through each one of them, checking if the content matches -> delete matches
alright, thats the only thing i could think of
thanks anyway
👍
oh, well… is there any simple way of looping through 100 and then the next 100
or would i just have to like store the last message id and then just fetch 100 from after that message or something
not sure if discord.js stores that automatically
That's probably what you have to do
Guys, how could i add a altprefix? I know it is possible but I have no clue how to do it, google is also not helping
final long guildId = event.getGuild().getIdLong();
String prefix = Config.get("PREFIX");
String raw = event.getMessage().getContentRaw();
if (raw.startsWith(prefix)) {
manager.handle(event, prefix);
}
this is my prefix code, takes the prefix from the .env
what language is this?
Is this JDA
I didn't know that JDA worked with .env
What does .env have to do with any programming language tho 
It indeed works
You want a dictionary attached to your client object
idk I thought it was just some javascript thing
where the key is the guild ID and the value is the prefix
For saving yes, for fetching I personally prefer to pulling from database on bot start and then working with cache only
I only cache prefixes for like 15 minutes
no point to have a big boi map if you don't use it
same shiv 😩
I’ll give it a try
how do I upload to a custom sharex server ? I have made one
how would i make something like this work?
assuming you have it hosted, you make a new custom uploader with the correct upload path and method, ex. POST and https://pyrocdn.com/upload and set the correct headers/body ex. key | MY_SPECIAL_KEY
use concatenation
AHA
or template strings
its all preference but template strings make it easier with spacing
?
Looks prettier also
@earnest phoenix refer to this and #development message
${msg.member.displayName} loved someone! vs msg.member.displayName + ' loved someone!'
.setTitle(${msg.member.displayName} `loved someone!`)
something like that?
👀 does that make any sense to you
sorry im new to coding
irdk.
You want one big string
Yours will only create loved someone!
You enter stuff in {} INSIDE the backticks as a placeholder
actually it will create Unexpected token: $
I'm not explaining that shit
oh
They will be essentially replaced with actual values
im sorry
but do you mean like this:
.setTitle(`${msg.member.displayName} loved someone!`)
One message removed from a suspended account.
Are you sure you saved your file and that the error isn't coming from somewhere else
i got the default npm ERR! code ELIFECYCLE error
only when i tried the command tho
yes im sure
show the full error
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! universe@1.7.0 start: `node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the universe@1.7.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
only pops in console when i try the command
all other commands work
Is there more to the error or is that all
thats all
and it only pops up when i try the command
The error is telling, you that it cant spawn your process
Something in your script is broken or causing problems
but thats weird bcs ever other command works
and when i remove ${msg.member.displayName} thats when the error stops
Did you installed a new NPM package?
yes
what?
no

.setTitle(`msg.member.displayName, loved someone!`)
^^ is that what i would type?
you node module folder is probably corrupted, run npm start
it works like i said
but when i type the command it stops and gives the error
this is the code for the command:
const Command = require('../Command.js');
const { MessageEmbed } = require('discord.js');
module.exports = class FindIdCommand extends Command {
constructor(client) {
super(client, {
name: 'love',
usage: 'love <user mention>',
description: 'Shows how much All About Ishaan loves you!',
type: client.types.OWNER,
ownerOnly: true,
examples: ['love @♥°•Lexie•°♥']
});
}
run(message, args) {
const target = this.getMemberFromMention(message, args[0])
if (!target)
return this.sendErrorMessage(message, 0, 'Please mention a user, role, or text channel');
const embed = new MessageEmbed()
.setTitle(`msg.member.displayName, loved someone!`)
.addField('He loved:', target,)
.addField('I hope he loves you forever! I am wishing you a wonderful day!', target,)
.setImage('http://38.media.tumblr.com/9204649fd84d3df7223feb6712a89444/tumblr_n8pc8badUs1sg0ygjo1_500.gif')
.setFooter(message.member.displayName, message.author.displayAvatarURL({ dynamic: true }))
.setTimestamp()
.setColor(message.guild.me.displayHexColor);
message.channel.send(embed);
}
};
npm cache clean --force
rm -rf node_modules package-lock.json
npm install
``` it should work again
is that correct?
or is that wrong
you are passing "message" and you are trying to access "msg" 
, totally wrong xD . message.member.displayName
oh
command works but now:
yes
omg thx alot!
im having a moment or my bots just dumb, i have color: "darkred", as my embed colour the colour its shwoing is darkblue -=- xD
this color does not exist
ohh
use HexColors for customization
it does exist DARK_BLUE
["DEFAULT", "WHITE", "AQUA", "GREEN", "BLUE", "YELLOW", "PURPLE", "LUMINOUS_VIVID_PINK", "GOLD", "ORANGE", "RED", "GREY", "NAVY", "DARK_AQUA", "DARK_GREEN", "DARK_BLUE", "DARK_PURPLE", "DARK_VIVID_PINK", "DARK_GOLD", "DARK_ORANGE", "DARK_RED", "DARK_GREY", "DARKER_GREY", "LIGHT_GREY", "DARK_NAVY", "BLURPLE", "GREYPLE", "DARK_BUT_NOT_BLACK", "NOT_QUITE_BLACK"]
dark but not black
yes, but not what they provided
lol
black but not dark
makes more sense
i how to fix this pls help guys
im using shard
one shard is online but other any shard is dont online
yeah, no errors here
looks like you have 4 shards online
bruh
why?
doesn't seem too hard if there is a library for a http server
just gotta get the body from the request
Could you let me know how would you do this. I’m trying to do it but I’m failing (never done it before)
idk how it works in Java
So I'm creating a meme bot. And when the reaction on the meme reaches 2 (2 for testing purposes) and I the owner of bot send lmao send-meme it should send the meme with 2 reactions. So far with my code it does this correctly.
What I want it to do is if the meme is the same as before it wont send it. How would I do that? I'm using reddit for the memes.
Code:
hot-meme.js (generates meme)
https://gist.github.com/EliteHaxy/bbaee8f36caadac07bc1eb8b696accec
send-meme.js (sends meme to channel)
https://gist.github.com/EliteHaxy/e6d8e414dbd438cf45e122dc69247394
in the future I want it to be automatic where when a reaction reaches the limit (in this case 2) it sends it to the meme channel. Doesn't duplicate the meme though if its the same.
Also side note question how would I say "if something is exported do this"?
in this case when a meme reaches 2 reactions it exports it. I want it to be when it exports it also sends that meme to the channel with no duplicate memes.
is this like a similar imitation of starboard but for daily memes?
define daily limitation? like you cant get the same meme mutiple times in a row or only allow a certain amount of memes per day?
is that normal
I mean it's an error, so... no?
well if the bot dont have permissions for it
also the role of the bot has to be above the one you want to give
ok
How do you find the Client ID of a bot? I am trying to add Dice Maiden to my server and I need the client ID
Well you need to have the client ID to do anything. Unless you have the bot's name and a search (on top.gg or google) lets you find the ID, you can't otherwise.
For the client Id go to your application then bot and it says client Id just copy
If your own bot, not someone else's, of course.
Yes
Do you have a bot that you made already? Like, did you code anything?
i have Dyno
That's not yours
but i dont know how to do that
He means one you developee
You mean Dyno already does that?
i dont know, i dont know too much english, so it too hard for me
Well, we really can't help you then
someone told me Dyno can do that
If you found a bot that does that, just use it
maybe ask on that server you captured that video from, ask them what bot they're using?
@@
Hi i recently released a bot and bot testers find it really cool.But does somebody have tips how to gain much guilds?
(node:15092) UnhandledPromiseRejectionWarning: MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist:
https://docs.atlas.mongodb.com/security-whitelist/
HTTPError [FetchError]: request to https://discordapp.com/api/v7/channels/724379979751882784 failed, reason: getaddrinfo EAI_AGAIN discordapp.com
at RequestHandler.execute (/home/container/node_modules/discord.js/src/rest/RequestHandler.js:107:21)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
code: 500,
method: 'patch',
path: '/channels/724379979751882784'
}```
Anything I can do about this? I saw people say "update discord.js" but afaik it's just v12
set ip whitelicst on cluster
then do all
mouth advertising do be best advertising
except when it becomes spam
Do, all, what?
he meant whitelist 0.0.0.0
Oof.
yes
I'll try now.
but are there any option without bot pages like partnering
well, for testing purposes he can do it without problems
to see if issue is regarding ip whitelist
but close it, if you are done
well, yes, but "constrained advertising" is different from "free will advertising"
It works with everyone, but I literally can't connect to the databsase.
like, if people like your bot, they'll talk good about it
Is Date.now() everywhere the same?
It worked.
ive had some luck with my bot, mostly bcs i where staff in a Server with 10k Members and i where allowed to add my bot there, sure got in the end like 15 invites out of it but it worked
ok, now you need to figure out a way to not need to use 0.0.0.0
well its a epoch timestamp
yes
english pls lol
1 user that likes your bot is better than 10 partnered advertisers
milliseconds lol
free will advertising is insanely powerful, just look at how people are capable of cancelling other people
quite hard to gain guilds if there are paying bad bots

do you mean i should speak with staffs and tell about my cool bpt xD
PAYWALL
you could try auctions, but they went to become way harder with the recent changes
What can I do if my local IP adress doesn't even, work?

are you using your public ip address?
your PC or your server?
like, not the 192.168.xxx.xxx
PC.
just be nice to your users, offer to help when you can
did you have a static or dynamic ip? also like KuuHaKu said the right ip?
It used to work like 1 day ago, today it doesn't.
make them fall in love with it
eventually you'll start to get advertising from those people
hi guys
okay i will try are they any partnering bots without botlabs.gg
Nope, it doesn't start with that.
(people who invite then kick 1 second later)
but like, how are you getting ur ip?
through cmd?
There is a button called Add current IP adress
ah, ok then
ive had a guild where idk what they had going on, they just invited my bot 10 times and kicked the bot 9 times
but still doesn't work, bruh.
did you have a VPN running? like some browsers have one build in
then use one and see if it helps
i do not recommend it
since you have then a point of entry that could get bruteforced
What can I do, though?
The docs say that passing [string, {meta: ...}] is completely fine, and yet typescript is throwing an error... am I doing something wrong? https://mongodb.github.io/node-mongodb-native/4.0/interfaces/findoptions.html#sort
Documentation for mongodb
(node:13220) UnhandledPromiseRejectionWarning: MongooseError: Operation `servers.findOne()` buffering timed out after 10000ms
yea bcs you are not connected
wow.
does it work now?
I literally edited and pressed save again and the IP changed.
gg
I did absolutely nothing.
the bane of dynamic IPs
👏
well your ISP did
🤷♂️
👀
its possible you have so much data it takes too long to index and send?
i love my FTTH network tho, i have a semi Static IP bcs its shared with 50 other people in the village, bcs of this the IP changes extremly rarely
yes
its like downloading games
nah
Hm.
discord used MongoDB when they started, a few 100k documents are nothing
if you run out of Ram you will get some issues (MongoDB stores Keys in Ram)
2GB storage*! No worries!
tbh this should be fine for most discord bots. like one document is just 1-3kb
maybe 5kb if its a larger one
180kb currently.
anyone?
what d.js version are you running (exact version)
wtf is this
the discord API?
oh oops 😅
Thank you
@quartz kindle I need a bit of help, im so confused how this is doing this http://cdn.yxri.dev/u/181906030321.png
http://cdn.yxri.dev/u/181929030321.png
http://cdn.yxri.dev/u/182118030321.png
echo just prints what's in the " " if I remember correctly.
k
Does anyone know a solution for this Problem:
- I have a Date given ==> want to parse it on the timezone ===> and get the timestamp of the time in the timestamp
just do not do it ,use a parser maybe you will find one on npm.js
, well I asked bc I did not found anything. Great help, irony off
Have you tried moment-timezone? https://npmjs.com/package/moment-timezone
- is depreceated
it has to convert the time into the timezone
I mean, do you need to convert to a specific timezone or support multiple?
It is indeed considered "legacy" but still works flawlessly and is continuously widely used. Well yeah it has to convert the time to the timezone. Perhaps I'm confused on what exactly you want?
much , 300
iirc the epoch timestamp is GMT 0 so you could go from it
and how, then I have to manually calculate the difference of each timezone?
where can I know the difference of each one?
GMT-0 to GMT+3 = +3 hours
any ressources
https://moment.github.io/luxon/ maybe this helps
have this, but do not how to convert them
read docs 
Yes, hard to find, when they are so much stfu lol
1 + 1
I just told u how to calculate
arent they still based of some imaginary lines drawn from pole to pole?
and when its summer 
just add when it's needed smh
yes, good listened in school xD
I have a doubt
not always, there are timezone offsets of 45 or even 50 minutes, not a full hour
it's literally a simple equation

but the main difference is the whether and when a specific timezone has summer time
probably just some supreme leader who wanted some special timezone
My bot had like 40-41 votes in Feb and still it never showed on the Maine Top.gg page, but I saw many bots being on the main page even with 30 votes and vere not sponsored
its possible that they got a place with auctions
trending new bots?
??????
where did u see them?
no, I mean, WHERE in the main page?
and they werent sponsored or promoted
thats way I am having a burnout, what to do lol
which was what I said...
trending new bots is only for new bots
it can be less than a week in some cases
it depends on several things not just votes
use luxon or moment-timezone
once you're out of there you'll need to compete against the big dudes
or buy a tag
^
well, all bots were small once
my bot's name is small
My bot is ShadeEE
mine was 30-ish servers a year ago, now it's 1600+ servers
dayumm how
everyone starts from ground
bruh, did you do paid adverts?
time, cool features, mouth advertising, on-demand support, etc
no, full f2p
I am using it, but I can not figure out how to convert it
help your users
moutch advertising?
Unfortuneately I am broke
be kind to them
as I said, 0 money spent (on ads I mean)
propaganda 
it is illegal for programmers to have friends
toxic
show ur bot to your friends who have servers, then help them learn to use it
their servers' members will eventually become curious
and ask how it works
ah nice, do you know i have a bot
exdi
whenever I show them they kick my a**
My lonely bot lol
just start small, don't try to shove a banana down their throats
true
what is the meaning of that idium?
idiom
all i can think of is deepthroating
what is deepthroating
oh my
its like you use a stick to clean your throat
just...let's drop that convo
lol
eh, ok
look at youtube premium or Raid: Shadow Legends™️
no
rude
:0
noice
don't simply run over them with a car
My Nitro expires in 9 Minutes 
be patient, don't expect more than 5 servers per week at the start
sED
eventually it'll speed up
I grow -3 servers per week lol
My nitro expires the day my exams are finished
haha, some bots which are really good ideas, have a stonky grapfh
my bot is in only 86 servers
Is it verifeid?
ofc yes
Can I try it out?//
hardly, unless you actively advertise it
yes
well, I mean, some bots do go from 0 to 100 real quick after it gets into motion
link pls
not here btw
but i am turning it off right now, the link to add it is in my rpc
yea
ook
my bot isnt 
Seb vettels helmet
Hello Fello Seb stan
It isn't a selfbot thing. Ik erwin does it using something
no
wonder how
Did u see his new car?
its legal
yes
its dope
SDK? I think lemmy check
Your bot is nice
DISCORD RPC
hank you

= Discord rich presence
ik
oh nice
@fast edge you can play with the bot tomorrow? may i turn it off?
i need to go through the bugs and stuff
sure
my RPC isnt working
ok, bai, ttyl
I need a good ban icon but I don't know which one to choose from https://icons.getbootstrap.com/
done it already
:Ban:
my nitro expired
sorry I am one minute to late lol
Hi, could someone help me with writing and reading a JSON file? I want to periodically access it and store server preferences in it, but I'm having a lot of trouble (doesn't seem like there's too much comprehensible info about it online). If there's a better way to do it please let me know.
that was a ban icon for a website lol
black white lol
You shouldn't be using json files to store persistent data - use a database
sqlite3, mongodb, postgresql are all great choices
Thanks, will look into it
And if you are just starting out you can try out quick.db
which makes it way easier
but it's very limiting
I want it to be a button, to show if the user is banned, for example it would be not filled if the user isn't banned, and when an admin clicks on the hammer, it fills
there isn't a non-filled hammer 😢
Edit it in photoshop
button for what? a site?
Ah
yeah
just change svg fill property to false
@cinder patio https://www.flaticon.com/search?word=Hammer
Is free to use
It just disappears
I'll change the color to white I guess
wait I can't that'll mess up my themes
I guess I'll use the bootstrap icon lmao
I really wanted my bot to be verified, but there was a problem where I coded it.
which is here?
you need to add a padding of -1 because of line width
thanks
when you need to fill it, just change fill="none" to black
or whatever color u need
what?
where do you make boots from
I code them in bootghost
notepad.exe, npp.exe, intellij.exe, vscode.exe
tldr: any text editor
there's no visual drag 'n drop builder
I prefer nano
you need to code
but you do you
I buy my boots, I don't make em
you're missing out
can confirm, google buys them from me
Tim made GoogleFeud's boots?
ah
thank you
henlo peeples of development peoplesing peoples
yes im very good at saying hi
So im getting an error with my warning system
and idek why
i have the error as well as all the warning commands, the warning model, main.js and message.js in here
if someone is able to help it would be greatly appreciated
Hi! Does anyone know if <message>.awaitReactions() is supossed to work on direct messages? My function works perfectly on a text channel but its filter does not receive any reaction if done in DMs.
are you exporting anything in your /models/warns
wdym
do you have the direct message reactions intent enabled?
if your not exporting any schema then your not using anything related to mongoose, so mongoose methods dont work
I dont think i even have schema in the warns.js, f
lemme fix that
ill come back if i need more help
//creating and exporting user schema
const mongoose = require('mongoose');
const UserSchema = new mongoose.Schema({
name: {
type: String,
required: true
},
otherproperties: {
type: String
}
});
const User = mongoose.model('User', UserSchema);
module.exports = User;
// using the User schema in another file
const User = require("../models/user.js");
User.somemongooseschemamethod;
just as an example.
thanks
im about to run it and see if it works
@solemn latch yeah i wasnt able to fix it
ill send my new warns.js
const db = require('../models/warns')
const { Message, MessageEmbed } = require('discord.js')
const { Mongoose } = require('mongoose')
const mongoose = require(`mongoose`)
let Schema = new mongoose.Schema({
guildid: String,
user: String,
content: Array
})
const warnschema = mongoose.model("warnschema", Schema)
module.exports = warnschema;
module.exports = {
name :'warns',
async execute(client, message, args){
if(!message.member.roles.cache.has('808043455255150612')) return message.channel.send('You do not have permissions to use this command.')
const user = message.mentions.members.first() || message.guild.members.cache.get(args[0])
if(!user) return message.channel.send('User not found.')
const reason = args.slice(1).join(" ")
db.findOne({ guildid: message.guild.id, user: user.user.id}, async(err, data) => {
if(err) throw err;
if(data) {
message.channel.send(new MessageEmbed()
.setTitle(`${user.user.tag}'s warns`)
.setDescription(
data.content.map(
(w, i) =>
`\`${i + 1}\` | Moderator : ${message.guild.members.cache.get(w.moderator).user.tag}\nReason : ${w.reason}`
)
)
.setColor("RED")
)
} else {
message.channel.send('User has no warns')
}
})
}
}
That was life saver! Ty. I wouldn't have realized by myself :)
its not warns.js, its your warn model export, ie '../models/warns'
wait so my previous warns.js was fine?
i mean in my other commands i had the const db = require('../models/warns`)
if you delete your usage of db in warns.js your other files will probably start erroring
i dont get it, i DO use db in my warns.js
which is whats erroring
so... I shouldnt use db in my warns.js?
I didnt say that.
sry btw im new to the whole mongodb thing
I think your error is because your '../models/warns' is setup incorrectly
huh
ok lemme check
so the ../ would bring it into the main directory
then its in the models folder
then it navigates to the warns.js folder
do I have to include the .js?
yes...
im still getting the same error
whats the file look like?
the warns model file
const db = require('../models/warns.js')
const { Message, MessageEmbed } = require('discord.js')
const { Mongoose } = require('mongoose')
const mongoose = require(`mongoose`)
let Schema = new mongoose.Schema({
guildid: String,
user: String,
content: Array
})
module.exports = {
name :'warns',
async execute(client, message, args){
if(!message.member.roles.cache.has('808043455255150612')) return message.channel.send('You do not have permissions to use this command.')
const user = message.mentions.members.first() || message.guild.members.cache.get(args[0])
if(!user) return message.channel.send('User not found.')
const reason = args.slice(1).join(" ")
db.findOne({ guildid: message.guild.id, user: user.user.id}, async(err, data) => {
if(err) throw err;
if(data) {
message.channel.send(new MessageEmbed()
.setTitle(`${user.user.tag}'s warns`)
.setDescription(
data.content.map(
(w, i) =>
`\`${i + 1}\` | Moderator : ${message.guild.members.cache.get(w.moderator).user.tag}\nReason : ${w.reason}`
)
)
.setColor("RED")
)
} else {
message.channel.send('User has no warns')
}
})
}
}
in the main directory
so you have two commands folders?
so theres nothing at /models/?
i need to try something
whats there
profileSchema.js (economy system)
and warns.js
TIL ncevm only supports JDK 11 and below
and warns.js is what im replying to?
😔
that is correct
I think whatever source your using for this is configured differently than what you have setup.
which means its really no use to you
you should setup mongoose and your commands seperately
your /models/warns.js should look something like this
//creating and exporting user schema
const mongoose = require('mongoose');
const UserSchema = new mongoose.Schema({
name: {
type: String,
required: true
},
otherproperties: {
type: String
}
});
const User = mongoose.model('User', UserSchema);
module.exports = User;
except warns, not a user.
nothing involving the command goes there.
oh
man im dumb
thanks a lot tho dude
i shall tryeth this
im pleased to announce it finally works
thanks a lot 😛
np
How can i fix this FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
Allocate more memory to your node process or look into what's taking all that memory in the first place and fix it
And how do i allocate more mem?
Idk. Google has an answer somewhere
just adding --max-old-space-size=8192 ans start script
Pretty sure it has a max of 1GB by default on x64 architectures. Or I might be wrong
max old space is how much space is allocated to a specific region of the garbage collection process
but might work
You might have a memory leak somewhere
no there's definitely something wrong with your code
think of this as a temporary solution
man im trying to mine a crypto currency i just programmed i dont need a fix lol
hey so if u use google chrome, it really sucks up RAM like there is no tomorrow
if you want, you can get Opera GX and limit the RAM usage to like 1 GB or less so that it runs fine without taking up all ur memory
im not using internet for this
The embed failed to send the support server as a hyperlinked word this is the first time ive had this problem
const Discord = require('discord.js')
exports.run = async (client, message, args) => {
message.react(':runit:');
var HELP = new Discord.MessageEmbed()
.setTitle("Help:")
.setDescription("To View My Commands Use c2 Commands")
.addField("Support","If You Are Having Any Trouble You Will Have To Visit Our Community Server [Mos Eisley Cantina](https:discord.gg/F86Drtz)")
.addField("OFFLINE","If You Have Seen Me Offline, I Am Updating To Be Notified Of Downtime/Updates Visit [Mos Eisley Cantina](https:discord.gg/F86Drtz)")
.setColor("0x#FF0000")
message.author.send(HELP)
};
the url in your hyperlink is not a valid url
oh i now see i forgot he //
yup
only reasons for downtime are updates
not all the time, ive had powercuts during updates that have caused unwanted downtime
Hi guys
Does somebody know if it's possible to clear errors on express-validator
i mean when i refresh the page
i still got the error
RIP. My script has 1234 lines... how to use multiple .js files??
(please don't tell me to read discordjs docs they doesn't explain that good)
They actually do.
Sup
Use the inbuilt command handler just by adding a few more lines.
okay than I don't understand them that well
you can use modules
that's what I mean
but how
and I got an error >:C
:/home/container$ npm i && npm start
npm ERR! code EJSONPARSE
npm ERR! file /home/container/package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected string in JSON at position 499 while parsing '{
npm ERR! JSON.parse "name": "Clyde",
npm ERR! JSON.parse "version": "1.0.0'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/container/.npm/_logs/2021-03-03T20_59_16_013Z-debug.log
container@pterodactyl~ Server marked as offline...
[Pterodactyl Daemon]: ---------- Detected server process in a crashed state! ----------
[Pterodactyl Daemon]: Exit code: 1
[Pterodactyl Daemon]: Out of memory: false
[Pterodactyl Daemon]: Aborting automatic restart, last crash occurred less than 60 seconds ago.
anyone?^
well
I can send whole script on pastebin if you want me to
Docs are answering this with script examples.
Use exports to split up your commands, classes etc., throw them into a directory, find and load files using filesync and add the loaded content to the existing command handler.
file1.js
module.exports = {
string: "test",
number: 2,
boolean: false,
array: ["pog", "gers"],
object: {pog: true},
function: () => {
return true;
}
}```
file2.js
```js
module.exports = (a, b) => {
return a + b;
}
main.js
const m = require('./file1.js')
console.log(m.function()) // true
console.log(m.string) // test
const add = require('./file2.js')
console.log(add(1, 1)) // 2
fuckin hell that was a lot
holy
Might be a solution to include a few collections of classes but not to include lots of files.
and this error?
bad package.json
Ima just beg a friend to do it lol too much work for my stupid noob brain
mhm
it’s not that hard....
TypeError: Cannot read property 'roles' of null
client.on("message", message => {
if (message.author.id === client.user.id) return;
if (!message.member.roles.cache.has("765885271861624843")) return;
var noWords = JSON.parse(fs.readFileSync("./antiping.json"));
var msg = message.content.toLowerCase();
for (let i = 0; i < noWords["antiping"].length; i++) {
if (msg.includes(noWords["antiping"][i])) {
message.delete()
let embed = new Discord.MessageEmbed()
.setTitle("Please dont ping staff!")
.setURL("https://client.dynamichost.xyz")
.setColor("#ff2e2e")
.setDescription("We can be really busy sometimes. \n Being at school or doing work... \n We do see your messages so please be patient. \n Dont ping staff without permission.")
.setFooter("Regards - DynamicHost")
.setImage("")
.setThumbnail("https://cdn.discordapp.com/attachments/765885272420253706/799597747153010728/gnome_V2.png")
return message.channel.send({ embed });
}
}
});
eh?
Why would you even bother with it if you have no clue?
{
"name": "Clyde",
"version": "1.0.0",
"description": "aka ModBot",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node 1index.js",
"lint": "eslint ."
},
"keywords": [],
"author": "IsmailZ",
"license": "ISC",
"dependencies": {
"discord.js": "^12.4.0",
"dotenv": "^8.2.0",
"chalk": "^4.1.0",
"google": "2.1.0",
"google-translate-api": "2.3.0",
"weather-js": "2.0.0",
"ffmpeg": "0.0.4"
"ms": "2.1.3"
}
}
I would do it if it was a bit easier but it isn't :/
it’s not hard
Imagine working with PHP frameworks especially for remote protocols with a few tousend lines of code
add a comma after "0.0.4"
thoughts on adding this error to my bot?
❌ | Invalid syntax:purge [amount to search] [options] ^^^^^^^^^^^^^^^^^^ Must be a numerical amount.
ahhh

TypeError: Cannot read property 'roles' of null
at Client.<anonymous> (/home/container/src/index.js:288:22)
at Client.emit (events.js:326:22)
Any ideas?
Client.<anonymous> nice
client.on("message", message => {
if (message.author.id === client.user.id) return;
if (message.member.roles.cache.has("765885271861624843")) return;
var noWords = JSON.parse(fs.readFileSync("./antiping.json"));
var msg = message.content.toLowerCase();
for (let i = 0; i < noWords["antiping"].length; i++) {
if (msg.includes(noWords["antiping"][i])) {
message.delete()
let embed = new Discord.MessageEmbed()
.setTitle("Please dont ping staff!")
.setURL("https://client.dynamichost.xyz")
.setColor("#ff2e2e")
.setDescription("We can be really busy sometimes. \n Being at school or doing work... \n We do see your messages so please be patient. \n Dont ping staff without permission.")
.setFooter("Regards - DynamicHost")
.setImage("")
.setThumbnail("https://cdn.discordapp.com/attachments/765885272420253706/799597747153010728/gnome_V2.png")
return message.channel.send({ embed });
}
}
});
Thats my code
I’ve already told you the problem
You're trying to access a member's roles in a DM which is not correct
how do i make it "Not null"
by running it somewhere that has members
its working just fine without this line
if (message.member.roles.cache.has("765885271861624843")) return;
yes because member is null
Eh ok ty
oh god free hosting
put if(!message.guild) return
idk
or you want to use it for dm
nvm
at what point does autoSharding decide to shard?
i realised that ur trying to check a role
like how many shards per server
/home/container/1index.js:1234
client.channels.get('698983333782093925').send('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \nServer: ' + message.guild.name + ' \nChannel: ' + message.channel.name + ' \nUser: @' + message.member.user.tag + ' \nMessage: ' + message.content)});
^
TypeError: client.channels.get is not a function
at Client.<anonymous> (/home/container/1index.js:1234:18)
at Client.emit (events.js:326:22)
at MessageCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (events.js:314:20)
at Receiver.receiverOnMessage (/home/container/node_modules/ws/lib/websocket.js:825:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Clyde@1.0.0 start: `node 1index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Clyde@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/container/.npm/_logs/2021-03-03T21_22_44_632Z-debug.log
```Another ERROR... :C
client.channels.cache.get
discord js v12?
k ty
=))
(node:38) UnhandledPromiseRejectionWarning: TypeError: Discord.RichEmbed is not a constructor
at notActive (/home/container/1index.js:784:34)
at Client.<anonymous> (/home/container/1index.js:782:14)
at Client.emit (events.js:326:22)
at MessageCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (events.js:314:20)
(node:38) 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:38) [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.
What old ass code you copying from
MessageEmbed
my own but I messed up so now full of bugs and i have a new host so need to install all npm modules again etc
k not fully my own tbh
if you are trying to fetch channels do
client.channels.fetch(id).then(channel => {channel.send("message")})
an edit of my friend's code xD
lemme try
client.on('message', message => {
if (!message.guild) return; //No DM Messages Allowed!
if(message.channel.id === "630405908715012150") return; //FG (avoid spam logs)
if(message.guild.id === "264445053596991498") return; //Top.gg (too many msg)
client.channels.cache.get('772767304072429588').send('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ \nServer: ' + message.guild.name + ' \nChannel: ' + message.channel.name + ' \nUser: @' + message.member.user.tag + ' \nMessage: ' + message.content)});
``` how to?
that should work, if it's a valid channel
it should work if the bot can access the channel
yep
How do i check if someone has a specific role
1 sec
ty
for ex if(message.member._roles.includes(roleid)) console.log("true")
u manage how to get the member
hope it helps
:}
isnt it roles.cache.has?
He doesn’t wanna know if the role exists
message.member is null in DM channels
i just want to make it so that the bot ignores messages from staff role
in server right?
log the message.member
pls
Scroll up, told you already
eh?
You can chain conditionals btw
if (message.member && message.member.roles.cache.has(id)) return
weird development channel moments
im running of decaff coffee rn 😭
just
console.log(message.member)
that s it
put that in your command or message event
idk
Who are you answering? Seems to be out of context...
just spams console
i'm talking with @harsh blade
and
if u do
console.log(message.member._roles)
do you get [ '765885271861624845', '776774885149507615' ]?
yeah
yeah
just copy the code
replace
IDs are strings
Make the ID a string
oh
cache.has() takes string for key
and like Papi said, check that message.member exists since it's null in DMs
like this ("123456789012345678")
Ehhhh
aand it just crashed
`if (message.member.roles.cache.has("765885271861624843"));
^
TypeError: Cannot read property 'roles' of null`
Sorry to bother yall w this
np
if(); wtf
if (newMessage) dontRead();
yeah its supposed to display that embed if the member has the staff role
huh?
like this ("123456789012345678")
Awesome!
oh wait what
if (message.member.roles.cache.has("765885271861624843"));
^
TypeError: Cannot read property 'roles' of null
if(message.member && message.member.roles.cache.has("123456789012345678")){
console.log("test")
}
but it was just working
now im confused
me too
maybe you restarted your bot and the member isn't cached anymore.
you need to fetch members that aren't cached.
Sorry without knowing the basics of JS getting help is impossible
Yeah. I suggest starting off with WOK (Worn off keys) or MenuDocs
Both are great to get you started on fundementals
i am constantly learning...
message.guild.members.fetch(message.author.id) can help here - but you need to await it since it's a promise.
More info on promises if you need to learn about those: https://js.evie.dev/promises
im taking courses all the time
Ok so here is the reason why it might not be working. The role either doesn't exist, or that ID doesn't exist.
I mean that's the only 2 I can think of
TypeError: Cannot read property 'roles' of null cannot happen if message.member is defined as anything
so there's a confusion here on someone's part.
Right
Well I just joined in so I'm in need of a little backing up here lol.
Now, there's 2 reasons for this:
- it's not cached
- this is a DM.
Right
he logged the message.member
and got it all
Right, maybe it was fetched at one point when he logged it
Right
if(!message.member) await message.guild.members.fetch(message.author.id);
There. that should fix it (assuming the function is async)
Yeah if you have a command handler in the callback part of the exports just add async infront of it
yea... try this and put async before message => {

cuz i saw u didn't had it
to be like that client.on("message", async message => {
This supposed to be 2 lines right?
no.
It doesn't matter
the same thing
you don't need to reassign? not sure how fetch() does it
but u can keep it in 1 line
Right
yeah maybe that's required, I'm not 100% sure
but it's certainly a step in the right direction 😄
it probably works, assuming that message.member is a getter
But I remember discord.js re-assigning the collection on guild.members.fetch() so maybe it'll be automatic. maybe.
¯_(ツ)_/¯
Tried installing color-thief on windows, but it errors out for some reason..... 🤔
nvm the error explains what i need to do.. lemme try
Seems to be working

Tysm for helpingg
Not a problem
whats this?
DiscordAPIError: Invalid Form Body DICT_TYPE_CONVERT: Only dictionaries may be used in a DictType at RequestHandler.execute (E:\Program Files\smug\code\node_modules\discord.js\src\rest\RequestHandler.js:154:13) at processTicksAndRejections (node:internal/process/task_queues:93:5) at async RequestHandler.push (E:\Program Files\smug\code\node_modules\discord.js\src\rest\RequestHandler.js:39:14) { method: 'put', path: '/guilds/774085711791783998/bans/388452965884755970', code: 50035, httpStatus: 400 }
i
I kinda dont understand it.
is it happening?
with a ping command? lol
no
yeah, 3 per second
I have a per guild cooldown so it just dropped all those without reply

Shame.
not answering on cooldowns - the smart thing most people forget is the smart thing to do
lol
i answer the first time
well it answers the first with a slow down embed
then any after the first it ignores silently
I've been looking into it to try and identify the reason for lag over the past 2 hours
anyone else noticing websocket lag?
no
anyone knows how to fix this
?
we'd need the code for your ban command to understand what's going on
module.exports = {
name: 'ban',
execute: async (client, message, args) => {
if (!message.member.hasPermission('BAN_MEMBERS')) return message.channel.send("You can't use that!");
if (!message.guild.me.hasPermission('BAN_MEMBERS'))
return message.channel.send("I don't have the right permissions.");
const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
if (!args[0]) return message.channel.send('Please specify a user');
if (!member) return message.channel.send("Can't seem to find this user. Sorry 'bout that :/");
if (!member.bannable)
return message.channel.send(
"This user can't be banned. It is either because they are a mod/admin, or their highest role is higher than mine",
);
if (member.id === message.author.id) return message.channel.send("Bruh, you can't ban yourself!");
let reason = args.slice(1).join(' ');
if (!reason) reason = 'Unspecified';
member.ban(`${reason}`).catch(err => {
message.channel.send('Something went wrong');
console.log(err);
});
const Discord = require('discord.js')
const Embed = new Discord.MessageEmbed()
.setColor('#FF0000')
.setTitle('Member Banned')
.setThumbnail(member.user.displayAvatarURL())
.addField('User Banned', member)
.addField('Kicked by', message.author)
.addField('Reason', reason)
.setFooter('Time banned', client.user.displayAvatarURL())
.setTimestamp();
message.channel.send(Embed);
console.log("Ban command had been ran..")
},
};```
(ping me)
@quaint wasp
you told me to ping you
if you will help me
its this line thats causing the issue right?
return message.channel.send(
"This user can't be banned. It is either because they are a mod/admin, or their highest role is higher than mine",
);
oh
😐
reason should be inside an object
