#development
1 messages ยท Page 993 of 1
@small prairie
thanks.
@tawny obsidian
```discord.js when?```
db.prepare(`CREATE TABLE IF NOT EXISTS ${options.table} (ID TEXT, json TEXT)`).run();
^error
var disabledSnipeDB = new db.table('Snipe-Blacklist-Table')
disabledSnipeDB.set('Guild-ID\'S', 1)
console.log(disabledSnipeDB.get('Guild-ID\'S'))
^code
help is appreciated
id = id
token = key
const WebBlock = new Discord.WebhookClient("id web", "key web")
WebBlock.send(...)```
runwhat?
i think the link i gave shows how to make a table
i put that into the code tho
My database and VPS runs on separate CPU. Which CPU should I upgrade if database write requests are lagging?
if this helps
Hi, can anyone help me?
i have no idea dice 
@earnest phoenix first find the cause of the issue, its possible that the problem is not related to resource usage
\๐ข
if your two VPS's are not at the same location, it might be just latency 
Level in leaderboard and rank card is not updated :v
I using quick.db
ooo
tell me how to quickdb
dice someone who can help ya
and i will help you
@pure lion show full error
let xp = db.add(`xp_${message.author.id}`, 1); let level = Math.floor(0.1 * Math.sqrt(xp)); let lvl = db.get(`level_${message.author.id}`) || db.set(`level_${message.author.id}`,1);; if (level > lvl) { let newLevel = db.set(`level_${message.author.id}`,level); if(message.guild.id !== "264445053596991498") { message.channel.send(`๐ ${message.author.toString()}, You just advanced to level ${newLevel}!`); } }
My code for xp system :v
C:\Users\(REDACTED)\Desktop\qBot\node_modules\quick.db\bin\handler.js:240
db.prepare(`CREATE TABLE IF NOT EXISTS ${options.table} (ID TEXT, json TEXT)`).run();
^
SqliteError: near "-": syntax error
at arbitrate (C:\Users\(REDACTED)\Desktop\qBot\node_modules\quick.db\bin\handler.js:240:6)
at table.set (C:\Users\(REDACTED)\Desktop\qBot\node_modules\quick.db\bin\handler.js:184:14)
at Object.<anonymous> (C:\Users\(REDACTED)\Desktop\qBot\index.js:91:17)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
@plucky heart ok cool but how do you make tables that work
sounds like table names with dashes are not supported
balls
lol
sqlite does not support prepared statements for table names, so the name is being injected as a string, which causes sqlite to think you're doing math with them
epicccccc
just use underlines
:feelssdiftghoeuhisgrtingman:
yes, i am sdiftghoeuhisgrting indeed
@plucky heart show code for rank card and leaderboard
let level = db.get(`level_${user1.id}`) || 0;
level = level.toString();
let exp = db.get(`xp_${user1.id}`) || 0;
let neededXP = Math.floor(Math.pow(level / 0.1, 2))
let every = db
.all()
.filter(i => i.ID.startsWith("xp_"))
.sort((a, b) => b.data - a.data);
let rank = every.map(x => x.ID).indexOf(`xp_${user1.id}`) + 1;
rank = rank.toString();
let img = await canva.rank({
username: user1.user.username,
discrim: user1.user.discriminator,
currentXP: exp.toString(),
neededXP: neededXP.toString(),
rank,
level,
background:"https://i1.wp.com/static.web-backgrounds.net/uploads/2012/08/City_Landscape_Background.jpg",
overlay: false,
avatarURL: user1.user.displayAvatarURL({format: "png"})
});
return message.channel.send(new Discord.MessageAttachment(img, "rank.png"));```
rank card
let data = db.all().filter(i => i.ID.startsWith(`xp_`)).sort((a, b) => b.data - a.data); if(data.length < 1) return message.channel.send("No leaderboard!") let myrank = data.map(m => m.ID).indexOf(`xp_${message.author.id}`) + 1 || "N/A"; data.length = 10; let lb = []; for (let i in data) { let id = data[i].ID.split("_")[1]; let user = await Client.users.fetch(id); user = user ? user.tag : "Unknown User#0000"; let rank = data.indexOf(data[i]) + 1; let level = db.get(`level_${id}`); let xp = data[i].data; let xpreq = Math.floor(Math.pow(level /0.1, 2)); lb.push({ user: { id, tag: user }, rank, level, xp, xpreq }); }; const embed = new Discord.MessageEmbed() .setTitle("Leaderboard") .setColor("RANDOM") lb.forEach(d => { embed.addField(`${d.rank}. ${d.user.tag}`, `**Level** - ${d.level}\n **XP** - ${d.xp} / ${d.xpreq}`, true); }); embed.setFooter(`Your Position: ${myrank}`); return message.channel.send(embed)
leaderboard
@solemn latch my 2 VPSs are both from Singapore
the latency can not be too high right?
where does the high latency happen?
does it happen when you run a command?
is the high latency actually from writing to the database or is it from sending sending/receiving a message from discord?
you can run a timer in your database write function to see how long it takes to write
https://oliy.is-just-a.dev/330efi_4805.png I'm confused as to what this would ever accomplish
its there for you to take a deep breath and practice tolerance and compassion
I mean all it would end up doing is causing an error if, for whatever reason, message.member was undefined.
Level in leaderboard and rank card is not updated :v
I using quick.db
please help
@amber fractal what are you trying to do/stop being rude to the Dev who wrote that
I'm saying that it would error and should be fixed
But if you think that it was rude, then let it error in production
I couldn't care less.
how do i find out how many guilds my bot is in and set it as the status
depends on your library 
lib?
js
did you type
npm i discord.js
OR
npm i eris
or
ok
won't set it as status tho
Tim, the latency only happens at writing. I know that because sometimes when reading, the database needs a few seconds to update properly.
reads are often cached, maybe your database has a really bad drive write?
try describing a write query
could be many reasons, network having issues, the connection pool being reset or a new connection being slow to connect, etc...
since they are both in different machines, i would blame the network before blaming the cpu or the disk, unless you have a huge workload
which database is it btw?
MongoDB atlas
i use atlas because i need to access the same data from many places
will do thanks
Iโm still on a shared cluster tho, does that mean I need to upgrade to a M10+ dedicated cluster?
is the profiler not available on the shared cluster?
if not, you could also try this https://docs.mongodb.com/manual/tutorial/manage-the-database-profiler/
not sure if it works for a remote db tho
Can someone help my bot wont go on. this is discord.js heres my index.js ```const Discord = require('discord.js');
const { prefix, token } = require('./config.json');
const client = new Discord.Client();
client.once('ready', () => {
console.log ("Ready!")
})
client.on('message', message => {
//console.log(message.content);
if(message.content.startWith(`${prefix}kick`)) {
message.channel.send("Kick")
}
})
client.login(token)```
whats your error?
when you run it?

