#development
1 messages · Page 1019 of 1
From the channel topic @delicate shore
@weary anchor it's not logging anything
what should i tell
does it unban?
because your logging nothing 🧠
^
console.log() logs nothing
^
an empty line*
Do you even know how to use try/catch?
message.guild.members.unban -.-
no
bruh
oh
reply.guild? lol
I didn't even notice
Because of the code not being formatted properly
yes
@delicate shore and yeah format your code before sending pls
you can use something like https://beautifier.io/
@delicate shore to unbansomeone
message.guild.members.unban()
U need more im not feeding
and you unban like this,
guild.members.unban('84484653687267328')
.then(user => console.log(Unbanned ${user.username} from ${guild.name}))
.catch(console.error);
but change it
U neeed to fetch the bans in the guild
reply.guild? lol
@weary anchor where
I was saying that your code had reply(...).guild
wut
it should be message.guild
lol

if(command === "unabn"){
go and learn js pls
lol
mannn
Sometimes its amazing you all have so many mistakes in one code snippet
the fact you cant even do embeds properly
yes dont eat him
Small question how long can a trending new bot be on trending new bot page for
Is there like a limit
Ah sorry
U can double check ur code..
Mee6 has been on those lists for a long time
mee6 is spnsor
Yeah, all I'm saying is there's really no upper limit
dank memer is always there too
@delicate shore to unban someone in a guild you need to:
fetch the bans
So it will be
Anyway, when you add a line of code, check it for spelling errors, and that you understand what each property, method and everything does
u cant just unban someone without saying what guild there from
How
¯_(ツ)_/¯
Go to docs, search fetchban
You can get guild from the bot's cache and just use or message.channel.guild:
https://discord.js.org/#/docs/main/stable/class/GuildMemberManager?scrollTo=unban
Not that hard 
it says this in top.gg api Authentication is performed with the Authorization HTTP header in the format Authorization: TOKEN
how to actuallt do it?
You need to use a token
plus the header
const dbl = new DBL('Your top.gg token', client);
This is an #topgg-api question really
what?
Oh like that, was ready it differently
what......
That's basic coding knowledge
Honestly, bot development is a good 3rd or 4th project once you know all these
I cant get the new line statement to work
Whatcha mean?
@solemn latch I bet after u code for like 1 -3 weeks u know them from head
"/n" to creat a new line
Use \n not /n
hmm
ye ye i got it
i was just derping again
I do that all the time
I must have gone to 5+ sites withuot realising what I was doing wrong
:3
Suuup

😑
Omg
define it
First mine help
Whatever your using
.includes on isnt defined
Reeeeeeeal nice
:/
Yours is the same error, just for id @earnest phoenix
@earnest phoenix did you read the error????
Whatever your using
.includes on isnt defined
@solemn latch And if you still don't know what this is, go learn code
using includes here - if(message.content.toLowerCase().split(" ")[0].slice(1) === i || commands[i].aliases.includes(message.content.toLowerCase().split(
Oh boy
Is aliases defined in every command
ye
lol
Are you sure
@lethal pine maybe
can i earn money from discord bot
In what context
Does anyone want a moderation bot? DM me and it'll be £2
yes but they all require skill
@surreal notch is aliases array?
How does this guy have the "Bot Developer" role and I don't
@solemn latch id?
@ebon kelp because your bot wasn't verified ye-
.includes is string function
String func-
Includes can be used on arrays
.includesis string function
@summer torrent it exists on arrays too
<Me> because your bot wasn't verified ye-
@pure lion I know, but was a joke
Yooooo who even watches YT for tutorials just read the do-
a lot of "bot developers" aren't qualified enough to be called developers 
Yeah
Somehow i learnt enough
@past blade english only
Its scary how little the badge can mean
role
@past blade english only
@summer torrent ok
Role and badge
the badge literally means nothing
True
The badge means you spammed your bot inv link in several servers for many months
you dont even need to put effort in to get it to that point
Yesterday there was a guy who didn't knew what to answer on the discord bot verify form
LOL
"do I have to put the js question answers here?"
There should be a test
Yes
Linkedin quiz
the badge literally means nothing
@amber fractal yes it does. it means you can get random dms from people asking to buy your account
what a great badge
Oh I want it

For the attention
Ikr

Yeah ill sell my account, but there's a 10 year verification process before I can sell it
Joke mods no ban plox
Poopoo posting in #265156361791209475 plij
is it possible to download a npm package with eval?
Why would you
why not
idk try it?
curious if its possible
dont have exec either dang it
require the exec function from the child_process module and call it
that works?
-eval const { exec } = require('child_process'); exec('npm i @caijs/python-eval') this did nothing lmao
set the second argument as console.log and check your console after running it
why evaling
lol
u have to await till execution is complete
make a separate command
lol
npm ERR! code ENOLOCAL
npm ERR! Could not install from "@caijs/python-eval" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/container/.npm/_logs/2020-07-03T16_00_44_540Z-debug.log
at ChildProcess.exithandler (child_process.js:303:12)
at ChildProcess.emit (events.js:310:20)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) {
killed: false,
code: 1,
signal: null,
cmd: 'npm i @caijs/python-eval'
} npm ERR! code ENOLOCAL
npm ERR! Could not install from "@caijs/python-eval" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/container/.npm/_logs/2020-07-03T16_00_44_540Z-debug.log```
oof
lol
what kind of shitty package is that smh
make a separate command for exec
i cant do anything about this can I?
eval code will not await
The package doesnt have package.json
ok
rip
yea...
epic
maybe you can build it from source
I am having a issue with memory, at like 300 servers. Pretty much, I want to check the database for every server, and if 24 hours have passed, according to the database, it will send a fact and then add 24 hours to the database. This is currently taking up like 180 mb of the memory. How can I make it not take so much memory? Here is the code,
what exactly is taking 180mb, how are you measuring it
the entire process? are you using process.memoryUsage() to measure it?
I don't exactly know. Jade put it up on a VPS and told me it used 160 mb memory, then went up to 170 mb, then 180 mb
@tulip wave
I'd assume it is that part of the code though
Why not eval it
Considering that is the only part I'd see that would use so much memory.
Does a eval use less memory?
or wait I am dumb
I mean use eval so you can see how much ram is being used
yes
i doubt the problem is that code, however you can greatly improve it by now executing all guilds at once, and spacing them out instead
180mb sounds normal for a discord.js bot
even at idle
my bot is using 300mb at idle
on idle
because python caches the loving god out of everything
its stabilised at 192mb
send a screenshot
of the ram usage
I don't think this is good for 93 servers on idle
lmao
350mb what kind of shitty ilb you using?
thats even worse than djs
jesus christ thats so bloated
i mean, so does djs
I don't even think there is a way to "uncache" everything
Python is shit
yes
deno >
but idk what is being cached the most
my 45 guild bot uses 50mb
its amazing
99% of discord libs caches everything
Client.fetch_offline_members = False
oh
lol
my 2.9k bot uses 400mb
yes
what the fuck
@tulip wave they wanted a screenshot of the ram usage
Also guild_subscriptions
@summer acorn https://redline-community.is-inside.me/QTqaWISK.png
ikr
36k members isn't all either
this server alone has 120k
that is just all that are cached when that gets logged
my bot has 360k members cached
so like, all the cached users upon startup
caching in discord is dumb, thats why i hacked the shit out of djs to remove it
https://peter.is-stinky.wtf/obsfbxgskn.png
Either I am an idiot
or it did nothing
this is 10s of uptime
lmao
Both peter
smh
170k+ users and 99mb
@opal plank log .rss
which is still a bit high
I dunno how to optimize
Well like, I need a way to do it without it taking like a billion mb memory
Apparently my 35 guild bot uses 400mb according to pm2
lmao
lol
*280mb
I mean like, imagine that bot in let's say 10k servers then
the memory is gonna explode
it will remember too much
@summer acorn you cant, not using regular discord.js, either you modify it yourself, or use an existing modification, or use a library that allows you to customize caching
ah, well in that case
use tims discord.js mod
my bot used to use 600mb ram at 3k servers before i modified it, now it uses 120mb
its good lol
hmm actually I was thinking
I'll try to edit discordjs to remove useless stuff & cache
Would using a json file and forEaching that instead, to get the guild id, use less memory?
just use this
and cache problem begone
@tight plinth you can take a look at ^ as inspiration if you wanna do it yourself
Yea that was my idea
wouldn't that just be like v11 codewise?
no
check both v2 and v3 repos, they approach the same problem in very different ways
oh, so you'd still have to use .cache?
v2 disables all events and uses the raw event, v3 hacks the events themselves instead
yes
yes
ok then
but channels are not cached by default
so you have to use channels.fetch() instead of channels.cache.get()
i removed most of those in v3 lmao
is this good to use?
better would be to make it yourself imo
looks alright quinten
Looks good
👍 imma use it
hi i have a question
if you use that
what do you do in index.js
like do you just remove the whole
yes because it’s a command handler
@tight plinth did you run something like Enmap? had it using about 1GB ram with 10 guilds
@lumap/commandhandler
or wait, this is about command handlers and not discord.js-light
ok I'll slowly back out
Use https://www.npmjs.com/package/@lumap/commandhandler
@tight plinth does it support folders too?
My command handler only works for one folder (a command folder with all commands inside) , but you can re use the code to make it support subfolders
ok
@summer acorn whats discord.js-light
scroll up
you can modifiy the package
Lumap check tester general again if u can lol
we were talking about it a couple minutes ago
:c
get a vps
I have

Get a server boi
But heroku give best ping
I got a 4gb vps
4gb isn’t low for a discord bot lol
Smhe
my pc finally booted, time to try to make my own discord.js
Your own discord.js?
4gb 4€
thats good price
ur brain capacity will fill up trying to understand the code @tight plinth
i mean, i'll try to edit discord.js to make it better
Oh ye good
my brain is empty lol
I might do that too
or just you know you can use discord.js-light

Explains why you are still active in this channel
lmao
yeah
i can explain if you have questions lmao
k
first thing to edit: the readme
wow i wish i knew about discord.js-light a week earlyer, then i had it used for a bot i recoded
rip
i think i will add it anyways, it adds some stuff that seems pretty usefull
congrats tim, you ar declaring things that you dont use https://lumap.is-inside.me/Y60eFTap.png
What's the diff between js and js-light?
also the 5 bots on my VPS already use about 1GB ram
it changes the caching behavior
its somewhere between V11 and V12
But then npm prune doesn't work 😄
same thing here https://lumap.is-inside.me/ojqzRvFh.png
should I switch to discord.js-light, I only got about 6 commands now
THAT URL
first time?
there's like a dozen of troll urls they created for the sake of the pun
Funnnn
@tight plinth fixed both lul
i add it now to a Private Bot i make for a Larger server im in. Lets see how it performs
noice
CPU usage drops to negative 70
dats big code
is there any open source bot using light yet?
i guess the Ram usage will get less, Currently i have 5 bots running on the same machine and they use about 5% CPU
Dibs on first :D
its more or less normal D.Js but with a few changes (atleast its what i get from the docs)
Oh
yes
btw v3 is not released yet, check the v2 branch for the current docs/readme
feel free to test v3 tho, its pretty much ready
Oooo
i guess the one on npmjs are the current docs right?
yes, the npm version is v2
maybe i open the repo for the bot im coding rn
:c
there is nothing special in it
H m
I’ll have to make a new repo when I go open source
for now ive got a reminder command
accidentally pushed my .env sometime
but you can repeat it infinitely
Js is cool :) uwu owo :DDDD X)
... i was wondering why the bot was not going online. Result: i forgot to connect to the VPN to get external access to the MongoDB
mongoliaDB
nice discord.js-light works out of the box with the new bot.
:o
it will work as long as you dont use .cache.get() on anything that isnt guilds lmao
imma switch to light 😄
Lol
I only have like 6 commands so it shouldn’t be a big deal
i throw it tomorrow on my bot with 40 commands and about 103 Guilds
if you have it in 100 guilds
did u apply for verified dev yet in discord
they just give the badge when u at 75 guilds if u apply until October or smth
no
i apply now bcs in october they probably get a really long query
october is for the 100 guild limit to start being applied
guys
they are now at almost 1 month
does anyone know how to get a .js file from another folder and require it at a certain part in a script
like:
require()
Does that require it at the SPOT
require('./folder/blabla.js');
^
or ../folder/bla.js if you want to go to the previous folder
and then you can export the functions in your required file
ok wait wait
if (command === "unban") {
let User = args[0];
let Reason = args.slice(1).join(` `);
if (!User) return msg.reply(`Who are we unbanning?`);
if (!Reason) Reason = `Unbanned by ${msg.author.tag}`;
if (msg.member.hasPermission("BAN_MEMBERS"))
return msg.rely(
"Only people with permission to ban members can use this"
);
msg.guild.fetchBans().then(bans => {
if (bans.some(u => User.includes(u.username))) {
let user = bans.find(user => user.username === User);
msg.guild.unban(user.id, Reason);
} else if (bans.some(u => User.includes(u.id))) {
msg.guild.unban(User, Reason);
} else {
return msg.reply(`This person is not banned`);
}
});
}```
my bot keeps on saying
member is not banned
//External File
console.log('haha yes')
//main file
console.log('The script in the external file would be executed below')
require("externalfile.js")
yes
however
the external file will be executed, but any declared function or variable will be lost if not explicitly exported
How do I make the bot to display server roles?
like this
the required file is not injected into the current scope like it happens in browser js
so basicly
put the script in the external file
in a function
and require it and then run the function
for example
@delicate shore you have a typo, and use lowerCamelCase
basicly a external module
//a.js
var a = 10;
//b.js
var b = 10;
module.exports = b;
//main
console.log(require("./a.js")) // undefined
console.log(require("./b.js")) // 10
console.log(a) // undefined
console.log(b) // undefined
How do I make the bot to display server roles?
like this
loop over guild.roles.cache
loop through them
client.on("message", message => {
if (message.content.startsWith(prefix + "serverroles")) {
const List = message.guild.roles.cache(e => e.toString()).join(" ");
const serverroles = new Discord.RichEmbed()
.setTitle("➠ server roles")
.setAuthor(message.guild.name, message.guild.iconURL)
.setColor("RANDOM")
.setDescription(List)
.setFooter(message.guild.name);
message.channel.send(serverroles);
}
});
@quartz kindle like this
cache is not a function, its a collection of roles
use .cache.map() to remap tem into a list of role names
and .name is probably better than .toString()
client.on("message", message => {
if (message.content.startsWith(prefix + "serverroles")) {
const List = message.guild.roles.cache.map(e => e.toString()).join(" ");
const serverroles = new Discord.RichEmbed()
.setTitle("➠ server roles")
.setAuthor(message.guild.toString, message.guild.iconURL)
.setColor("RANDOM")
.setDescription(List)
.setFooter(message.guild.toString);
message.channel.send(serverroles);
}
});
It is difficult, can you fix the mistake and send me the code please? @quartz kindle
he's not gonna do that lmaooo
he already told u what to do
how does one play music from spotify
I am already playing music from youtube
bruh
there is a npm module i think
can ya link it
look for either an api or libraries that do it
not sure which library i can use
search for spotify on npm
found it
I have a website, and to login to it u need to provide the username and password, but if u dont want to do that u can do /users/userid how can I make it not do that because then anyone can log into anyones account just by knowing their id.. any ideas? im using expressjs btw
https://www.npmjs.com/package/spotify 6 years ago :/
search for others
@digital ibex Assign a cookie once someone logs in
@delicate shore you have a typo, and use lowerCamelCase
@earnest phoenix what
where is typo?
check if the session (cookie) matches the ID of the user
oh
so I can dojs if (req.headers.cookie === user.id) { } and that'd stop them from being able to do that?
btw pls help me
this is gonna be hard for me to implement spotify :/
It wouldn't as they can just set the cookie to the user ID
if (command === "unban") {
let User = args[0];
let Reason = args.slice(1).join(` `);
if (!User) return msg.reply(`Who are we unbanning?`);
if (!Reason) Reason = `Unbanned by ${msg.author.tag}`;
if (msg.member.hasPermission("BAN_MEMBERS"))
return msg.rely(
"Only people with permission to ban members can use this"
);
msg.guild.fetchBans().then(bans => {
if (bans.some(u => User.includes(u.username))) {
let user = bans.find(user => user.username === User);
msg.guild.unban(user.id, Reason);
} else if (bans.some(u => User.includes(u.id))) {
msg.guild.unban(User, Reason);
} else {
return msg.reply(`This person is not banned`);
}
});
}```
this is my code
oh
my bot says member is not banned
you should create sessions for when somebody logs in and store them in a database, for example a session could look like this:
{sessionId: "SOME LONG UNIQUE STRING", userId: "some user ID"}
Then with the cookie you are gonna get the userId and compare em
hm, im confused now, the user id and the cookies aren't the same
the id is just numbers
hm, would I add session id's per visit or only use one?
You should create a session when a user logs in / registers
and everytime they do whatever, update the session id or add onto the session ids?
No, update the session ID only when they log out / login
For example...
User A logs into the website, a session is created for them {sessionId: "12345", userId: "their id or whatever"}
Now, when they go to a certain page and you need their profile, you could easily get the user who's logged in:
const session = await myDatabase.sessions.findOne({sessionId: req.cookies.sessionId});
const userProfile = await myDatabase.users.findOne({id: session.userId});
When user A logs out, the session's destroyed and a new one will be created when they log back in. You could make it so sessions expire after a certain time (for example, 5 days)
oh
i have never used webhooks . how to use them with python any guide?
so then i just do:js if (session === userProfile) { } and then done?
anyone help me
@delicate shore dont unban people for reason doesnt make sense
?
no, lol, what are you trying to do again
what
userProfile is the user that you fetch with the session user ID
why would u have a reason to unban
me?
Why would you compare them
why would u have a reason to unban
@spare mirage It can act as kind of warning
that u sure u wanna ban that kid
so
he has to give reason
so other people cant log into other peoples account
lol
haha no
The snippets I gave you already do this... There's no way a user can get someone else's sessionId
I'm not talking to you
brvh
@delicate shore dont expect everyone to help u
😦
You should look into making web apps and oauth flow instead of jumping straight into it
me?
Last thing you want is an insecure site due to lack of knowledge
ok
I kind abroke my bot
bruh
What's the issue
And what steps have you taken to resolve it
but he is
msg.guild.fetchBans().then(bans => {
if (bans.some(u => User.includes(u.username))) {
let user = bans.find(user => user.username === User); this is wrong
oh
Is User an array?
no
nope
Are you resolving the user by the name?
i always watch wrong tuotorials
Are you resolving the user by the name?
@strange trout id / name#tag
userid
so if u want to unban user ID ur command will be unban <@!userid>
You should do it by ID
@delicate shore do u use something like
let NAME = args[0]
i-
?
COMMAND HANDLER
how to use inline field in discord.js v11 cmd handler
eww v11 update to v12
lol
COMMAND HANDLER
@spare mirage i don't use it
breh
it took time for me
to update
how to use inline field in discord.js v11 cmd handler
@surreal notch
after that u fetch the bans @delicate shore
lol
N,ping
yes
-bots noembed
Izzy#2929's bots:
@narrow orbit
yes
then
i do
if (command === "unban") {
let User = args[0];
let Reason = args.slice(1).join(` `);
if (!User) return msg.reply(`Who are we unbanning?`);
if (!Reason) Reason = `Unbanned by ${msg.author.tag}`;
if (msg.member.hasPermission("BAN_MEMBERS"))
return msg.rely(
"Only people with permission to ban members can use this"
);
msg.guild.fetchBans().then(bans => {
if (bans.some(u => User.includes(u.username))) {
let user = bans.find(user => user.username === User);
msg.guild.unban(user.id, Reason);
} else if (bans.some(u => User.includes(u.id))) {
msg.guild.unban(User, Reason);
} else {
return msg.reply(`This person is not banned`);
}
});
}```
see i fetch
bans
WHY A REASOn
You tell to the member that you don't have permission if they have it
ok
so
if (command === "unban") {
let User = args[0];
let Reason = args.slice(1).join(` `);
if (!User) return msg.reply(`Who are we unbanning?`);
if (!Reason) Reason = `Unbanned by ${msg.author.tag}`;
if (msg.member.hasPermission("BAN_MEMBERS"))
return msg.rely(
"Only people with permission to ban members can use this"
);
msg.guild.fetchBans().then(bans => {
if (bans.some(u => User.includes(u.username))) {
let user = bans.find(user => user.username === User);
msg.guild.unban(user.id, Reason);
} else if (bans.some(u => User.includes(u.id))) {
msg.guild.unban(User);
} else {
return msg.reply(`This person is not banned`);
}
});
}```
?
Put a ! before msg.member.hasPermission("BAN_MEMBERS")
if (command === "unban") {
let User = args[0];
let Reason = args.slice(1).join(` `);
if (!User) return msg.reply(`Who are we unbanning?`);
if (!Reason) Reason = `Unbanned by ${msg.author.tag}`;
if (!msg.member.hasPermission("BAN_MEMBERS"))
return msg.rely(
"Only people with permission to ban members can use this"
);
msg.guild.fetchBans().then(bans => {
if (bans.some(u => User.includes(u.username))) {
let user = bans.find(user => user.username === User);
msg.guild.unban(user.id);
} else if (bans.some(u => User.includes(u.id))) {
msg.guild.unban(User);
} else {
return msg.reply(`This person is not banned`);
}
});
}```
@spare mirage now?
but
where is user.id
like
i already have id
in user
Change msg.rely() to
msg.reply()
so do i need it
return msg.reply("Only people with permission to ban members can use this"
)};```
shouldnt it be this
Just when you click on VOTE button on a bot, it will show a login hyperlink... Click on it then authorize
Screenshot?
I can't vote on a bot, it won't let me
@earnest phoenix
Login
With top right
If you on pc
Mobile sucks
@delicate shore if there are no bans u should return or it will break
so?
Also are you trying to unban by ID or by username?
ID
Doesn't seems to be
and he gave up
¯_(ツ)_/¯
@earnest phoenix do u know why this is not workking?
bot.commands = new Discord.Collection();
bot.aliases = new Discord.Collection();
const modules = ['fun','moderation','others'];
const fs = require('fs');
modules.forEach(c => {
fs.readdir(`./commands/${c}/`, (err, files) => {
if (err) throw err;
console.log(`[Commandlogs] Loaded ${files.length} commands of module ${c}`);
files.forEach(f => {
const props = require(`./commands/${c}/${f}`);
console.log(props)
bot.commands.set(props.name, props);
props.conf.aliases.forEach(alias => {
bot.aliases.set(alias, props.name);
});
});
});
});```
@spare mirage error?
define "not working"
ok

you moved the require line outside of the forEach lol
@spare mirage Shift + Alt + F will format your code in visual studio code
might need to highlight first
@spare mirage lemme tell u a secret:
yeah
did you just leak your token lmao
lul
Ahahhaha

also, one of your commands doesnt have a .conf property
?
cannot read property aliases of undefined
meaning you're trying to read aliases from undefined, meaning conf is undefined
ie: prop.conf doesnt exist
you need to open your commands and see
args is not defined
props.conf.aliases.forEach(alias => { what do I change @quartz kindle
cannot read 1 of undefined meaning you're trying to read 1 from undefined, meaning args is undefined
:0
@spare mirage you need to open your commands and see
ok
const discord = require("discord.js");
module.exports = {
name: "ban",
category: "moderation",
description: "Ban anyone with one shot whithout knowing anyone xD",
usage: "ban <@user> <reason>",
execute(bot, message, args) {
if(!message.member.hasPermission("BAN_MEMBERS" || "ADMINISTARTOR")) {
return message.channel.send(`**${message.author.username}**, You do not have perms to ban someone`)
}
if(!message.guild.me.hasPermission("BAN_MEMBERS")) {
return message.channel.send(`**${message.author.username}**, I am do not have perms to ban someone`)
}
const target = message.mentions.members.first();
if(!target) {
return message.channel.send(`**${message.author.username}**, Please mention the person who you want to ban.`)
}
if(target.id === message.author.id) {
return message.channel.send(`**${message.author.username}**, You can not ban yourself!`)
}
if(!args[1]) {
return message.channel.send(`**${message.author.username}**, Please Give Reason To ban Member`)
}
let embed = new discord.MessageEmbed()
.setTitle("Action : Ban")
.setDescription(`:white_check_mark: Banned ${target} (${target.id})`)
.addField("Reason : " + args.splice(1).join(" "), `Good Job ${message.author.tag} u get a banana :banana:`, true)
.setColor("#ff2050")
.setThumbnail(target.avatarURL)
.setFooter(`Banned by ${message.author.tag}`);
message.channel.send(embed)
target.ban(args[1])
}
}``` is there something wrong here?
you have name, category, description, usage and execute, but you dont have any conf
yes
so I make it conf:
whatever you want
how i can fix this
prop is the required file, meaning prop contains those you write there
if you want to access prop.conf, you need to have a conf there to give it something to read
src = 'prop.conf' ?
you dont need to pass arguments to setTimeout
just do setTimeout(() => {
but i wanted to edit the message that i sended
Anyone got some documentations/source code of a command handler working with classes? I want to try to learn it my friend told me classes is much better then objects
store the message you send in a value
you already have the message
a command handler hurts my brain
oh
const message = channel.message.send()
if you add arguments to the setTimeout you are overriding the variables you already have with the same name
with empty ones
so dont pass anything to setTimeout, and let it use the existing variables that exist outside
@spare mirage ```js
module.exports = {
bla:1,
bla2:2,
bla3:3
}
// main file
prop = require(path/to/file.js)
prop.bla // 1
prop.bla2 // 2
prop.bla3 // 3
No one has documentions of a command handler working with classes?
nop
Hi,
I'm currently tyring to use spotify-url-info and i wanted to ask how i get the things that it returns
@tulip ledge honestly using classes for a command handler is a waste
module.exports = {
bla:1,
bla2:2,
bla3:3
}
// main file
prop = require(path/to/file.js)
prop.bla // 1
prop.bla2 // 2
prop.bla3 // 3
what does this even mean
Tim
Do you know anything about command hanlders with classes?
Oh u tagged me I see
i wouldnt use classes for a command handler
@quartz kindle are there easier command handlers that automatically execute?
My friend said it's way more efficient
And you can apparently change stuff using bot commands like changing enabled to false without having to go into the files and change it yourself and restarting the bot
like multiple commands that are very similar
Man this bot is good https://i.alhassan.best/u/MC9v0jzyF4.png
Yeah I don't need that
is that bot opensource
I would like to learn more about classes tho
js classes?
you can do something like this for starters ```js
module.exports = class MyCommand {
execute(message) {
message.send("bla")
}
}
ik how to make http requests lmao
Oh
And the handler is just the same
It's just the files that are changed?
If u get what I mean
the difference is that you need to initialize it with the new keyword
I made a bot from my mobile
Oh yeah
!!!
Ok?
Is class used for constructing constructors?
But is there a way to like change values in the module.exports without needing classes?
classes are good for creating a blueprint that gets reused every time
Ah
Since I want to be able to disable commands when I'm on my phone etc
Thats the main reason I wanted to use classes
@tulip ledge yea
module.exports = class MyCommand {
execute(message) {
message.send("bla")
}
}
@quartz kindle
wont u need
if
else if
else if
shit for that?
N-
What?
you dont need if else walls for anything
you dont need that now with your command handler
not even in without classes
elif
to execute the commandname.js files??!??!
From py(?)
yeah
No lol?
Ok ok ok
get the command with the name(dynamically)
You can just run the files when they're called?
then run them
Like Woo said
Wouldn't it be cool if
?
But is there a way to like change values in the module.exports without needing classes?
You had one handler statement
So I can do like -disable <command>
And it got args[0] and ran it?
And it changed it
imma ge tback my old handler
@tulip ledge
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles){
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.once('ready', () => {
console.log('Codelyon is online!');
});
client.on('message', message =>{
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if(command === 'ping'){
client.commands.get('ping').execute(message, args);
}
});``` how do I iprove this
Learn js
bruh
¯\_(ツ)_/¯
- Get an event handler
- Fix your command handler
@spare mirage i believe i told you before, that you can replace the entire if else wall of text wth a simple check if command exists
"simple" is different
Why can't we just do client.commands.get(args[0])
You literally check if it exists
Ultra dynamic
Some people splice their command from their args meaning args[0] would be the 2nd thing given in the message @pure lion
Ah
which i think is the better way to do it
Well I'm gonna go do that :D
const command = args.shift().toLowerCase(); here he shifts it meaning the first index is removed from the original args array
client.commands.get(command) what?
if(client.commands.get(command)) //code
you defined your command Name as command
@spare mirage Please just learn js
🤔
It's really simple javascript
ima go make lunch, gl
I learned js in a relatively short period of time
No
People who have coding in schools are so lucky we don't have any software development its so annoying
Learn now
People who have coding in schools are so lucky we don't have any software development its so annoying
@tulip ledge ikr
Then you can fix it
ive been using js for months now, and i dont consider myself very knowledgeable about it.
I still learn a small quirk or two a day
People who have coding in schools are so lucky we don't have any software development its so annoying
I literally started coding 1/2 months ago :DddDddDDDdDdDDDDddDDDDD school is shit
@spare mirage imagine yu have a list, like this [1,2,3,4,5,6,7,8,9]
you dont need to do if(list.includes(1)) { return 1 } else if(list.includes(2)) { return 2 } you can just do return list.find(1) directly
I started learning it 4 years ago but haven't really done alot since like a year or 2 and I'm pretty bad at it
its the same principle with commands
ok
Can someone gimme a js test idk what "level" I'm at
