#development
1 messages · Page 1058 of 1
you're telling me
where are you from?
uk
tr
@quartz kindle im trying to move to mysql and it seems to be easier to get the information and i dont have to remake much because it allows json styles data sets is this good or bad? https://cdn.vurighosting.com/u/TFPpnl.png
the end scanid is a visual glitch
client.cache.channels.get() to get a channel, right?
@obtuse jolt its not json style
its tabular data, tables and columns, thats how SQL works
idk but this works https://cdn.vurighosting.com/u/8s7wp4.png
yes, but its completely different
for example, you cant have nested structures
json can have objects inside objects, sql cant
i mean
how would that be possible
i dont think they can
it would destroy the point of client.channels.get
in the end its still data storage, so there are similar concepts everywhere, but you have to approach SQL with a different mind set
thats impossible
Ids are 100% unique regardless of if its a diffrent guild
2 guilds cant have the same channel id
not out of the box
although postgre does have extensive tooling for json structures
mysql only has it in newer versions
or as an extension
usually when interoping json with sql, one would stringify the json, and store it as text
thats what i do
ReferenceError: Cannot access 'Boss' before initialization Boss is a class and is created in the SAME else statement where I'm making the new Boss object
show code
@quartz kindle Actually postgre still does the string and load method
also why create a class on the fly like that
Send pic of code, we cannot see the issue without seeing what you did
it just has a c based codec now which usually does it automatically
Ok but I'm gonna cut out all the code in between
I dont get why
As the bracket of else {} goes all the way down
I’m not that good with classes but I think you need to define it before you call it
const filter1 = m => m.content === '1' || m.content === '2' || m.content === '3' || m.content === '4'
const f = m => m.content
tChannel.awaitMessages(filter1, {
max: 1
}).then(async collected => {
if (collected.first().content === '1') {
e1.delete()
let e2 = await tChannel.send(salesQ1embed)
tChannel.awaitMessages(f, {max:1})
.then(c => tickets.set(`tickets.${msg.guild.id}.user`, {
type: 'sale',
questions: [c.first().content]
}))
.then(tChannel.send(salesQ2embed))
tChannel.awaitMessages(f, {max:1})
.then(c => tickets.push(`tickets.${msg.guild.id}.user.questions`, c.first().content))
}
})
it sends 2 message embeds without waiting for the messages
techinically
classes work the same way as const and let
they are partially hoisted and depend on context and scope
but idk why would you wanna do that
So I move the class up?
classes are supposed to be defined somewhere like a blueprint, not declared on demand
Or move It to a different file
Do I just use my VPS IP?
I assume you mean to be in #topgg-api
wait yes oof
LOL
@quartz kindle would this work?
client.queue.on('empty', function (){
connection.connect(function(err) {
if (err) {
console.error('error connecting: ' + err.stack);
client.channels.get("726960119929241631").send("DATABASE ERROR DETECTED: " + err.stack)
return;
}
});
connection.query('truncate manualScans')
console.log("-----------------------------------")
console.log("Queue Database Cleared")
connection.end(function(err) {if(err) console.log(err)});
})```
idk
most of that seems to be custom code, so no way of knowing
will the truncate bit work?
also it only saves the first 10 numbers of the channel id and i cant find out why
you need to store IDs as strings/text
not as numbers
the truncate command depends on the sql version
some dbs accept TRUNCATE mytable
others require TRUNCATE TABLE mytable
just make it async
async execute
Ok thx
epic it works
@obtuse jolt can you show me
what is that
mysql
what is
TypeError: (intermediate value).setColor(...).setTitle(...).description is not a function
@misty sigil so like this
wat
wat
no
How
async module.exports
I think yes
or remove the async from there and put it async execute instead of just execute
awesome it all works https://cdn.vurighosting.com/u/Aawdbr.png
how do i get a message in v11
like channels.get but for message IDs
@misty sigil it did not work
Here my hole code
async exports = {
name: 'dogs',
description: 'Dogs!',
execute(message, args) {
const command = message.content.toLowerCase();
if(command === Prefix + 'dogs') {
let msg = await message.channel.send("Fetching");
fetch('https://dog.ceo/api/breeds/image/random')
.then(res => res.json())
.then(json => {
let embed = new Discord.MessageEmbed()
.setTitle('Woof , Woof')
.setImage(json.message)
.setTimestamp()
.setFooter(message.author.tag,message.author.displayAvatarURL());
msg.edit(embed)
})
}
},
};
This is for a command handler that’s why
module.exports = {
name: 'dogs',
description: 'Dogs!',
async execute(message, args) {
const command = message.content.toLowerCase();
if(command === Prefix + 'dogs') {
let msg = await message.channel.send("Fetching");
fetch('https://dog.ceo/api/breeds/image/random')
.then(res => res.json())
.then(json => {
let embed = new Discord.MessageEmbed()
.setTitle('Woof , Woof')
.setImage(json.message)
.setTimestamp()
.setFooter(message.author.tag,message.author.displayAvatarURL());
msg.edit(embed)
})
}
},
};```
I am so dumb
Pretty sure your name is S O B B A tho
Does anyone know how to code a discord.js bot to send a dm to someone you pinged?
why does everyone here have great dad jokes
Just get the member object and run a .send on that
Does anyone know how to code a discord.js bot to send a dm to someone you pinged?
@earnest phoenix 1. get user pinged (message.users.mentions.first())
- then .send().catch(e)
Ok
Just get the member object and run a .send on that
@tulip ledge isn't it user object?
You should also put a catch on it for when the users have DM's disabled
I think both would work
No nvm it's user
It's the user object
When automating browsing with a bot, is it against a rule here or against discord TOS to have a recaptcha solver?
good luck making it
I need help again
show code
Ok
@knotty steeple recaptcha solvers already exist, no need to make one
do same thing
but in meme.js this time
module.exports = {
name: 'meme',
description: 'Meme!',
execute(message, args) {
if(command === Prefix + 'meme') {
let msg = await message.channel.send("Fetching...");
fetch('https://meme-api.herokuapp.com/gimme')
.then(res => res.json())
.then(json => {
let embed = new Discord.MessageEmbed()
.setTitle(json.title)
.setImage(json.url)
.setFooter(Link: ${json.postLink} | Subreddit: ${json.subreddit})
msg.edit(embed)
}) //this is for ending the .then code
}
}
};
Guys how can I send the user DM when he get kicked? return message.author.send
Can't
Get the member object of whom you're kicking then get the user obejct of that member object and run the send method on that
Yes you can Jeremy
not after he is kicked
Ok so is if(message.users.mentions.first()) correct?
Ok just .send not message.channel.send?
and didn't you mean user object
obviously u will send the message before u kick @misty sigil
mkay
i think my bot is mad at me https://cdn.vurighosting.com/u/hu10dj.png
😔
I work
did you mean: 
Ok I'm confused here is the code else if (command === 'test'){ If(!args[0]) return message.channel.send('test'); If(message.users.mentions.first()) Message.user.send('test'); anything wrong here?
yes
Ok where did I mess up lol
its message.users.mentions.first().send().catch() i think i dunno
Ok
Yes
message.users.mentions.first().send("message").catch(return message.channel.send("The user had DM's disabled!")
Genuinely can’t find why it’s not replying
Maybe it really is mad
ohhh I think I know why
why
Nope still doesn't work
hi
Yeah it works now
@misty sigil apparently my bot doesn’t like intentions
(oh god)do you know js
@cunning coral https://discordjs.guide
or any language
@misty sigil the command did not work https://discordapp.com/channels/264445053596991498/272764566411149314/732709972462534667
@marble juniper my autocorrect on my phone does that its fine normally
k
ok yea i got no idea
I got the error "Cannot read properly 'mentions' of undefined"
I fucking hate people that say k it has no context and you never know if they are saying ok or they are angrily trying to say idc
then put it as the message object
Any idea why this SELECT * FROM test WHERE type = "sword" AND id = 1 OR id = 2 OR id = 3; returns all the values even the ones where type doesn't equal sword?
<message>.users.mentions.first().send("message").catch(return message.channel.send("The user had DM's disabled!")```
i have chrome book tho
Should it still be a if statement?
no there should be no if statement
Remove the <>
Now I got 4 errors
I fixed mine
Oh I fixed it lol
uhhh @quartz kindle i think i did a bad thing https://cdn.vurighosting.com/u/j1ROWK.png
Nope still doesn't work
idk what to do
It said the same error
@misty sigil all my command are not working for my bot when I did this https://discordapp.com/channels/264445053596991498/272764566411149314/732709356306694234
what
@obtuse jolt that happens when you try to connect/disconnect multiple times at once
use a connection pool and keep the connections open
are you using npm i mysql?
So instead of opening the connection I just connect once then use that
That’s pretty cool
What do I put for the connection limit
Idk what goes there
I fucking love levenshtein algorithm
connection limit = max amount of connections kept alive at the same time
What is the account limit?
account limit?
Yeah when I tried to login to my account earlier it said too many people were logged in at the same time
that depends on your mysql configuration
Do I remove my connection.ends?
Ok I need help here im trying to get the bot to dm a pinged user
Here is the command I get this error "cannot read properly 'mentions' of undefined"
@earnest phoenix message.users is not a property. You should flip it with message.mentions.users instead.
Ok
You should also make sure one user is mentioned by checking the collection .size.
Wait where does .size go?
It goes on the collection. message.mentions.users returns a collection. So, if (<Collection>.size == 0) {...} (fallback for if no one is mentioned).
Then again, getting the first mentioned user is not 100% reliable, but it's good enough.
Got it to work thanks
I have this else statement that will change the "itemid" to a different value and then run the code after the else statement the issue is that client.con.query takes time before it's done and therefore itemid is undefined when it reaches the code that will execute the things with itemid
This is the code:
else {
await client.con.query(`SELECT * FROM items WHERE itemtype = "${foundType}" AND (itemid = "${weapon}" OR itemid = "${helmet}" OR itemid = "${chestplate}" OR itemid = "${leggings}" OR itemid = "${boots}" OR itemid = "${fishingrod}")`, (err, rows) => {
if(err) throw err;
if(rows.length < 1) return message.channel.send("You don't have this item equipped")
let type = rows[0].itemtype;
let id = rows[0].itemid;
if(type === "sword" || type === "bow" || type === "weapon" && weapon !== id) return message.channel.send("You don't have this item equipped")
else if(type === "helmet"&& helmet !== id) return message.channel.send("You don't have this item equipped")
else if(type === "chestplate" && chestplate !== id) return message.channel.send("You don't have this item equipped")
else if(type === "leggings" && leggings !== id) return message.channel.send("You don't have this item equipped")
else if(type === "boots" && boots !== id) return message.channel.send("You don't have this item equipped")
else if(type === "fishing rod" && fishingrod !== id) return message.channel.send("You don't have this item equipped")
selected = type;
itemid = id;
console.log(itemid)
})
}
// Do stuff with itemid
Do I make a promise from the query?
@quartz kindle
undefined
/home/container/node_modules/mysql/lib/protocol/Parser.js:437
throw err; // Rethrow non-MySQL errors
TypeError: Cannot read property '0' of undefined```
```js
connection.query('SELECT * FROM automatedScans WHERE scanid = ' + input, function (error, results, fields) {
console.log(results)
console.log(results[0])
if(results[0].isautoscan === 1) {
client.channels.get(results[0].channelid).fetchMessage(results[0].messageid)
.then(message => {
message.clearReactions()
message.react('723475322061979669')
connection.query('SELECT * FROM automatedScans WHERE scanid = ' + input, function (error, results, fields) {
if(results[0].type === "url") {
vtauto.urlScan(results[0].input)
.then(async (resp) => {
await new Promise(resolve => { setTimeout(resolve, 5000) })
let reso = resp.resource
vtauto.urlReport(reso)
.then((res) => {
if(!res.total) {
message.react('724367489328349325')
}
if(res.positives) {
if(res.positives === 0) {
message.react('723481373616373818')
} else {
message.react('723481391786098688')
}
} else {
message.react('724367489328349325')
}
})
})
}
})
})
}
})```
^ classic example of callback hell
undefined
/home/container/node_modules/mysql/lib/protocol/Parser.js:437
throw err; // Rethrow non-MySQL errors
TypeError: Cannot read property '0' of undefined
at Query.<anonymous> (/home/container/bot.js:72:28)
at Query.<anonymous> (/home/container/node_modules/mysql/lib/Connection.js:526:10)
at Query._callback (/home/container/node_modules/mysql/lib/Connection.js:488:16)
at Query.Sequence.end (/home/container/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
at Query.ErrorPacket (/home/container/node_modules/mysql/lib/protocol/sequences/Query.js:92:8)
at Protocol._parsePacket (/home/container/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/home/container/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/home/container/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/home/container/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket.<anonymous> (/home/container/node_modules/mysql/lib/Connection.js:88:28)```
yeash but why
when i run this command the fillText's stay the same every time its run
const Canvas = require('canvas')
Canvas.registerFont('BebasNeue-Regular.ttf', {family: 'Sans Serif'})
const canvas = Canvas.createCanvas(750, 200)
const ctx = canvas.getContext('2d')
const { GuildMember } = require('../models/index')
const { MessageAttachment, DataResolver } = require('discord.js-light')
module.exports = {
name: 'level',
usage: 'aa!level',
async execute(client, msg, args) {
const data = await GuildMember.findOne({ID: msg.guild.id + msg.author.id})
ctx.fillStyle = '#7289DA'
ctx.fillRect(0, 0, 750, 200)
let img = await Canvas.loadImage(msg.author.displayAvatarURL({format: 'png', size: 2048}))
console.log(`${data.xp}\n${data.level}\n${data.level * 500}`)
ctx.strokeStyle = 'white'
ctx.lineWidth = 20
ctx.strokeRect(100, 65, 500, 100)
ctx.fillStyle = 'white'
ctx.fillRect(100, 65, 20, 100)
ctx.font = '50px Bebas Neue'
ctx.fillText(msg.author.tag, 155, 50)
ctx.font = '25px Bebas Neue'
ctx.fillText(`XP: ${data.xp}`, 620, 100)
ctx.strokeStyle = 'white'
ctx.fillStyle = 'white'
ctx.lineWidth = 10
ctx.arc(100, 100, 75, 0, Math.PI * 2)
ctx.clip()
ctx.stroke()
ctx.fill()
ctx.drawImage(img, 25, 25, 150, 150)
ctx.strokeStyle = 'white'
ctx.shadowColor = 'black'
ctx.shadowBlur = 10
ctx.shadowOffsetX = 10
ctx.shadowOffsetY = 10
ctx.lineWidth = 10
ctx.arc(100, 100, 75, 0, Math.PI * 2)
ctx.stroke()
let card = new MessageAttachment(
canvas.toBuffer(), `${msg.author.username}'s_card.png`
)
msg.channel.send(card)
}
}
e.g itll say my tag even if someone else runs the command
its loading different images too, just not changing the text
so thats how they make the level up cards, looks hard
lol
(and also broken... etc)
@quartz kindle i found the error
Error: ER_BAD_FIELD_ERROR: Unknown column 'eRcN7y' in 'where clause'
the fucking irony is unreal https://cdn.vurighosting.com/u/A4Wy5b.png
*cries in not getting help*
@misty sigil
also bruh
Whats the issue Dice?
he might be able to help
And stop changing ur name
I'm always confused if ur referenceerror or not lmao
@pure lion
Whats the issue?
const data = [];
const { commands } = message.client;
if (!args.length) {
data.push('Here\'s a list of all my commands:');
data.push(commands.map(command => command.name).join(', '));
data.push(`\nYou can send \`${prefix}help [command name]\` to get info on a specific command!`);
return message.author.send(data, { split: true })```
um this get's all the commands in this folder
but i wanna seperate it by folder
@stark abyss I'll break down for you how to do it ok?
yeah please
@earnest phoenix hello there, lord of canvas. i apologise for the ping but i appear to be suffering from an issue that neither i nor ChickenDev can solve. your assistance would be greatly appreciated :). the issue is that the text isnt updating per use of the command, and stays the same as the first user who ran the command
(https://hasteb.in/hifikoji) <= code
First you create a function like this:
function loadCommands = module.exports.loadCommands = (dir ="./commands/") {
}
Inside the function you first run an fs.readdir to get all the files & folders inside commands
The you wanna .forEach these files and use fs's function .isDirectory() on them, if this returns true you can call loadCommands again and add this directory into it like this: loadCommands(dir + file + "/") if .isDirectory() returns false you can just add the command to your set like usual
dire times :sad:
okay that's gonna be bit rough on me but ill try my best
i have a screenshot command right, how would i filter out nsfw content?
do i just have todo if(ss).includes(...)?
just restrict it to nsfw
yeah thats what i have right now
it'll be bypassed
it's impossible
but for yours i thought you have it bypassed flazepe
nope
you have nsfw bypassed or did you lock your command to nsfw?
not anymore
we were all told to lock, even for owners
hello, I am trying to export some of my features which are often repeated in my code, example:
const discord = require('discord.js')
var config = {
check: async(msg) => {
if(msg.channel.id !== "534739150214135818"){
if(!msg.member.hasPermission('MUTE_MEMBERS')) {
msg.delete()
return msg.channel.send("Les commandes sont autorisés uniquement dans [#534739150214135818](/guild/264445053596991498/channel/534739150214135818/)").then(msg => msg.delete(10000))
}
}
}
}
module.exports = config```it works the message and send but the continuation of the code is executed as I can stop the continuation? if the action does
https://modeus.is-inside.me/r3Irc5i4.png
constructor(options) {
this.options = options || {}
if (typeof this.options !== "object" && this.options !== null) throw new TypeError("'options' has to be an object.")
}```
js is a troll
using typeof on an array returns object
@knotty steeple an array is an object
You can use Array.isArray(array) to see if it's an array or not
An array is basically an object with different methods
I have a json element that I've parsed using js, how do I get the first json object in the array?
index [0] @gritty bolt
I think it's not very understandable what I said
@tulip ledge ||sorry for ping just ignore me if you don't wanna deal with me||
so I sort off did what you aimed for in different way
fs.readdirSync(`./commands/`).forEach(folder => {
var loadFolder = `${folder}`
console.log("Loadded " + loadFolder)
fs.readdirSync(`./commands/${loadFolder}`).forEach(file => {
var loadFile = `${folder}/${file}`
console.log("Loadded " + loadFile)
})
})```
and it's console.logging the folder and file right but the thing is that i called
```css
const data = [];
const { commands } = message.client;
data.push(commands.map(command => command.name).join(', '));```
So I want to seperate the commands by file for help embed but i am not sure how to
so how can i do data.push by folder in this folder then taking all files in this folder
how to i get to the 0 https://cdn.vurighosting.com/u/74MElb.png
theres spaces in that
currently using
console.log(results[0])```
what is results?
that is the result
where is it defined though
connection.query(`SELECT EXISTS(SELECT * FROM votes WHERE userid = '${vote.user}')`, function (error, results, fields) {
console.log(results[0])
})```
i am not expert but what happens when you just do results instead of results[0]
error?
the same thing i think
maybe it's worth trying? idk man
yeah its literally the same thing
when the command is run, check that the person running has your id
if(message.author.id !== "YOUR ID") return;```
no
use what
@quartz kindle i need help
@obtuse jolt is the key to your entry an entire sql query?
hmm?
without export:
if (!message.member.hasPermission("BAN_MEMBERS"))return msg.channel.send("You don't have permissions to do this!");
member.ban()```I do not have the perm it sends the message and stop the code before ban
with export:
```js
ExportConfig.permcheck(message, "BAN_MEMBERS")
member.ban()```
I do not have the perm it sends the message, its not stop before ban
how to remedy this?
code :
```js
const discord = require('discord.js')
var config = {
check: async(msg) => {
if(msg.channel.id !== "534739150214135818"){
if(!msg.member.hasPermission('MUTE_MEMBERS')) {
msg.delete()
return msg.channel.send("Les commandes sont autorisés uniquement dans [#534739150214135818](/guild/264445053596991498/channel/534739150214135818/)").then(msg => msg.delete(10000))
}
}
},
permcheck: async(msg, perm) => {
if (!msg.member.hasPermission(perm))return msg.channel.send("Vous n'avez pas les permissions pour faire cela !");
}
}
module.exports = config```
god tim is being pinged 
i need tim
he has big brain
@wicked pivot if they bot says it doesnt have permission to send the message the bot is most likely muted in that channel
you probably want to use AS
as?
SELECT EXISTS(bla) AS hue = results[0].hue
otherwise
SELECT EXISTS(bla) = results[0]["bla"]
big brain tim
in your case
results is returning everything right after SELECT
so you'd need to results[0]["EXISTS(SELECT * FROM votes WHERE userid = '${vote.user}'"] lmao
bruh
thats why you use AS
AS vibecheck
yes
beautiful
oh fuck yes https://cdn.vurighosting.com/u/O3s2YN.png
this man has no vibe we must vibe check him
bruh
why
no ads
@scenic kelp is there an anti ad bot here or something
luca
luca deletes any messages from whitenames with links to certain places afaik
luca anti ad auto ban
Oh sorry
yes
I didn’t know
they should add that
@warm copper Maybe you should read the rules then
isn't that prone to sql injection
still
sql injection has entered chat
sql injection has left chat
there's ?
i mean if dbl wanted to sql inject me i suppose they could
but i would hope they wouldn't
use the ? thing in sql
ok why not 3000 priority tokens for me 
a parameterized query
seriously, i'd advise securing that
i mean theres no sensitive data its all scan config files and server configs so
the mysql lib doesnt have actual prepared statements, they just do string escaping
oh
HOW
still, better than nothing
that's kinda dumb
how would i add it tho
god knows how long thats been there
doesnt it just query the database?
it looks like you just pass an array of args
so couldnt you just manually add it
this is what SO says
ive been working on this for over 4 hours
so it'd be like connection.query(`sql statement with ?`, [arg(s) to replace with], callback)
yeah
not a huge change but one that is the difference between giving users access to your db and not
it's not for me
it's for you
sql injection is stupid
how does the ? do that i never got that
for example, if your query is SELECT * FROM table WHERE id = "USER ID FROM COMMAND HERE"
and a person does command bla" DROP TABLE
your query becomes SELECT * FROM table WHERE id = "bla" DROP TABLE"
escaping characters prevents dangeours chracters like quotes from being parsed by SQL as commands
so that your dbl will understand DROP TABLE as text, and not as a command
its so easy to add tho i wouldve though they would just add it by default
they cant do it by default, because the entire interface is text based
you are basically sending one huge text command to SQL
they have no way of validating the command for you, you need to do it yourself
the ? just makes it easier to add multiple values to the query
fs.readdirSync(`./commands/`).forEach(folder => {
var loadFolder = `${folder}`
console.log("Loadded " + loadFolder)
fs.readdirSync(`./commands/${loadFolder}`).forEach(file => {
var loadFile = `${folder}/${file}`
console.log("Loadded " + loadFile)
})
})```
and it's console.logging the folder and file right but the thing is that i called
```css
const data = [];
const { commands } = message.client;
data.push(commands.map(command => command.name).join(', '));```
so how can i do data.push seperately to files in folder then just all files in this folder with multiple folder
so this would work? https://cdn.vurighosting.com/u/ZTd6yR.png
I need to seperate it bc i am using this for help embed and it would give me all commands. I want to categorize them
yes
can I define a constant as a block of code instead of a single line
seems easy enough
not sure if you need the quotes around the ?
i think you dont
@opaque hawk what kind of block
if anyone can help me please ping me
I think that I could do ```ts
const xp = ({
});```
i dont understand what your code is trying to do p025
it loads all the commands
@opaque hawk you can define a const as anything, an array, an object, a function, etc...
the top bit does at least
ok
but it needs to be a specific thing
yeah idk what hes trying to do either
for example ```js
const a = function() {
return 10
}
or
const a = {
a:10,
b:20
}
it would make more sense for something like this I'd think https://cdn.vurighosting.com/u/6RMAwJ.png
yes
i dont understand what your code is trying to do p025
@quartz kindle So right now I have
data.push('Here\'s a list of all my commands:');
data.push(commands.map(command => command.name).join(', '));
data.push(`\nYou can send \`${prefix}help [command name]\` to get info on a specific command!`);
return message.author.send(data, { split: true })
This is triggered when I do prefix + help. the data.push(commands.map) line will give me all the commands that exist in this folder called commands. But just giving all commands is kinda weird so I wanna categorize them. I already have folders in folder named with their category name and I want to separate the commands by folder
is this good? https://cdn.vurighosting.com/u/OmzdAa.png
can I ask why you are hosting pictures to send rather then just sharing/sending?
yes it's good

nice
you could just... you know... copy and paste? the actual code?
upload a few bytes instead of an image?
@stark abyss do you have some kind of category field defined in your commands?
oh
for example
cmd = require(folder/file)
cmd.category = folder
client.commands.set(cmd.name,cmd)
oh ok
you're basically using the command loader to attach the folder it came from to itself
so it remembers which folder it came from
okay 
connection.query(`SELECT EXISTS(SELECT * FROM votes WHERE userid = '?') AS vibecheck`, [vote.user], function (error, results, fields) {
if(results[0].vibecheck === 0) {
connection.query(`INSERT INTO votes (priorityleft, totalvotes, userid) VALUES (?, ?, ?)`, [0, 0, vote.user], function (error, results, fields) {
connection.query(`SELECT EXISTS(SELECT * FROM votes WHERE userid = '?') AS vibecheck2`, [vote.user], function (error, results, fields) {
connection.query(`UPDATE votes SET priorityleft = ?, totalvotes = ? WHERE userid = ?`, [vibecheck2.priorityleft++, vibecheck2.totalvotes++, vote.user], function (error, results, fields) {
})
})
})
}
if(results[0].vibecheck === 1) {
connection.query(`SELECT EXISTS(SELECT * FROM votes WHERE userid = '?') AS vibecheck`, [vote.user], function (error, results, fields) {
connection.query(`UPDATE votes SET priorityleft = ?, totalvotes = ? WHERE userid = ?`, [vibecheck.priorityleft++, vibecheck.totalvotes++, vote.user], function (error, results, fields) {
})
})
}
})```
is that all valid
i think mysql will add the quotes around the placeholders automatically, so '?' is wrong
code: 'ER_PARSE_ERROR',
errno: 1064,
sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '551854789990940699'') AS vibecheck' at line 1",
sqlState: '42000',
index: 0,
sql: "SELECT EXISTS(SELECT * FROM votes WHERE userid = ''551854789990940699'') AS vibecheck"
dont even need the help
i know that one
ReferenceError: vibecheck2 is not defined
seriously
ok ok
no errors
now to check the database
hmm
im on there but it wont add votes to me
i cant get it to work wtf
@quartz kindle help
I got this error
WARNING: The script chardetect is installed in '/Users/
Library/Python/3.8/bin' which is not on PATH.
So it ran
nano .bash_profile
then
export PATH="/Users/Library/Python/3.8/bin:${PATH}"
Was this correct?
And is that and okay thing to do
like will it mess up something else
is async enabled in for loops?
cmd = require(folder/file)
cmd.category = folder
client.commands.set(cmd.name,cmd)```
does anyone know what category or folder is in 2nd line
Hi 😄 how do I make it so it can only be used in a nsfw channel?
make sense? 🙂
ik but how? 😄
in which lib
? 😄
how do i change the color of my web?
what do you mean
i tried adding background-color style to my body but nothing
discord js
style it with css
lol yeah
!
avatar not found
i know @earnest phoenix
then i will pass it to my VPS
Right now its just the model 
embed.set.thumbnail(message.author.displayAvatarURL)
@earnest phoenix will this work?
Bulma is my css framework 
or something like it
you can also mark background-color with !important
error
read your damn error
that is not the issue
please stop trying to help if you cannot diagnose the issue correctly
not using ext
@ember lodge pretty sure background-color has to go between <body> </body
what
no
that's not how css works
and oh i just noticed your issue
your style tag is outside of the head
I havent used html in a while
then don't help? lol
@zenith terrace I figured out by myself so don't worry
I added background color to html tag
error
@earnest phoenix can you try usingmessage.author.avatar_urlinstead ofmessage.guild.user.avatar_urlMay work 🤔
do .thumbnail
not _
@gray zealot He is using discord.py so "_" is right
@gray zealot He is using discord.py so "_" is right
@regal raven oh nvm then 🙂
🙂
🙂
😂
why would this let welcome = db.get(welcome_${message.guild.id});
give me this error
(node:57) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
@fervent flume you don’t have it in your message event
Consider using the `--user` option or check the permissions.
I flagged my command with the --user too, if anyone can help please DM me!
@fervent flume
is it in your <Client>.on message event
I think its fixed seeing that you deleted your message?
what?
no it isnt its still saying thgat error, and yeah it is in my on message event
@torn ravine
ive not given any path as Commands\helpCommands.
its not even telling me where that code is -_-
@fervent flume v11 or v12
v12
Press New Application
i did
@lavish anchor also learn a language
Enter a name for your application -> Click the "Bot" tab on the left side bar -> Build the bot
oh! i see
thanks
i will proceed further
if i need any help
will let you know
yeah
which guide?
ClientConnectorCertificateError(
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discordapp.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')]
Can someone help me with this issue that I get when running python3 main.py on a mac? Please ping me if you have a solution 🙂
how am i meant to handle
(node:11571) UnhandledPromiseRejectionWarning: Error: WebSocket was closed before the connection was established
even tho its thrown does it still close it?
d.js version?
how do i best clear guild cache for a specific guild in discord.js?
@torn ravine me?
ya you
its not a djs error nor do i use djs its just ws package
ah
making a bot there seems to be something wrong with the code but i dont see it
What's the issue though
no commands run
const Discord = require("discord.js");
const bot = new Discord.Client();
const token = 'token';
const PREFIX= '*';
bot.on('ready' , () =>{
console.log('This bot is online!')
}
)
bot.on('message' , message=>{
let args = message.content.substring(PREFIX.length).split(" ");
switch(args[0]){
case 'ping':
message.channel.send('pong!');
break;
case 'info':
console.log('message received');
if(args[1] === 'version'){
message.channel.send('Version 1.0.0');
}else{
message.channel.send('Invalid Args');
}
break;
}
})
bot.on('ready', () => {console.log('ready')});
bot.login(token);
heres all of the code
ClientConnectorCertificateError(
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discordapp.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')]
Can someone help me with this issue that I get when running python3 main.py on a mac? Please ping me if you have a solution 🙂
Because it is
Do the .msi, you'll get an installer
Do the .zip, it's an archive file
It's usually down to preference but msi is generally more straightforward
so the msi is easy then zip? @pure lion
Hey guys how can we use bot catch censor??
use some image apis
well uhh the command (work command) it works but when the user runs again it doesnt store the number like the cmd works but the number doesnt get stored into the database
make sure that you're writing the value to your database
what db type
mongoDB
mongoose?
Javascript
yes
sure
ill just give full code then
const Discord = require("discord.js")
module.exports = {
name: "work",
aliases: ["w"],
category: "Currency",
run: async (bot, message, args) => {
let random = Math.floor(Math.random() * 100);
console.log("blah")
let prevmoney = await bot.db.collection("Money").findOne({"User_ID": message.author.id})
if(!prevmoney) {
await bot.db.collection("Money").updateOne({"User_ID": message.author.id}, {$set:{Money: prevmoney ? prevmoney.Money + random : random}},{upsert:true})
prevmoney = 0;
}
let embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitle(`You worked!`)
.setDescription(`You worked and got \`\`${random}\`\` money!💰`)
.setFooter("By the way this command is in beta!")
message.channel.send(embed);
}
}
wdym
it will only update if it cannot find the user's id in the money collection
uhh?
k
the bot should set my data as expected
mhm
but if i tried to run the command again
prevmoney is now defined and the block that updates the database will never run
because when you say (!prevmoney) you're telling it "if this user doesnt exist update their currency"
yes you can
ok will that work?
but you can also do findOneAndUpdate
@earnest phoenix Yo bro
can you come to my base i need talk xD
K
essentially you can just use the code that you currently hve
but lift it out of the if block
nd replace findOne with findOneAndUpdate
because you also specified upsert it will create a new document if it cant find the user
i started using mongodb
could you give an example? @valid frigate
okay
await db.collection("test").findOneAndUpdate({ user_id: "0" }, {
$set: {
money: 100
}
}, upsert: true)
wait fuck
so where would that go?
bruh
bruh
everyone starts somewhere
uuhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
wait does it go in the else statement? @valid frigate
no
oh
you dont need a conditional at all
because think about it this way
the code above will create and set a document if it cant find the user, and if it can, just update it like normal
ClientConnectorCertificateError(
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discordapp.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)')]
Can someone help me with this issue that I get when running python3 main.py on a mac? Please ping me if you have a solution 🙂
now how do i make a bal cmd? @valid frigate
use .findOne()
@valid frigate how?
........similar to findoneandupdate
uhh god
welp
wait
cant i do
let prevmoney = await bot.db.collection("Money").findOne({"User_ID": message.author.id})
message.channel.send(prevmoney.Money)
```?
let me try
that
const Discord = require("discord.js")
module.exports = {
name: "balance",
aliases: ["bal"],
category: "Currency",
cooldown: 5,
run: async (bot, message, args) => {
let prevmoney = await bot.db.collection("Money").findOne({"User_ID": message.author.id})
let embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitle(`${message.author.username} here's your balance!`)
.setDescription(`Balance: \`\`${prevmoney.Money}\`\``)
.setFooter("By the way this command is in beta!")
message.channel.send(embed);
}
}
``` @valid frigate well when someone has no money it says cannot find Money of null or smth how can i stop that?
if (!prevmoney) {}
ok in ?
guess
right above it
When I do <channel>.awaitMessages(...{max:1}).then(), if doesn't wait for the collector to end
b to the r to the u to the h
k
:/
so i need help planning my api
each space has pages, but pages can belong to a group (like channels and categories in discord)
how should i lay out the api routes?
i was thinking this:
/pages
/pages/id
then pages includes the groups as well to make it simpler
but i'm not too sure if that's good
Yeah I think pages/id would be a good api route amon avis
👍
also what sort of regex can i use to only match two words
so the regex only outputs true if the value it gets is public or private - case insensitivie
Use |: (private|public)
you do not need regex for that
regex is much slower compared to just directly comparing the string
how do i get all the roles of a member?
Read the docs
which docs
Your libs
.
Don't dotpost
Your libs
@honest perch discord.js
/home/runner/work/import/import/commands/softban.js:31
let logchannel = message.guild.channels.cache.find(x => x.name = 'logs');
^
SyntaxError: Identifier 'logchannel' has already been declared
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 /home/runner/work/import/import/index.js:21:17
at Array.forEach (<anonymous>)
at /home/runner/work/import/import/index.js:20:9
at FSReqCallback.oncomplete (fs.js:155:23)
##[error]Process completed with exit code 1.```
help me plz

Please go review js basics
That's a real simple error
@summer torrent plz bro
no, read error

Anyone what this error means?
(node:1818) UnhandledPromiseRejectionWarning: #<Response>
5:46 PM
(node:1818) 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(). (rejection id: 1)
5:46 PM
(node:1818) [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.
@earnest phoenix show code
I want to but every time I reboot the error come from a different place
yes try catching and logging the error
Read the error message
@earnest phoenix That error message is pretty much useless...
ok i told him what to do
/home/runner/work/import/import/commands/softban.js:31
let logchannel = message.guild.channels.cache.find(x => x.name = 'logs');
^
SyntaxError: Identifier 'logchannel' has already been declared
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 /home/runner/work/import/import/index.js:21:17
at Array.forEach (<anonymous>)
at /home/runner/work/import/import/index.js:20:9
at FSReqCallback.oncomplete (fs.js:155:23)
##[error]Process completed with exit code 1.```

@earnest phoenix Please stop
[c.forEach(e => e.content)]
i want to put the content of the collected messages (c) into an array while using awaitmessages, ive logged it and it returns undefined
u are assigning
@earnest phoenix If you can't work with simple js you shouldnt be working on a bot.
@earnest phoenix u are assigning the value of channels to logs
@earnest phoenix plz help me sir
@earnest phoenix That error message is pretty much useless...
@earnest phoenix what should I do?
send the code @earnest phoenix
Identifier 'logchannel' has already been declared
Self explanatory
@earnest phoenix u know the line where the error occured
Nope
now place a .catch
Luca oment
luca o m e n t
u have to place in correct line
Try a try and catch block @earnest phoenix
try { peepee } catch (err) { poopoo }
yes why
👁️
wot
github not for host
student edition
:o
not edition tho
No, you have to call GitHub and ask them to run it for you /s
@restive pebble yus i am student
/s/s/s/s

oh i see
[c.forEach(e => e.content)]
hhhhhhhhhhhhhhhhhhhhhhhhhh
whats the error here
What's the issue
it logs undefined
and why u putting in []
^
because its meant to be an array
You want map, not forEach
no content is there
forEach doesn't return anything
or foreach and add push to array
@earnest phoenix Try adding https://nodejs.org/docs/latest-v12.x/api/process.html#process_event_unhandledrejection if you can't figure out what is throwing the error
nice
mongo
it works
mongoDB?
Well done
i can easily switch to any db i want in the future as i made a custom wrapper
yes mongodb
nice
ah ok
if you're interested i can send it though tomorrow
I already have my small handler
mine works more basically, ie
await db.coll('users').add(...)
how to set the color of that line thingy on the embeds in discordia?
<embed>.setColor('COLOR')
discordia
discordia
Do the docs mention anything?
nope
ok nice
at least i dont think so
dont use that thing if they dont have proper docs
i saw somewhere something like embed color.fromrgb or something like that
why use discord.js
because its based on lua and i like lua
line 38
ok
Oh that's lua didnt even realize
@slender thistle thanks will try it
@slender thistle ok, thank you so so much, it works!

dek-help
epic
muted
how
how would i make my bot leave all guilds with eval
thats not development related
but well
my bot was added on 45 servers in 5 days
so uh
idk
if you consider it good
I clear using bulk
rainbow role bot ip banned why??
uhh

api abuse?
k
@strong fractal that only deletes up to 2 weeks worth of messages or 100 messages tho
@earnest phoenix it is api abuse
If you are using a speed that's lower than 60000ms (1 minute) Your bot might get IP-banned!
...
true /false
?
is that a question?
If you are using a speed that's lower than 60000ms (1 minute) Your bot might get IP-banned!
true/false

false
wot





making a dashboard in raw html