ready means its on
what happens when you do the command
uncomment the console.log(message.content)
wdym
turn //console.log(message.content);
to
console.log(message.content);
what errors
from doing that
if(message.content.startWith(`${prefix}kick`)) {
^
TypeError: message.content.startWith is not a function
at Client.<anonymous> (C:\Users\12138\code\CraftyBot\index.js:12:24)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (C:\Users\12138\code\CraftyBot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Users\12138\code\CraftyBot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\12138\code\CraftyBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
at WebSocketShard.onPacket (C:\Users\12138\code\CraftyBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
at WebSocketShard.onMessage (C:\Users\12138\code\CraftyBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
at WebSocket.onMessage (C:\Users\12138\code\CraftyBot\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
at Receiver.receiverOnMessage (C:\Users\12138\code\CraftyBot\node_modules\ws\lib\websocket.js:800:20)```
what
Its startsWith()
wherer
in the one spot it could be
startsWith() doesnt have that
startWith()
doesnt exist,
startsWith() does
ohh
ok
I didnt see ur s
in starts
I only saw start
FACE PALM
thanks
I PUT IN THE WRONG TOKEN FOR WRONG BOT
UGH
what err
hmhmh
internal/modules/cjs/loader.js:1175
throw err;
^
SyntaxError: C:\Users\12138\code\CraftyBot\config.json: Unexpected end of JSON input
at parse (<anonymous>)
at Object.Module._extensions..json (internal/modules/cjs/loader.js:1172:22)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\12138\code\CraftyBot\index.js:2:27)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
PS C:\Users\12138\code\CraftyBot>```
wot
im confused
"prefix": "!",
"token": ""
}```
thats my config
can u show me whats suppose to look like?
cause im confused
did you save it?
then y is there errors?
make sure its saved
ya
I fixed it
Seems like I copied and paste it weird
Its up and running
Thanks for the help guys
https://hasteb.in/adisutem.js
it does the role menu but then it crashes and gives me this error at Function.Module._load (internal/modules/cjs/loader.js:879:14)
(node:1704) UnhandledPromiseRejectionWarning: OverwriteModelError: Cannot overwrite ReactionRole model
well tbh i was going to post a github repo that i have just posted that has some features that u cant really find so i will put it here
it just has things that people can learn from or use https://github.com/ark-maker-bot/open-source-discord-bot
like custom welcome channels and custom welcome messages and it open source if anyone wants to use it
tag me if u want any help or u want it removed
This is a discord bot that is open source and has working guild.id based greet channels and greet messages. If you use this please credit me, thank you - ark-maker-bot/open-source-discord-bot
i aint promoting
this is purely for people to use
just so u know admins
honestly, tim probably would know @hardy vector 
lmao
that is 100% promotion 
^
nah
just because you say it isnt, doesnt make it not
@quartz kindle do you know how to fix my mongo issue
no like i am being serious i did it for my own learning and its open source and it has the custom server welcome channel and welcome messages and i cant find any tutorials for that
so if people wanted that
there it is
someone woulda asked 
oh well there it is

i asked people and they didnt know
so i came up with a way
so i thought i would post it
Does anyone know if there is something wrong with pinging between glitch and uptimerobot?
that was disabled by glitch
yh
i dont think they posted an update for the situation nor a est date for it to be enabled again
i think they decided to perma disable it
That would screw me over
its kinda abuse of their systems
heroku still works i think
but that will also very likly go the same route
of disabling
yh most likely
you can get a VPS for like $35 a year, or like $3 a month
thatll run multiple small bots no issue
Yes .. But in my country .. The dollar issue .. uff
i got a nice home server, but i dont use it for anything really
:/ xd
i got a nice home server, but i dont use it for anything really
@solemn latch same
yeah
yeah
just some old pc parts, was a high end desktop at one point
ohhh
my dad works in a server room
gets old equipment from time to time

huge lmao
Wait wia twait
wia twait
wia twait
what?
How do I set a bots status. Discord.js Do i like make a new file or put it in index.js?
docs
kk
or wait gimme a sec
I dont see it in the docs
client.user.setActivity(status in here)
What
give me your code.
kk
const { prefix, token } = require('./config.json');
const client = new Discord.Client();
client.once('ready', () => {
console.log ("Ready!")
})
client.on('message', message => {
//console.log(message.content);
if(message.content.startsWith(`${prefix}ra`)) {
message.channel.send("Never gonna give you up!")
}
})
client.login(token);```
he said to look in the docs, and in under 60 seconds you didnt find it
i just searched my code
i have d.py documentation in a bookmark, if i need to find smth i can find it pretty quickly
client.once('ready', () => {
console.log ("Ready!")
client.user.setActivity("Activity goes here")
})```
const Discord = require('discord.js');
const { prefix, token } = require('./config.json');
const client = new Discord.Client();
client.once('ready', () => {
console.log ("Ready!")
client.user.setActivity("Activity goes here")
})
client.on('message', message => {
//console.log(message.content);
if(message.content.startsWith(`${prefix}ra`)) {
message.channel.send("Never gonna give you up!")
}
})
client.login(token);```
try it and see 
restart your bot and check
start the bot 
there's some documentation on .setActivity
client.user.setActivity(WATER | Prefix !)
^^^^^^
SyntaxError: missing ) after argument list
at wrapSafe (internal/modules/cjs/loader.js:1054:16)
at Module._compile (internal/modules/cjs/loader.js:1102:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47```
ERROR
gotta be a string
You need to put it in "", '' or ``
it has to have quotation marks
Im dumb
Ya ik
it works
@cerulean lakeBot
@austere bronze
How do you make commands non case sensitive? Discord.js
I searched but didnt work
you can just turn the whole message.content to lowercase and make the commands lowercase
.toLowerCase
how so
i think this would help you a ton
What are JavaScript Properties and Methods | Properties and Methods | JavaScript Tutorial. In this JavaScript tutorial you will learn about properties and methods used on JavaScript objects. Examples of objects include variables and arrays, which are used often in JavaScript s...
?
this isnt helping me
with the lower case and upper case
non senitivity caps\
.toLowerCase()
is a property
Ya BUT wHEre do I pUT it
yikes, method*
yikes
the video explains how to use properties and methods
so when someone says .toLowerCase()
you know exactly where it goes
It's a string function string.toLowerCase()
"AAAAAA".toLowerCase() == "aaaaaa"
Basically yes
so if your user types !cOmmAnd it will turn it into !command
^
^^^
<<<

i hate how people don't apricate resources to help them learn how to not ask the same questions all the time
How to i resolve this error?
Does anyone know a decent tutorial or something for using separate files for commands, i've never really done it before and i tried it yesterday and all i kept getting was "can't use args before initialization" or something :/
Discordjs?
Yeah
The discordjs guide command handler is a great tutorial
By a milisecond
i was waiting if you were gonna send it
and you didnt
then you sent it almost the same time mmlol
I believe that was nearly exactly how i was doing it but i was getting the "args" error thing, can't access before initialization
I assume i did it slightly wrong so i'll read through the website
Args need to be defined in your index file, and passed on in the execute
Or doesn't need to be, thats just how this specific handler does it
Is there a way to just have the entirety of my play functions in a separate file? Or should i just do it the way i was going to and just have all the music code in index and have all the other commands in separate files?
Everything can be done through the command handler(seperate files)
So i can have many commands in a single command handler file
File or folder?
Yeah i assume that isn't possible to have?
I'd have to have a separate file for every command?
You can have files or a file
But i could just organise into one folder
You can do it either way.
All the command handlers I know of are seperate files for each command.
All in one folder
I used to do one file per command category.
Okay i'll just do it that way then, it's just easier than messing about trying to do it a different way
External and internal command handlers are just as easy as one another.
I know how to have 1 command per file so for now i'll just stick to that and possibly change it when i add more commands
Whatever works for you, just stick to that.
what lang
im not sure if it works that way like in python, but im guessing that x became a pointer to y
That's because you're not copying the object, but getting the reference to it
so my theory is right
So X equals to Y, and Y equals to X
You need to create another array and add the values of Y
Else they'll represent the same object
x basically is now a pointer to y, any changes to x will reflect on y and vice versa
I still dont understand how to make command non case sentitive for discord.js
const { prefix, token } = require('./config.json');
const client = new Discord.Client();
client.once('ready', () => {
console.log ("Ready!")
client.user.setActivity("WATER | Prefix !")
})
client.on('message', message => {
//console.log(message.content);
if(message.content.startsWith(`${prefix}invite`)) {
message.channel.send("**INVITE BOT LINK**")
message.channel.send("de")
}
})
client.login(token);```
index.js
String.toLowerCase()
Hm
after a string.
whats string
sigh
user message
The one you want to be lower case
I cant do that for you
No spoonfeed
y
^
im NOT SAYING THAT RE
You are
boi
I gave you a fantastic video that explains how to use methods

can u edit my index.js to show me
You should hire a teacher, but i doubt a hired teacher will edit your code for you
They will just teach you how to use properties and apply them 
there should literally be a recurring spam in this chat from a bot
telling people they have to learn how to code
its the development version of "when will my bot be accepted"
if you don't think learning syntax is fun and generating "hello world" then programming probably isn't a passion for you
how can i put a 5s cooldown on slots?
if message content includes help and message content includes pls then send codecademy link
slots?
yes
in the economy
because you cand spam with slots and it can produce bot lag
js
Agreed @maiden mauve .
Thats the fun stuff
discord.js
This guide expects you have a command handler, you might have to change some stuff.
https://discordjs.guide/command-handling/adding-features.html#cooldowns
ok thx
Lol
As much as I support learning on your own
I love having professional friends to help
friend helped me with Heroku being retarded
essentially Heroku needed to be force fed new mongo and node
hi
.setDescription(stripIndents`Gamemode: ${gametype.slice(1, 2).toUpperCase() + gametype.slice(2)}`)
i got this from somewhere
but it doesnt work properly
so can someone tell me what it means
cuz im dumb and srsly dont understand
gametype = args[2]``` btw
lol
that code is literal shit
like fr it looks as if someone took a big fat dump on that code
lol
what does it even do
tell me what it means
its supposed to
wait
why
wtf
its supposed to print the args[2]
why is it like this
lol
can you convert a date string (2020-06-26) to an actual js date object
whats the context, whats the function, why is there a random stripIndents at the beginning of that string
@sick cloud new Date(year,month,day) I believe
i got it from github
if that doesnt work, use moment
whatever.execute
whatever doesn't exist so excute doesn't exist
and js doesnt like that
๐ค
my sorting is madly broken
how can i fix it
its supposed to show oldest at the top
split by the date by "/" and arrange the middle array by number
if (props.sortBy === sorting.DATE_CREATED_NEWEST) gameList.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
if (props.sortBy === sorting.DATE_CREATED_OLDEST) gameList.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime()).reverse();
that's what i'm doing rn
using the date
it can be in any year month or day
i'm wondering is it possible pull guild data instead of running the bot using python?
data like guild members, roles, channels(guilds that bot app in)
for the web dashboard i need bot data
look into oauth2
if (props.sortBy === sorting.DATE_CREATED_NEWEST) gameList = gameList.sort((a, b) => b.createdAt - a.createdAt);
i have zero idea why it won't sort
but i think i have to keep the bot running in loop but i don't want to do that

oauth2 doesn't require a bot at all
oh
i misread
i thought you wanted to pull data from certain users
data like guild members, roles, channels
guild members no, you'll have to use the gateway for that
for everything else you can using REST
however that can be very expensive and you can ratelimit yourself really quickly
so it's just suggested you pull data from the gateway
actually members not needed. i used it for example. i want pull only roles, channels
CAN SOMEONE HELP?
have you tried reading the error
mhm
i cant find anything wrong
it's a syntax error
yeah @wet osprey totally possible then, but beware of the ratelimits
give me a minute and i'll send you doc links
ok
@earnest phoenix where do i fix the syntax error?
to get roles you can use this endpoint
https://discord.com/developers/docs/resources/guild#get-guild
to get channels use this one
https://discord.com/developers/docs/resources/guild#get-guild-channels
@earnest phoenix where do i fix the syntax error?
@earnest phoenix
it tells you right there in the error
ive put in my bots token though-
@earnest phoenix why did u download a premade bot
i had help with it
https://discord.com/api/v6/guilds/{guild.id}/channel ? like this? what is headers i should use? i know gateway headers but idk anything about this?
headers?
the only header needed is the Authorization header
i had help with it
@earnest phoenix idrk what you just said but dont fricking downloaded premade bots it just means ur trash
Bot <token> should be the value of it
but once again i'm warning you of ratelimiting, you should probably handle those
@earnest phoenix idrk what you just said but dont fricking downloaded premade bots it just means ur trash
@pine sage i paid someone to custom make it
but once again i'm warning you of ratelimiting, you should probably handle those
@earnest phoenix waht is the limit?
@pine sage i paid someone to custom make it
@earnest phoenix oh boy he didnt make that
there isn't a set in stone one
ratelimits are dynamic
returned in the headers of the request
@earnest phoenix oh boy he didnt make that
@pine sage oh
still, how do i fix it?
see https://discord.com/developers/docs/topics/rate-limits#rate-limits for more about ratelimits
ok
@earnest phoenix put your index.js on https://hastebin.com so its much easier
read the error
SyntaxError: Invalid or unexpected token
at wrapSafe (internal/modules/cjs/loader.js:1054:16)
at Module._compile (internal/modules/cjs/loader.js:1102:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at /Users/bronwenblack/Downloads/dippy/index.js:11:19
at Array.forEach (<anonymous>)
at /Users/bronwenblack/Downloads/dippy/index.js:10:9
npm ERR! code ELIFECYCLE
@earnest phoenix bro follow what i fucking said
@earnest phoenix put your index.js on https://hastebin.com so its much easier
@pine sage do u fuxking understand this
?????????????
it's a syntax error, they're perfectly capable of identifying the error themselves
i've never worked with them before
do you understand what a syntax error is
read the stack
put ur index.js here https://hastebin.com so i can check ur index.js
const Enmap = require("enmap");
const fs = require("fs");
const modules = "./modules/";
const Discord = require("discord.js");
const config = require("./config.json");
const client = new Discord.Client();
client.login(config.token);
fs.readdir("./events/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
const event = require(./events/${file});
let eventName = file.split(".")[0];
client.on(eventName, event.bind(null, client));
});
});
client.commands = new Enmap();
client.aliases = new Enmap();
fs.readdirSync(modules).forEach(file => {
fs.readdir(./modules/${file}/, (err, files) => {
if (err) return console.error(err);
let jsFile = files.filter(f => f.split(".").pop() === "js");
if (jsFile.length <= 0) {
return console.log("Couldn't find any commands.");
}
jsFile.forEach(f => {
let pull = require(./modules/${file}/${f});
client.commands.set(pull.data.name, pull);
pull.data.aliases.forEach(alias => {
client.aliases.set(alias, pull.data.name);
});
});
});
});
submit a bot and wait for it to get verified @lethal pine
and holy shit don't paste blocks of code here
lol
submit a bot and wait for it to get verified @lethal pine
@earnest phoenix thankx bro
omg

they're most likely underage
they're not dumb
im illiterate xd
they just don't understand
i have bad temper sorry
its allg
a syntax error
you're not closing your if statement
yikes
therefore, unexpected
see https://discord.com/developers/docs/topics/rate-limits#rate-limits for more about ratelimits
@earnest phoenix rate limit is not returned in headers other than that everything working fine
ive sent the link, what now?
@pine sage ?
what
whats wrong with the code?
you still aren't closing your if statement
they definitely did not understand a single word
you still aren't closing your if statement
@earnest phoenix where me not getting it
how do i use nekobot API in my bot?
this is my current code:
no u
jkmy bot has 780 lins of code
that should work
i get it
lol
now you aren't closing your catch
why you using it on catch block
else works on if statements obviously
and they are using it on an if statement
f(command === "kick") {
if (msg.member.hasPermission("KICK_MEMBERS")) {
if (msg.members.mentions.first()) {
try {
msg.members.mentions.first().kick();
} catch {
msg.reply("I do not have permissions to kick " + msg.members.mentions.first());
}else {
msg.reply("You do not have permissions to kick " + msg.members.mentions.first());
}
}
yeah inside the catch block
edit this pla
no
and that try catch won't do anything since kick is a promise
they didn't close the catch
@delicate shore since you are on glitch, click the { parenthesis on your if statement and it will highlight the one where it is ending. Put your else statement there
should've used .catch or await it

wait are you telling me like C# you can use try () catch {}
In js also you can use try catch
teach me lol
thats what i said....

lemme fix your code
dm me
da code
@delicate shore which help
do not spoonfeed them lol
guide them to the fix
Do always ask2ask
yeah
thats what i was gonna say...
a friend said pommss broke, whats that?
can anyone help more
i just figured outthe try catch thingy, now can someone tell me the syntax
@delicate shore @_@
First ask
can anyone help more
@delicate shore if you dont want us to spoonfeed you
where { closes?
@delicate shore click it glitch will highlight
the } where it ends
so you haven't closed it
@delicate shore it is alredy closed read the baractes
Open close open close
Like this
how to get early supporter badge
It happens when you copy paste the code
@earnest phoenix no
@lethal pine this not development topic
sad
Go #general
can someone tell me the syntax of try catch
cuz my community would panic if it goes down because of an error (lies)
Try { your code}.catch(err =>{console.log(err)})
๐ค
how to get early supporter badge
@lethal pine
you cannot anymore, people who got nitro back when it was introduced have it
can someone tell me the syntax of try catch
@earnest phoenix
for synchronous code and async/await pattern see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch
for promise pattern see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch

const fs = require("fs");
const modules = "./modules/";
const Discord = require("discord.js");
const config = require("./config.json");
const client = new Discord.Client();
client.login(config.token);
fs.readdir("./events/", (err, files) => {
if (err) return console.error(err);
files.forEach(file => {
const event = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, event.bind(null, client));
});
});
client.commands = new Enmap();
client.aliases = new Enmap();
fs.readdirSync(modules).forEach(file => {
fs.readdir(`./modules/${file}/`, (err, files) => {
if (err) return console.error(err);
let jsFile = files.filter(f => f.split(".").pop() === "js");
if (jsFile.length <= 0) {
return console.log("Couldn't find any commands.");
}
jsFile.forEach(f => {
let pull = require(`./modules/${file}/${f}`);
client.commands.set(pull.data.name, pull);
pull.data.aliases.forEach(alias => {
client.aliases.set(alias, pull.data.name);
});
});
});
});```
ive tried fixing it and it still doesnt work
it said something about pomsss@2.0.3
how to check if someone voted and reward them
goto #topgg-api
why me minimodding
lol
whats pomsss@2.0.3
nothing comes up
why can't it read mentions
@delicate shore its supposed to be msg.GUILD.members.mentions.first()
yep
ok
imma steal your code hehehehhehehhe
no it was right
@earnest phoenix
remove guild
it cannot read members
and it's mentions first and then members
wait what
mentions is a property for message
so the thingy i saw on youtube was for a REALLY old version of discord.js
mentions stores members
docs make my head go crazy
its the only reliable source you should go for
tf avast says discord.guide is safe to use but many people gave it a thumbs down cause they dont trust it
specially when you start going into libraries that arent popular and dont have tutorials for
its a good practice to get used to docs
what is the emoji for the red cross thingy
@pale vessel should i remove GUILD?
yeah
removing it won't fix it
msg.mentions.users.first() he said right
users?
that'll return user
members if you need those instead
not member
why will you kick bots
\โ
wait its already escaped
and my bot cant use custom emojis unless he is in here
it cannot read mentions
which version of d.js you using?
dj
hey don't look at his private stuff
lemme use my eval rq
imma go stalk em on glitch
message.mentions.members.first()
that is what i use
what\
BRO MESSAGE AND MSG ARE DIFFERENT THINGYS
YOU DEFINED MSG AND YOU USING MESSAGE
WHY ME YELLING
alright turned off caps
yes
where?
hastebin
if(command === "kick") {
if (msg.member.hasPermission("KICK_MEMBERS")) {
if (msg.mentions.members.first()) {
try {msg.mentions.members.first().kick();}
catch {msg.reply("I do not have permissions to kick " + msg.mentions.members.first());}}
else {
msg.reply("You do not have permissions to kick " + msg.mentions.members.first());
}
} };
his code
i copied form glitch
let msg = message
np
can i copy your code under the MIT license
that code is so simple i'd argue you cant even claim ownership of it
that he was kicked
@delicate shore because you are using else on catch lmao you put the message.channel.send("kicked em") INSIDE THE TRY BLOCK!!!
bro my head's gonna explode
i fixed his code
@delicate shore because you are using else on catch lmao you put the message.channel.send("kicked em") INSIDE THE TRY BLOCK!!!
@earnest phoenix ??
guys, someone have worked with the google-translate-api?
i did use the cloud api for some time
yeah, well i'm trying to do the same for my bot.
though i moved to translate-api package
@delicate shore else {} doesn't work on catch so your bot sends the kick message when the kick command gets an error
basically you were using else on catch block
https://www.npmjs.com/package/translate-api >>> https://github.com/googleapis/nodejs-translate @steep garnet
theres barely any deifference between them, i'd recommend using the translate api instead
@earnest phoenix now?
@delicate shore hard to explain you im gonna just fix your code
no
else is NSIDE if statement!!!
lemme fix it
where
Okay what's going on
OK
if(command === "kick") {
if (msg.member.hasPermission("KICK_MEMBERS")) {
if (msg.mentions.members.first()) {
try {msg.mentions.members.first().kick();
msg.channel.send(" I Yeeted" + msg.mentions.members.first());}
catch {msg.reply("I do not have permissions to kick " + msg.mentions.members.first());}}
}
} } else {
msg.reply("You do not have permissions to kick " + msg.mentions.members.first());
}
@delicate shore should work
wait, wut.
@earnest phoenix ok cool but in future don't spoonfeed
@earnest phoenix
@opal plank, that module seems like 100 times easier.
it is
what i've done all this time.
tf
@delicate shore it's a catch block
the cloud api is much harder to handle
@delicate shore goto that line on glitch imma see your code
and the fact that the parser is chewing some of the errors is annoying
hard to debug when the only error is BAD REQUEST
@delicate shore oh boy who told you to remove what i fixed partially
actually.
i thought i wasted 60min of like figuring out what was happening.
hard to explain doggos
and then you come and say "hey, i have this cool module".
@delicate shore
and i just read it for 3sec and it looks easier
damn.
no reason NOT to use that instead if you only doing basic stuff
i luv you now
๐
you're my best friend now ok? 
bruh @delicate shore cant even read that "unexpected token OMMAND" typo it was supposed to be command
GOTTA GOTOVISUAL STUDIO CODE and start from scratch on his kick command and i dont make typos
lol.
Btw I'm kinda retarded inside but is there a way for me to log the guild ID on quick.db and then access each one when called? After the ID will be a number, 1 or 0 and I want this to be accessible per guild
definetly use VSC or atom(preferably vsc, my opinion)
i use atom.
Vsc best :chant:
atom had some nice features, but nothing that VSC extensions cant handle
but i rlly went more with atom.
stuff like live commits are insanely fun
ok so
Wait atom has live commits??
yeah
I'm gonna go download atom
kinda like liveshare on vsc
Wait are there any vsc add-ons that do that?
@opal plank, link to the extension of atom?
liveshare
https://teletype.atom.io/ @steep garnet
ah yes, ty so much.
but for my bot, what it happens @opal plank?
Yeah the formatting of the code was kinda bad it could be a lot simpler
wdym?
lemme fix your code
i swear you are hard to explain
not sure i get the question, everyone will see the error on the code
@steep garnet if there's an error we're here to help you
ty.
Np :)
the code doesnt run while you guys are editing, it only changes the code as everyone types
ohh, ok.
you'd need to reload cache/ restart the bot to apply changes
Oh ye
But what if you have no friends to edit with 
specially for support, it comes in quite handy when trying to debug someones code
Yeah, instead of just typing it out here
what is wrong here
Uh
if (msg.member.hasPermission("KICK_MEMBERS")) {
if (msg.mentions.members.first()) {
try {msg.mentions.members.first().kick();
msg.channel.send("***I yeeted him Lol***")}
catch {msg.reply("I do not have permissions to kick " + msg.mentions.members.first());}}
} else {
msg.reply("You do not have permissions to kick " + msg.mentions.members.first());
}};
```
though, usually when you need to do that, i do not assure mental sanity safety
Okay first, I'd really reccomend switch-case
what?
the spaguetti code i've seen thus far is beyond my level of bad code
Over if (content) then
dynamic command handler
But what if you have no friends to edit with
@pure lion ah yeah, i've none.
your code will become a monster rather quickly if you go the if's approach
client.commands.get(command).execute(command.args).catch((err) => ())
what?
So you wanna split up the response into individual words, this makes an array usually named (args). When you put this as a var into your code, you can do switch (args[0]). This will get the first word of the input. If you do switch (args[0]) {case'kick': -> code here}
map the commands you have, then get, if it errors, do nothing(aka, it didnt find a command matching)
You can use args to get a mention, E.G
let person = msg.mentions.users.first() || msg.guild.members.fetch(args[1])
let reason = msg.content.substring(prefix.length + 4 + args[1].length)
try {
person.kick()
msg.channel.send('person.(tag or id) has been kicked because of ' + reason)
} catch (err) {
msg.channel.send('I was unable to kick this user')
console.log(err)
}
@delicate shore
wait a second.
@steep garnet https://paste.awoo.rocks/botipafigi.js use hastebin
pastebin is every devs worst nightmare
i wanna do if perms is missing
is it !
before that
@opal plank do you knwo
know
is upper on the code.
if NOT has_perm
thnx
:/
ok tell
nah dude, all good
tis why you usually wanna learn, thats just spoonfeeding
lol.
@steep garnet rerun the command with console.log(langToTranslation) and log textToTranslate too
you might be getting an error while trying to use a non existant abreviation and sending a request
did you log the variables?
