#development

1 messages ยท Page 897 of 1

drifting dome
true ravine
#

@true ravine What about now for the eco.addMoney(message.author.id, amount); what would i put to replace the message author id
You have to get the ID of whoever reacted and substitute that in

copper cradle
#

display: none !important;

unborn steeple
#

But that the pount lol

#

like what would i use

#

You have to get the ID of whoever reacted and substitute that in
@true ravine

How would i do that though ive never tried it befroe so its a bit confusing

true ravine
#

reaction.users.first I think

#

Never done it before that's a guess

unborn steeple
#

it responds with the id?

true ravine
#

No you need to get the id from that

#

So reaction.users.first().id

#

I think

earnest phoenix
#

in the request module in node.js

anyone know the flag to get "location" to show up in headers?
currently using this

 request(url, {resolveWithFullResponse: true}, (err, res, body) =>{ console.log(res.headers)})
pale vessel
#

define it in headers maybe?

unborn steeple
#

reaction.users.first I think
@true ravine

I did that and it doesnt cancel the bots reaction tho

#

and gives the bot the reward

true ravine
#

Oh yeah

#

reaction.users[1].id Then

earnest phoenix
#

but i get headers from the site the url directs to

unborn steeple
#

reaction.users[1].id Then
@true ravine

Where at tho

#

Because the reaction collector still deletes the message when the bot reacts

copper cradle
#

...

#

show your code

true ravine
#

reaction.users[1].id

This should just return the id of the second person who reacted

#

I assume that would work based on your code?

unborn steeple
#
	
	let channel = bot.channels.get("692820090831503412");
	
	let chance = Math.round(Math.random() * 1000);
	
	let amount = Math.round(Math.random() * 200);
	
	let embed = new RichEmbed()
	.setColor(0xabc123)
	.setAuthor("Reward Spawned", bot.user.displayAvatarURL)
	.setDescription("A lootbox spawned with " + amount + " tokens inside.");
	
	if (chance > 900) {
		channel.send(embed).then(function (msg) {
			message.react("๐Ÿ’Ž");
		
		const filter = (reaction, user) => {
			return ['๐Ÿ’Ž'].includes(reaction.emoji.name) && !message.author.bot;
		};
		
		msg.awaitReactions(filter, { max: 1, time: 200000, errors: ['time'] })
		.then(collected => {
			const reaction = collected.first();
			
			if (reaction.emoji.name === '๐Ÿ’Ž') {
				
				msg.delete();
				eco.addMoney(message.author.id, amount);
				message.reply("You grabbed the " + amount + " tokens.");
				
			}
			
		})
		
		})
		
	}
	
});```
#

The message is deleted

#

Once someone reacts

true ravine
#

Yeah I know

#

Have you tried reaction.users[1].id ?

unborn steeple
#

on the id?

#

It wont do anything

#

Becaus ethe message would delete before the user has a chance to react

copper cradle
#

dude you're literally deleting the message before checking for anything

unborn steeple
#

what i wanna know is how to fix it

true ravine
#

I assume this some code you got off the internet?

earnest phoenix
#

you're talking to a verified bot developer @true ravine

copper cradle
#

that doesn't mean anything

#

anyone could be verified

#

they just need to apply

#

it's not like discord checks their code

#

because trust me

quartz kindle
#

i wish they would

#

lmao

copper cradle
#

if they did then way less devs would be verified

true ravine
#

Bruh my code is super inefficient, but it's all mine. The fact it's inefficient is because it's my own work lol

copper cradle
#

?

#

no one said anything about your code bruh

blazing portal
#

bruh

true ravine
#

Bruh

copper fog
true tundra
copper cradle
copper fog
#

You add your bot?

#

Lol

copper cradle
#

yes

#

you add your bot

#

wait

#

wrong url

copper fog
#

The embed doesn't even show up

copper cradle
#

there

copper fog
#

k

copper cradle
#

why the fuck is there a discord embed showing up

copper fog
#

Idk

unique nimbus
#

login with discord

true ravine
#

Top.gg is secretly discords planned bot list

copper cradle
#

lol

copper fog
#

Use brakets like <this> e.g: < https://url.com > so the embed doesn't show up

copper cradle
#

I know

#

that wasn't my question tho

copper fog
#

Hm.

true ravine
#

If send loads of queries to a database all at once will that cause any issues?

blazing portal
#

If you define loads and database we might be able to help ๐Ÿ˜‰

true ravine
#

Hmmm ๐Ÿค”

#

Mysql database (just the mysql community server ting)
Loads is between 20 and 50 queries in a for loop once a week

#

All updating values of a column

#

Tbh I might as well take my usual approach to push the update and wait for complaints to come in when it crashes

#

Usually works

modest maple
#

eh thats nothing for dbs

#

they can cope with hundreds of querys per second

true ravine
#

Oh nice

#

Thank you very much

earnest phoenix
#

I'm still getting the invalid user error, but i don't know from where it comes

#

Any idea ?

copper cradle
#

send logs

#

and code

earnest phoenix
#

Idk where it comes

#

And logs are just DiscordApiError Invalid User

copper cradle
#

show the log

#

and I'll tell you where it's coming from

earnest phoenix
#

what are you using to define member

copper cradle
#

kinda

earnest phoenix
#

Wait

#

I go on my computer

#

Cuz i only have the logs on my phone

spiral prawn
#

about levelling
you know, where you get xp for sending messages
what's the best way to do this
clearly making a db call for every user every message is a bit stupid
so every 10 messages? 2 minutes?
whats the best idea here

astral yoke
#

https://prnt.sc/s7mzg0 anyone know why my bots falling to start up? it's supposed to log two more things, the last thing should say that the bots online but it's not showing it and I've had it wait a few minutes. It would normally get through this no problem. It dosen't tell me theres an error anywhere it's just failing to start up. This is also happening with my vps neither I or it can start the bot fully up.

Lightshot

Captured with Lightshot

#

Theres no error or nothing it should do it.

digital ibex
#

probably ur ready event?

#

what language r u using?

astral yoke
#

discord.js

earnest phoenix
#

debug

#

go through your code

#

try catch for possible errors

#

and console.log at closures

astral yoke
#

I'm gonna restore before I updated it and save that as the bots files and see if it's cause of new code or i don't even know.

opaque eagle
#

Does anyone else have problems with node-gyp and canvas?

#

node 13.13.0

drifting dome
#

might needa wait a bit for an update

final stone
#

Hey, I am attempting to delete a message when a reaction is detected (specifically \๐Ÿ—‘๏ธ ), the bot reacts first and then to delete the user can click it, I want to do this for all old messages (so I can't use awaitReactions, or whatever that is.) and it needs to be done in a DM. this is the code which for some reason only works on mesages sent since the bot was online.

client.on("messageReactionAdd", async (reaction, user) => {
    if (user.bot) return;
    if (reaction.message.author.id !== '632773652848574484') return;
    if (reaction.message.channel.type !== 'dm') return;
    if (reaction.emoji.name !== 'wastebasket')

        await reaction.message.delete({ timeout: 500 })
})``` could someone point me in the right direction?
#

using discord.js v12

zenith orchid
#

For old messages?

final stone
#

Just messages sent before the bot was online, I get this error
0|index | TypeError: Cannot read property 'id' of null

#

its not erroring at the message.author.id check, as it works fine without it

#

same error when using old messages

digital ibex
#

ur message event?

#

or messageCreate?

zenith orchid
#

Bot can't find message.

earnest phoenix
#

the author*

zenith orchid
#

You can use partials.

final stone
#

I am using partials currently

#

const client = new Discord.Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });

#

I don't have much experince with partials so that might be the issue.

#

the bot works with any messages that were sent when it was on, but after a reboot the same messages pull that error

zenith orchid
#
try {
await reaction.message.fetch()
} catch (err){
console.log(err)
}
}```
final stone
#

so wait how would I intergrate this? would it just be putting that in the front, where would the code go exactly?

#
    if (reaction.message.partial) {
        try {
            await reaction.message.fetch()
        } catch (err) {
            console.log(err)
        }
        if (user.bot) return;
        if (reaction.message.author.id !== '632773652848574484') return;
        if (reaction.message.channel.type !== 'dm') return;
        if (reaction.emoji.name !== 'wastebasket')
            await reaction.message.delete({ timeout: 500 })
    }
})```
Like this?
zenith orchid
#

Done

clear wraith
#
    at RequestHandler.execute (/rbd/pnpm-volume/3e0e7ff0-a6f9-4413-afc4-43ee427079be/node_modules/.registry.npmjs.org/discord.js/12.2.0/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
    at processTicksAndRejections (internal/process/task_queues.js:88:5)
(node:23998) 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)``` 
How can I fix this? I am trying to run the command but nothing shows, And that message shows in the logs.
final stone
#

It works! @zenith orchid thanks for the help

zenith orchid
#

@clear wraith Can you show your code for me?

clear wraith
#
const superagent = require("superagent");

exports.run = (client, msg, args) => {
  var fs = require("fs");

  fs.readFile("./e/cmds.json", "utf8", function(err, contents) {
    var c = JSON.parse(contents);
    if (c.nsfw === "0") {
      msg.channel.send();
    } else {
      cc();
    }
  });
  function cc() {
    const notnsfw = new discord.MessageEmbed()
      .setTitle("NSFW not allowed here")
      .setDescription("Use NSFW commands in a NSFW marked channel")
      .setColor("BLUE")
      .setTimestamp()
      .setImage("https://i.imgur.com/oe4iK5i.gif");
    if (msg.channel.nsfw === true) {
      superagent
        .get("https://nekobot.xyz/api/image")
        .query({ type: "4k" })
        .end((err, response) => {
          msg.channel.send({ file: response.body.message });
        });
    } else {
      msg.channel.send(notnsfw);
    }
  }
};
#

Hopefully i was allowed to do that... since its kinda NSFW

#

But there's the code @zenith orchid

zenith orchid
#

I think there is no error, wait i'm trying this code

clear wraith
#

ok

copper cradle
zenith orchid
#

@clear wraith hey, there is no error.

earnest phoenix
#

someone can help me my bot does not work

#

what doesn't work

#

my bot

#

yes but what part of it

prime cliff
#

Is that nsfw...

earnest phoenix
#

logging in? message event? what doesn't work

zenith orchid
earnest phoenix
#

{
"resource": "/c:/Users/Vicente/Desktop/Bot-dunner/package.json",
"owner": "generated_diagnostic_collection_name#0",
"severity": 4,
"message": "String does not match the pattern of "^(?:@[a-z0-9-~][a-z0-9-.~]*/)?[a-z0-9-~][a-z0-9-.~]*$".",
"startLineNumber": 2,
"startColumn": 11,
"endLineNumber": 2,
"endColumn": 25
}

grim aspen
#

i swear that's an nsfw image

prime cliff
#

Same LULW imagine testing your bot in an nsfw channel

copper cradle
#

the image is indeed nsfw

earnest phoenix
#

read above for context

#

and ping, you don't know what their json file looks like so you can't get the exact same result

copper cradle
#

{
"resource": "/c:/Users/Vicente/Desktop/Bot-dunner/package.json",
"owner": "generated_diagnostic_collection_name#0",
"severity": 4,
"message": "String does not match the pattern of "^(?:@[a-z0-9-~][a-z0-9-.~]*/)?[a-z0-9-~][a-z0-9-.~]*$".",
"startLineNumber": 2,
"startColumn": 11,
"endLineNumber": 2,
"endColumn": 25
}
@earnest phoenix what is that supposed to be?

#

and how does that help us on helping you at all

earnest phoenix
#

where it says message it says the problem but i dont understand

copper cradle
#

yesh but like

#

show your code

#

ffs

#

am I supposed to guess what your code looks like?

earnest phoenix
#

this?

copper cradle
#

omfg

#

not like that

zenith orchid
#

No

copper cradle
#

use code blocks

grim aspen
#

TOKEN

earnest phoenix
#

aa

zenith orchid
#

TOKEN ALERT

copper cradle
#

omfg

#

that's not the worst thing

#

Why are you creating a message event for EVERY command

#

that's the worst code I've ever seen here

#

and I've seen some shit

#

but it's readable at least

#

btw reset your token

#

you just leaked it

earnest phoenix
#

im sorry i just starting

copper cradle
#

don't worry

#

tho you should google about good and bad practices

earnest phoenix
#

ok

copper cradle
#

programming practices*

earnest phoenix
#

i think the bot stop working because i change the name

copper cradle
#

no

#

Send your code (inside a codeblock) and don't leak your token

#

I'll try to help

#

changing the name has nothing to do with it

valid frigate
#

ok so as a general question i'm using c++14 and i'm wondering should i define a bitmask in binary or hexadecimal? eg should i be using
constexpr std::uint_fast8_t mask{ 0b0000'0001 };
or
constexpr std::uint_fast8_t mask { 0x1 }?

copper cradle
#

it's more readable

#

hex

valid frigate
#

ah

#

do people use hex more or

earnest phoenix
#

it doesn't matter

#

which one you use

amber fractal
#

it's the same in the end

valid frigate
#

oh so either one

copper cradle
#

yeah

#

tho hex is more readable

valid frigate
#

i suppose ill use hex then if its easier to read

copper cradle
#

if I see 0b0000'0001 with no context I won't instantly know what it is

#

tho if I see 0x1

#

then

valid frigate
#

ah

earnest phoenix
#

hex is more readable but the result is the same, you're probably using an AOT compiler which takes care of that value and produces the same machine code instruction regardless of whether the type is bin or hex

valid frigate
#

would there ever be a scenario where it does matter

#

out of curiosity

earnest phoenix
#

can't think of one

final stone
#

Ok, so I have ran into the same issue (https://discordapp.com/channels/264445053596991498/272764566411149314/704820927279661077) and thought I fixed it, turns out I did not. I think I know the issue now, that my discord.js message cache is not caching the new messages. as the onmessagereaction does not even detect them. Part of my issue was fixed here (https://discordapp.com/channels/264445053596991498/272764566411149314/704823459133521991)

But it still persists.
Is there any way to bypass cache to test it?

earnest phoenix
#

fetch returns the message object, i don't think it updates the existing one

delicate zephyr
#

You can tell the fetch function to cache when fetching

final stone
#

well now actually that I think about it, its the exact opposite, old messages work, but new messages arent even detected by the event

delicate zephyr
#

@final stone it wont detect event from uncached messages

earnest phoenix
#

because you locked that behind a partial check

#

new messages aren't going to be partial

delicate zephyr
#

which means you'll have to store the ids for the messages you want to track, or enable the reaction event partial

final stone
#

The partial is enabled.

#
const client = new Discord.Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'] }); 
delicate zephyr
#

then you should store the message ids of the messages you want to track the events of and fetch and cache them on bot start

final stone
#

so how can I store them? I am looking at the docs right now and I think I might be blind as im not seeing a way to cache messages it sends or anything.

delicate zephyr
#

store the channelid and message id and then you should be able to do:
Channel.messages.fetch(id, true)

#

true tells it to cache when fetched

final stone
#

so that should fix the issue of not being able to see new messages?

delicate zephyr
#

what do you mean its not caching new messages? discord.js caches all new messages unless you'd told it otherwise

final stone
#

The bot im making is a simple bot which provides UUID's for a system im making, when a user joins, he is sent a UUID, the onMessageReaction event does not detect this, however when restarted, it detects the message and it functions properly.

final stone
#

im confused by the statement, new messages arent going to be partial? (Im still getting used to partials)

earnest phoenix
#

they're going to be in cache

delicate zephyr
#

New messages wont be partial, since they are being cached when they are recieved

earnest phoenix
#

tldr discord does not send you the entire object on these events, just the id (hence partial, it doesn't have the rest of the object properties). that's why you need to fetch it to get the rest of the data you want

delicate zephyr
#

yea

#

discord be like that

final stone
#

so wait if it sends over the id it should be very simple to get the object right?

earnest phoenix
#

that's what you're doing with fetch, yes

delicate zephyr
#

yea just fetch the pre-existing message

#

which is where you would use Channel.messages.fetch(id, true)

tough relic
#

Hello guys! How can I give a role to the person who write the message without having him to ping himself in the message?

earnest phoenix
#

however, new messages aren't partial because discord.js internally caches new messages and has the data in store already before you get the reaction event, so they aren't partial, they're stored internally

#

Hello guys! How can I give a role to the person who write the message without having him to ping himself in the message?
@tough relic in which library

tough relic
earnest phoenix
#

get the message author from the context

final stone
#

So confused right now, so do I need a third party db or anything to store the id? or can I just use this?

        let usermsg = reaction.message.channel.fetch(reaction.message.id, true)
tough relic
#

thanks cry

earnest phoenix
#

@final stone which lib ver are you using? because that's incorrect for d.js v12

final stone
#

yeah d.js v12, still getting used to it.

final stone
#

aah

earnest phoenix
#

make sure to await fetch and you're all set

final stone
#

wait so the above Is valid? if corrected, so I can fetch using just partials?

earnest phoenix
#

the above isn't valid, no, what i posted is

#

and yes, partials contain the id in them which means you can fetch them

final stone
#

thanks a lot! I will test it out now

delicate zephyr
#

doesnt fetch also allow you to store the message in cache after fetched

final stone
#

I modified my code to ```js
let usermsg = await reaction.message.channel.messages.fetch(reaction.message.id, true)

delicate zephyr
#

oh the default is true

#

so you dont need the true there

final stone
#

oh woops

delicate zephyr
#

๐Ÿ‘Œ

final stone
#

also is it the same thing for user? do I have to fetch that or does user provide an obj?

fresh bough
#

my commands are not working and the only one that worked was my 8ball command

pale wadi
#

Someone knows why this isn't working (to verify a dc bot, idk if this is the correct channel lmao)

final stone
#

ex: would i have to do this, or is this redundant
let usr = await client.users.cache.fetch(user.id)

earnest phoenix
#

doesnt fetch also allow you to store the message in cache after fetched
@delicate zephyr yeah, fetch first looks up the cache and if it isn't found in cache then it actually fetches and stores in cache

delicate zephyr
#

ah cool

summer torrent
delicate zephyr
#

I knew that fetch had a boolean but didnt know it was true by default

final stone
#

tbh why would you not cache it? :p

delicate zephyr
#

stop you spamming the api when you already have the data

earnest phoenix
#

memory

final stone
#

ah

#

well thanks for the help, testing it now

#

Am I doing this right? Its still not detecting the message (aka this event is not triggering to new messages)

client.on("messageReactionAdd", async (reaction, user) => {
    if (reaction.message.partial) {
        try {
            await reaction.message.fetch()
        } catch (err) {
            console.log(err)
        }
        let usermsg = await reaction.message.channel.messages.fetch(reaction.message.id)
        if (user.bot) return;
        if (usermsg.channel.type !== "dm") return;
        if (reaction.emoji.name !== 'wastebasket')
            await usermsg.edit("Trashing Message.").then(async (e) => {
                await e.delete({ timeout: 500 })
            }).catch((err) => {
                console.log(err)
            });
    }
})```
I feel so stupid right now ![oliypls](https://cdn.discordapp.com/emojis/512280875283513346.webp?size=128 "oliypls")
earnest phoenix
#

you're still locking that code behind the partial check

final stone
#

oh yeah ๐Ÿคฆโ€โ™‚๏ธ

#

After putting it above the partial check it is no longer triggering for any messagesjs client.on("messageReactionAdd", async (reaction, user) => { let usermsg = await reaction.message.channel.messages.fetch(reaction.message.id)
Sorry for keepin ya busy on one question

delicate zephyr
#

you only need to fetch the message if partial is true though

earnest phoenix
#

it doesnt matter as it looks through the cache first

#

if you want to nitpick performance then yeah

#

and remove the partial check

final stone
#

just entirely?

earnest phoenix
#

you're still locking the rest of the code behind it

delicate zephyr
#

yea I know but realistically

if (reaction.message.partial) {
 // fetch here
}
//code here since 'message' will be from cache anyway```
earnest phoenix
#

the ideal code would be something like above

#
var m = msg.partial ? await fetch() : msg;

//proceed to use m normally
delicate zephyr
#

yep

earnest phoenix
#

i can flatten that actually

#

there

delicate zephyr
#

that is beautiful

final stone
#

wait so where are you getting the msg arg? from reactions.message?

earnest phoenix
#

yes

final stone
#

aah

#
    var msg = reaction.message;
    var m = msg.partial ? await fetch() : msg;
    if (user.bot) return;
    if (m.channel.type !== "dm") return;
    if (reaction.emoji.name !== 'wastebasket')
        await m.edit("Trashing Message.").then(async (e) => {
            await e.delete({ timeout: 500 })
        }).catch((err) => {
            console.log(err)
        });``` so this?
pale vessel
#

v a r

final stone
#

@pale vessel shut

earnest phoenix
#

don't forget to actually call fetch on the objects and fill out the args

#

other than that

#

yes

final stone
#

oh I thought ? await fetch() : msg; was fetching

earnest phoenix
#

that was just pseudocode telling you what you are supposed to do

final stone
#

ah my brain turned off lmao got it working

#

that took WAY too long for such a simple issue, thanks a lot!

pale vessel
#

you used msg.fetch() right? it's shorter

final stone
#

oh yeah better do that

digital ibex
#

hi, how can i fix this? Thonk
SyntaxError: Unexpected token o in JSON at position 1

pale vessel
#

read the error

#

or send a snippet of that json

digital ibex
#

the error is coming from: ```js
let banned = JSON.parse(fs.readFileSync('../../../blacklisted.json', 'utf8'));

pale vessel
#

ok the actual file

digital ibex
#
{
    "id": "oof!"
}
pale vessel
#

that's it?

digital ibex
#

yes

pale vessel
#

why not require?

sudden geyser
#

../../../ does not look right for fs.readFileSync

copper cradle
#

bc they're updating it

sudden geyser
#

also require caches the file

#

so it won't be up to date

copper cradle
#

@sudden geyser do you know what ../ means?

sudden geyser
#

yeah

pale vessel
#

you can use __dir

#

and add /../../

lyric mountain
#

../ is just navigating the directory

#

No issue there

copper cradle
#

the upper dir

pale vessel
#

the parent dir, yes

digital ibex
#

so, _dir/../../blacklisted.json?

earnest phoenix
#

how do i check if a number is NaN or not? I am using JavaScript

pale vessel
#

nono

copper cradle
#

no

sudden geyser
#

does ../ not read from the root of where your project started

lyric mountain
#

Unless you added more ../ than necessary

sudden geyser
#

at least it does for me

pale vessel
#

no

lyric mountain
#

@sudden geyser no

pale vessel
#

from the current dir

digital ibex
#

if(!NaN) @earnest phoenix

lyric mountain
#

../ is equal to cd ..

#

It goes one dir above

pale vessel
#

mine read from where my project started though

copper cradle
#

../ reads from the parent of the current dir

#

lmao

pale vessel
#

which is why i use __dirname

copper cradle
#

that's why I asked if you knew what ../ was

#

bc what you were saying said otherwise

digital ibex
#

๐Ÿ—ฟ

sudden geyser
#

I mean I tried it from ./src/commands/Developer/eval (fs.readFileSync("./package.json")) and it read from where the project root is just now.

earnest phoenix
#

@digital ibex thanks

copper cradle
#

show your console dir

#

and then you'll see why

digital ibex
#

np

sudden geyser
#

who me?

lyric mountain
#

./ is "in this dir"

copper cradle
#

../ is the parent dir

digital ibex
#

thats the issue?

#

huh

#

how

copper cradle
#

so if I have

#

no

#

well idk

pale vessel
#

is the utf8 needed btw

copper cradle
#

show your folder tree

#

yes

pale vessel
#

ok

digital ibex
#

me?

copper cradle
#

that utf8 is needed

#

if you have something like this

โ–ฌโ–ฌโ–ฌ root dir
โ–ฌโ–ฌโ–ฌโ–ฌโ–ฌ lower dir

if you're in lower dir then if you do ../ the selected dir will be root dir
digital ibex
lyric mountain
#

2 ../

copper cradle
#

../../blacklisted.json

#

there

#

not ../../../

lyric mountain
#

You've put more than necessary

digital ibex
#

when i do thw require(' in vsc

#

it like shows where u r

#

so

#

i fillowed that and it made me do ../../../

pale vessel
#

wait no

#

it's ../../../

digital ibex
#

yeah

pale vessel
#

did you read the tree

#

it's more to the left so it's in a parent dir

#

lol

copper cradle
#

oh shit you're right

digital ibex
copper cradle
#

maybe havng folding lines would help you lol

#

wait

#

you never told us the error you were getting

digital ibex
#

prolly shud've shown he commands folder

#

i did

pale vessel
#

it would've said no dir existed

lyric mountain
#

What's the first char in your json?

copper cradle
#

ah lol

digital ibex
#

and the error wasn't coming from anything to do with the ../.. thing lol

copper cradle
#

the file must look like this

sudden geyser
#

A question of mine: Why does the fs module try to read from where the project started rather than the relative directory like you guys are saying? When I try fs.readdir("./"), it shows the directory with the package.json file than what would be a command directory because it was used with an eval command in src/commands/Developer/eval.js

copper cradle
#

{ "": "" }

digital ibex
#

oh

copper cradle
#

not like a formatted file

pale vessel
#

let me see here

copper cradle
#

iirc when I was using json dbs I used to get that err

#

and got fixed when I changed the way the file was written

digital ibex
#

so

lyric mountain
#

Just noting, notepad actually messes your json file

digital ibex
#

?

pale vessel
#

ae.eval require("fs").readdirSync("./")

lyric mountain
#

So don't edit it with notepad

pale vessel
#

sorry

digital ibex
#

even tho that is a syntax error zsnails?

pale vessel
#

omfg

digital ibex
#

oh

#

i'm dumb

#

and never read

lyric mountain
#

@digital ibex go to https://jsonlint.com and paste your whole json

digital ibex
#

mb

#

i did

copper cradle
#

bruh

#

lmao

#

I didn't read your file lol

summer torrent
#

how can I get API latency ๐Ÿค”

pale vessel
#

lib?

sudden geyser
#

you send a request then check how long it took

summer torrent
#

djs

pale vessel
#

yeah send a request

#

i thought you meant ws latency

summer torrent
#

request to which page? does it matter?

pale vessel
#

doesn't matter

digital ibex
#

@copper cradle same error

sudden geyser
#

the most basic would be to send a message

pale vessel
#

your json is cursed man

sudden geyser
#

then edit it

digital ibex
#

how2uncurse

sudden geyser
#

did you save the file

digital ibex
#

yes

sudden geyser
#

what is the exact error

digital ibex
#

my json is just {"":""} now

#

Unexpected token o in JSON at position 1

sudden geyser
#

why don't you try removing the JSON.parse and console.log the output

digital ibex
#

ok

#

so like

earnest phoenix
#

why are you using JSON as a database in the first place

digital ibex
#
let banned = JSON.parse(fs.readFileSync('../../../blacklisted.json', 'utf8'));
// no, not ^^
let banned = console.log(fs.readFileSync('../../../blacklisted.json', 'utf8'));
//yes ^^
#

don't plan on blacklisting many people

lyric mountain
#

Show us output

digital ibex
#

ok

lyric mountain
#

Also, you cant let banned = console.log()

sudden geyser
#

it's just for testing

lyric mountain
#

But won't that cause errors?

sudden geyser
#

no

#

well it may if it's used

#

but it'll be undefined

lyric mountain
#

Js is weird

sudden geyser
#

"" == false

amber fractal
#

an empty string does evaluate to false, yes. Just like 0.

#

that's why when working with those types you use strict comparison

#

i.e. "" === false is false

sudden geyser
#

javascript

lyric mountain
#

Weirdscript

digital ibex
#

ok, it logs object object

lyric mountain
#

So we have an issue here

digital ibex
#

just got back mb

lyric mountain
#

Because it was supposed to output a string

digital ibex
#

oh

lyric mountain
#

Try using require instead

digital ibex
#

this is my whole code in my blacklist.js file ```js
if (!args.length) {
message.channel.createMessage('sur, u kno what to do');
} else {
let id = { "id": "${args[0]}"};
let banned = console.log(fs.readFileSync('../../../blacklisted.json', 'utf8'));

        fs.writeFileSync('../../../blacklisted.json', JSON.parse(banned));
        message.channel.createMessage(`done`);
    }
#

use require instead of what?

lyric mountain
#

Ok, just noticed something

#

You dont need to JSON.parse

digital ibex
#

hm?

lyric mountain
#

It's already getting a json

#

Object is a JSON actually

sudden geyser
#

pretty sure it doesn't

lyric mountain
#

Try doing Object.entries(readfilesync())

#

To see the output

copper cradle
#

the error is so easy to fix

#

set the file to {}

#

omg

#

I can't believe you put {"":""}

earnest phoenix
#

the json file needs to be parsed

digital ibex
#

i'm kinda very confused

lyric mountain
#

Ah

#

Omg

#

That's true

#

But still, it should return a string instead of an object

copper cradle
#

You're Officially Lost

digital ibex
#

mad confuso man

lyric mountain
#

Try doing Object.entries(readfilesync())

#

I wanna see what kind of object is being returned

digital ibex
#

ok

copper cradle
#

?

digital ibex
#

and btw, i set the json file to {}

#

it logs that @lyric mountain

lyric mountain
#

Lol

digital ibex
#

i'm so much more confused now

lyric mountain
#

Your json became an array of arrays

digital ibex
#

oh

lyric mountain
#

Oh, nope

#

It's just [object Object] as a splitted word

digital ibex
#
{} 
``` is just what what the blacklisted.json file looks like
#

oh lmao

#

wait, idk

#

its got numbers in it tho

lyric mountain
#

Try require

digital ibex
#

require instead of?

lyric mountain
#

Maybe there might be some dangling unicode chars in your json

sudden geyser
#

Your file says [object Object] because you wrote to the file a parsed JSON rather than a stringified version. In short, it was .toString()ified and became [object Object]

lyric mountain
#

Idk

#

Ahh, makes sense

#

So it wrote exactly [object Object]

digital ibex
#

hm, so, i need to Object() it

#

thungu?

lyric mountain
#

JSON.stringfy()

sudden geyser
#

I'm still not sure about that relative ../../../ as the fs module's file path is never relative to the current directory for me/the file I used it in.

#

but you need to:

  1. Fix the JSON file to be actual JSON.
  2. Use JSON.stringify in your fs.writeFileSync

3 (bonus). Avoid using JSON as a database.

astral yoke
#

use quick.db for a starter database its pretty good and helped me setup my setprefix command

sudden geyser
#

or sqlite (or any db) so you can use sql

digital ibex
#

ye, i already use mongo compass but i don't want to use anymore space lol, and i don't plan on blacklisting many users so a json is fine

lyric mountain
#

It's not

#

Json files are quite fragile

sudden geyser
#

if that file becomes corrupted don't blame us

astral yoke
#

^

digital ibex
#

ye and as i said lol, i don't plan on blacklisting many users

astral yoke
#

as we said, if it breaks dont run to us

digital ibex
#

ok

lyric mountain
#

Also sqlite will barely use any space at all

digital ibex
#

noted ๐Ÿ—ฟ

#

so i do ```js
let banned = JSON.stringify(fs.readFileSync('../../../blacklisted.json', 'utf8'));

#

?

sudden geyser
#

no

#
  1. Use JSON.stringify in your fs.writeFileSync
digital ibex
#

o, ok

#

so fs.writeFileSync('../../../blacklisted.json', JSON.stringify(banned));

#

?

lyric mountain
#

Yes

digital ibex
#

i get the same error, ```js
SyntaxError: Unexpected token o in JSON at position 1

lyric mountain
#

That's because your json is already dead

digital ibex
#

what should my json look like then?

lyric mountain
#

Simply reset it to {}

digital ibex
#

i did

lyric mountain
#

Then it's in the wrong path

digital ibex
#

oh?

lyric mountain
#

See if in 3 folders above your project one there's a file named blacklisted.json

digital ibex
#

it is the correct path

lyric mountain
#

Try with require then

#

See if it works

sudden geyser
#

@earnest phoenix do you happen to know if the fs module reads from the relative file directory of where it was called (e.g. src/hi -> fs.readdir("./") -> list of files from ./src/)

digital ibex
#

require instead of what tho?

sudden geyser
#

also sorry to ping

earnest phoenix
#

keyv has highly serve vulnerabilities

digital ibex
#
let banned = require('../../../blacklisted.json');
``` this what u mean?
lyric mountain
#

Yes

digital ibex
#

ok

earnest phoenix
#

iirc relative, @sudden geyser

sudden geyser
#

so the example I gave? when I try it, I always get where the project started aka the directory with package.json in it

earnest phoenix
#

oh

#

i guess that's where it starts out

#

you can always make a path to it with path.resolve() and __dirname though

sudden geyser
#

hmm

pale vessel
earnest phoenix
#

yeah you can also use that

#

resolve just does that iirc

pale vessel
#

like DIR in php

#

fucking markdown

digital ibex
#

still the same @lyric mountain, the json doesn't change

#

code: ```js
if (!args.length) {
message.channel.createMessage('sur, u kno what to do');
} else {
let id = { "id": "${args[0]}"};
let banned = require('../../../blacklisted.json');
//let banned = JSON.parse(fs.readFileSync('../../../blacklisted.json', 'utf8'));
//let banned = console.log(Object.entries(fs.readFileSync('../../../blacklisted.json', 'utf8')));

        fs.writeFileSync('../../../blacklisted.json', JSON.stringify(banned));
        message.channel.createMessage(`done`);
    }
pale vessel
#

it's not supposed to

#

oh

#

you're not writing anything to it lol

earnest phoenix
#

but you aren't changing anything

#

yeah

digital ibex
#

how would i do that? its my first time using a json as a db btw

earnest phoenix
#

it's an object

#

how would you change an object

copper cradle
#

wait

#

where do you have your console path set to?

digital ibex
#

my console path?

copper cradle
#

why are you using message.channel.createMessage tho

pale vessel
#

eris

copper cradle
#

oh yeah

#

true

#

I hate eris for that reason

pale vessel
#

wtf

#

why

copper cradle
#

jk

#

I don't hate eris lol

pale vessel
#

me angry

copper cradle
digital ibex
#

ur icon is now ironic

pale vessel
#

well it's all personal preference

earnest phoenix
#

for enmap do I need slqlite

pale vessel
#

answer cry's question

lyric mountain
#

Enmap?

pale vessel
#

how would you change an object

#

let's say banned is the object

digital ibex
#

yeah, i er

#

1 of 2 things:

pale vessel
#

oh?

digital ibex
#

String/Number... (object) ?

#

or

#

idk, i'm assumg

lyric mountain
#

wait, what?

pale vessel
#

no

#

it's like referring to a property but instead you're defining it

#

idk how to explain honestly

lyric mountain
#

banned = {user: somebody, reason: something}

digital ibex
#

huh

lyric mountain
#

but you gotta put it

#

instead of ovewriting

pale vessel
#

or banned[id] = { "reason": reason }

lyric mountain
#

that

digital ibex
#

but banned = require

lyric mountain
#

but reason doesn't need to have ""

#

js converts it automatically

pale vessel
#

so

{
  "id": {
    "reason": "blabla"
  }
}```
lyric mountain
#

JSON.parse()

earnest phoenix
#

what

#

you don't use JSON.parse

#

it already is an object

pale vessel
#

if you require you don't need it yeah

digital ibex
#

i'm confused

lyric mountain
#

officially lost

digital ibex
#

banned = require()

#

this name is not self proclaimed

pale vessel
digital ibex
#

my name is not

pale vessel
#

you are officially lost

digital ibex
#

no my question was

#

what i was confised about was

#

i ahve banned = require

#

and u said

pale vessel
#

please take your time writing

digital ibex
#

banned[id] = { }

pale vessel
#

yes?

digital ibex
#

but how does that make sense?

pale vessel
#

it writes it in memory

#

but not directly to the file

digital ibex
#

oh

#

oh

pale vessel
#

you need to put it to the file

#

which is why you need JSON.stringify()

#
  • fs
#

do you understand now

earnest phoenix
#

wait

#

why isnt that just an array if all they're going to store are ids

pale vessel
#

reason?

digital ibex
#

i'm just gonna store the id

earnest phoenix
#

oh

#

oh

#

my bad

digital ibex
#

my bad

#

ye

#

not reaon

lyric mountain
#

if it was sql it'd be only INSERT INTO Banned VALUES (:id, :reason) tsc tsc

digital ibex
#

just id and not reason

earnest phoenix
#

then you can make it an array

pale vessel
#

you could've done "banned": [] and push it if you don't need reason

earnest phoenix
#

or just made your file the array itself

pale vessel
#

yeah

#

i didn't know that can be done actually

digital ibex
#

so the file {[]}

lyric mountain
#

no

digital ibex
#

or

#

not

#

ok

earnest phoenix
#

no

#

{} indicates an object

#

brain exercise

digital ibex
#

ye

earnest phoenix
#

if you want it to be just the array, without objects, what would be the file content

pale vessel
#

i wonder

digital ibex
#

i want the file to just look like```json
{
"id": "an id",
"id": "another id"
}

pale vessel
#

why

earnest phoenix
#

that's not how json works

lyric mountain
#

you can't have that

#

because you can't have duplicate keys

digital ibex
#

oh

#

oh, well

pale vessel
#

maybe "id": true

#

so you can check

lyric mountain
#

where id would be the user's id

earnest phoenix
#

that would both waste JIT's time and lookup time

pale vessel
#

yes

#

why don't you just go with cry's array method

lyric mountain
#

so ```json
{
"590455379931037697": true,
"234703377999593472": true,
"350836145921327115": false
...
}

#

but still

#

an array would be better

pale vessel
#

no, true is just for checking

#

you don't need false

#

just omit the id if it's false

lyric mountain
#

ik, but whatever

digital ibex
#

ok, i'll use cry's way

lyric mountain
#

mono-valued jsons are as useful as a maserati in dirt road

pale vessel
#

make sure it's not {[]}

digital ibex
#

ok

lyric mountain
#

nor [{}]

#

and for the sake of god

#

no [{]}

digital ibex
#

ye, i know a bit more about json than that lol

lyric mountain
#

but you'll not use json

#

but an array

digital ibex
#

ok

hollow saddle
#

Quick question as the docs don't seem to be clear on this but does https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=overwritePermissions overwrite all preexisting permissions on the channel or just permissions defined in the overwrites parameter?

pale vessel
#

defined

hollow saddle
#

Ya know I did try it and it seemed to overwrite everything... no need to be rude

pale vessel
#

chill

#

sounds like something createOverwrite would do

#

don't know why it replaced everything

midnight blaze
#

How save is this evaluate function?
Can people abuse it and do more than simply some calculations?

#
      else if(isValidCommand(message,"mawdwdwdh")){
      const { inspect } = require('util');
      const args = message.content.split(' ');
      const command = args.shift().toLowerCase();

      
      if(!message.member.hasPermission('MANAGE_NICKNAMES')) return;
      let evaled;
      try {
      evaled = await eval(args.join(' '));
      message.channel.send(inspect(evaled));
      console.log(inspect(evaled));
      }
      catch (error) {
      console.error(error);
      message.reply('there was an error during evaluation.');
      }
summer torrent
#

eval must be bot owner only

daring garden
#

Any thoughts on why I might be getting random disconnects for a couple shards?

[WS => Shard 2] [CLOSE]
    Event Code: 1006
    Clean     : false
    Reason    : No reason received
#

It'll connect and then often immediately disconnect with that error

#

But usually only an issue with a couple random shards

#

Of course this continues and causes my auth attempts to run out and invalidates my token

midnight blaze
#

@summer torrent ah ok, hmm, why tho? It doesnt seem dangerous

#

from util

#

it has only inspect

daring garden
#

Anyone could execute any arbitrary code within the context of your app

summer torrent
#

I can reset your vps with eval

earnest phoenix
#

you can't make a truly sandboxed eval

#

simply don't give people you don't trust permission to use anything relating to eval

midnight blaze
#

aight,thanks. Wasnt 100% sure

sudden geyser
#

I mean in nodejs you can use the vm module but yeah it's better you avoid using eval at all times unless it's only for you.

clear wraith
#

can someone help me with this: (node:10060) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'cache' of undefined

#

Here is my code for that error...

#

let Invite = message.channels.cache.first().createInvite();

#

what did i do wrong?

#

its for my c!message [user id] [message] command.

hexed prawn
#

anyone know how to make a command that can give people tokens that are stored in a json file

wraith ibex
#

I forgot how the heck to make something dev only

#

i forgot to delete my DM command and instead want to make it Dev only

copper cradle
#

@clear wraith message doesn't have a channels property, it has a channel one, however, guild has a channels property, so you'd want yo use Message#guild

clear wraith
#

Ok, Thanks!

copper cradle
#

np

clear wraith
#

@copper cradle It says "cannot read property 'first' of undefined"". Would i just remove the .first()?

copper cradle
#

show your code

clear wraith
#

let Invite = message.guild.cache.first().createInvite();

copper cradle
#

๐Ÿคฆโ€โ™‚๏ธ

#

you forgot

#

channels

#

message.guild.channels

#

then .cache etc

clear wraith
#

Oh, wel Duh. Im half asleep. There we go! Thank you again.

#

I just made myself look dumb

copper cradle
#

lol

clear wraith
#

Anyway... Thanks again

#

(node:25207) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message

#

I did my message command, and it all went fine. But I got this message in my logs.

#

Do I need to do anything to fix that, or Is it not a thing you can fix?

copper cradle
#

show the entire log

stark terrace
#

anyone here using the sharding library kurasuta?

earnest phoenix
#

hello my bot to use a command to enter a voice channel and radio music played which does not stop and sometimes quits by itself can not be solved? CODE ```js
const Discord = require("discord.js");
const botconfig = require("../../botconfig.json");

module.exports = {
name:'start',
description: 'owner',
status: 'on',
async execute(bot, message, args, con) {
//code
con.query(SELECT * FROM servers WHERE sid = '${message.guild.id}' , (err, rows) => {
if(err) throw err;

    let nEmbed = new Discord.MessageEmbed()
        .setColor('#f76252')
        .setAuthor(`${bot.user.username} - SYSTEM`)
        .setDescription(":no_entry_sign: **access denied** :no_entry_sign:");

if(message.author.id != botconfig.owner) return message.channel.send({embed: nEmbed})

const ids = rows[0].musicchannelid

const channel = bot.channels.cache.get(ids);
channel.join().then(connection => {
connection.play('http://***************/live.mp3', {
    volume: 0.2,
});

})

});

//code
}}

astral yoke
#

wait is chalk broken

summer torrent
#

no

earnest phoenix
#

wait is having a command that sends an invite to your server against the rules?

stray wasp
#

@earnest phoenix unrelated to your issue

#

if you where inputting user generated data like you have your database could be easily be compromised

earnest phoenix
#

Fully encrypted all data

stray wasp
#

and when they drop all your tables then you have no data lmao

earnest phoenix
#

how do we throw up if no one has access?

stray wasp
#

?

copper fog
spare goblet
#

check the classes

copper fog
#

I'm quite new to HTML

#

sry

spare goblet
astral yoke
#

ok i have question, so when I install the verison from heroku and install it to my thing, and try and start it, it says in terminal that Error: Cannot find module 'chalk' so since heroku dosen't store the node_modules I did node install, and try to start it, it shows

[2020-04-28 22:59:34]: [Log]: Got data from botconfig file!
[2020-04-28 22:59:34]: [Log]: Note: If you want to exit the bot, type exit into the console.
[2020-04-28 22:59:34]: [Log]: Successfully loaded other files.

which shows four things, however it's supposed to show six. It's supposed to show this.

[2020-04-28 22:59:34]: [Log]: Got data from botconfig file!
[2020-04-28 22:59:34]: [Log]: Note: If you want to exit the bot, type exit into the console.
[2020-04-28 22:59:34]: [Log]: Successfully loaded other files.
[2020-04-29 05:41:17]: [Info]: Bot is online!
[2020-04-29 05:41:17]: [Info]: DogBot is 100% online!``` Which after waiting a few minutes, it dosent start up at all. If I try to update it on heroku it still shows the four and then I gotta revert it back to the one that didnt have it break. I need to know why its doing this because I'm very confused.
turbid bough
#

is chalk some kind of library to color stuff?

astral yoke
#

indeed.

#

it makes the date on the shown thing^ blue.

earnest phoenix
#

i want to make a website for my discord bot can i ask for help at there ?

#

this is my first init since before I changed to command handlers

astral yoke
#

do you have it where it like console.logs("bot online?")

earnest phoenix
#

nope shall do that right now

#

like I said I just switched to command handling

#
  if (!member.guild.me.hasPermission("MANAGE_CHANNELS")) return;```

Cannot read proprety โ€˜hasPermissionโ€™ of undefined
Who can help me?
#

why are you doing member.guild.me @earnest phoenix

#

verify if the bot hasperm

#

but i can't figure out what to put instead

#

@earnest phoenix

cinder patio
#

looks correct to me

#

me can sometimes be undefined tho, if your bot isn't cached

#

You should fetch your bot first

 const botInServer = await member.guild.members.fetch(member.guild.client.user.id);
earnest phoenix
#

How do i get the discord API ping? I am using Eris

mossy vine
#

send message, edit, get difference between timestamps

nocturne grove
#

HTTPError [AbortError]: The user aborted a request.
Is there any clear fix for this? I couldn't find one. Not here and not on the internet.
Anyone?

valid frigate
#

does the everyone role have an id

earnest phoenix
#

yes, it's the guild id

#

<@&264445053596991498> a fun little trick for mentioning it

feral quarry
#

Can someone help me with the welcome message setup?

sinful belfry
#

yeah i will try to help you out

#

so you want a welcome message?

#

what lib btw?

feral quarry
#

Yes, I figured out how to do the text but the joinheader, I want to be able to mention the user who joined but domt know how

#

Lib? sorry i donโ€™t understand

sinful belfry
feral quarry
#

Sorry, I really donโ€™t understand. Never seen that before. Itโ€™s just for a clan server Iโ€™ve made

sinful belfry
#

how are you making your bot?

#

are you using a programming language?

feral quarry
#

umm I donโ€™t believe so

#

Iโ€™m just adding a welcome message

earnest phoenix
#

what are you using to make it

sinful belfry
#

yeah, i am confused

#

you are talking about making a bot, correct?

feral quarry
#

Oh no no no

#

Iโ€™m using the ServerStats bot commands to create a welcome message

earnest phoenix
#

go to their support server

sinful belfry
#

-wrongserver

gilded plankBOT
#

Hey! We think you have our server mistaken. We do not provide support, help, or advice for any bot. You need to click on the "Support Server" button on the bot's page, not the "Join Discord" button at the top of our website. If there isn't a button that says Join Support Server, then we can't help you. Sorry :(

feral quarry
#

Oops

sinful belfry
#

lol it is okay

feral quarry
#

Sorry for the inconvenience

sinful belfry
#

dw

queen needle
#

thats my code if i do the command like ^google fish it doesnt send anything back

astral yoke
#

can someone help here please? i need someones help very bad.

tight plinth
#

show ur package.json @astral yoke

astral yoke
#
  "name": "dogbot",
  "version": "1.0.0",
  "description": "",
  "license": "MIT",
  "main": "src/index.js",
  "scripts": {
    "test": "node src/error.js",
    "start": "node src/index.js"
  },
  "dependencies": {
    "body-parser": "^1.19.0",
    "cathyjs": "^5.0.3",
    "chalk": "^2.4.2",
    "command": "0.0.5",
    "common-tags": "^1.8.0",
    "covid-19-tracker": "^1.1.0",
    "cpu-stats": "^1.0.0",
    "dateformat-light": "^1.3.3",
    "dblapi.js": "^2.4.0",
    "discord-economy": "^1.2.2",
    "discord-money": "^0.2.0",
    "discord-money-mongoose": "^1.1.2",
    "discord-webhook-node": "^1.0.5",
    "discord.js": "^11.6.1",
    "discord.js-commando": "^0.10.0",
    "discord.js-musicbot-addon": "^13.9.1",
    "discord_server_info": "^1.0.9",
    "express": "^4.17.1",
    "fs": "0.0.1-security",
    "json5": "^2.1.0",
    "long": "^4.0.0",
    "moment": "^2.24.0",
    "mongoose": "^5.9.2",
    "ms": "^2.1.2",
    "mysql": "^2.18.1",
    "node-fetch": "^2.6.0",
    "node-superfetch": "^0.1.10",
    "opusscript": "0.0.7",
    "pbl-api": "^1.0.3",
    "quick.db": "^7.1.1",
    "quick.eco": "github:inex07/quick.eco",
    "random-puppy": "^1.1.0",
    "request": "^2.88.2",
    "roblox-js": "^4.0.4",
    "sequelize": "^5.21.5",
    "sharp": "^0.25.2",
    "snekfetch": "^4.0.4",
    "sqlite": "^3.0.3",
    "strip-indent": "^3.0.0",
    "superagent": "^5.0.5",
    "urban": "^0.3.2",
    "uws": "^100.0.1"
  }
}
tight plinth
#

hm

#

r u sure there isnt a error somewhere in ur files?

pale vessel
#

chalk is 4.0.0 now

astral yoke
#

it surely doesn't show one.

tight plinth
#

even a return misplaced?

astral yoke
#

hm.

#

That's possible for my message handler maybe.

earnest phoenix
#
const Discord = require("discord.js");
const fs = require('fs');

module.exports.run = async (client, message, args) => {
    let blacklist = JSON.parse(fs.readFileSync("././blacklist.json", "utf8"));
    let user = args[0];

    if(!message.member.hasPermission("BAN_MEMBERS")) return message.channel.send(":no_entry_sign: **Nu ai permisiunea sa faci asta!**");

    if (!user) return message.channel.send(':no_entry_sign: **Trebuie sa introduci un ID**');
    
    if (!blacklist[user]) {
        message.channel.send(":no_entry_sign: **Acest utilizator nu este pe blacklist!**");
        return;
    };
    
    if (blacklist[user].state === false) {
        message.channel.send(":no_entry_sign: **Acest utilizator nu este pe blacklist!**");
        return;
    };

    if (blacklist[user].state === true) {
        blacklist[user] = {
            state: false
        }
    message.channel.send(":white_check_mark: **Utilizatorul a fost inlaturat de pe blacklist!**");
    fs.writeFile("././blacklist.json", JSON.stringify(blacklist), err => {
        if(err) throw err;
        return;
    });
    }
    
}

module.exports.run = {
  name: "unblacklist"
}

Do you guys have any idea why this doesn't work?

tight plinth
#

what doesnt work

pale vessel
tight plinth
#

^

earnest phoenix
#

Nothing if i type $unblacklist nothin happens

tight plinth
#

r u sure the command is properly registered

earnest phoenix
#

Yes, it worked on my other bot

astral yoke
#

chalk is 4.0.0 now
@pale vessel
should I update it? maybe thats why?

tight plinth
#

with the exact same code?

delicate zephyr
#

module.exports.run

#

what

earnest phoenix
#

oh

#

now i see

delicate zephyr
#

isnt it suppost to just be exports.run

earnest phoenix
#

discord.js v 11.5.1 not v12

tight plinth
#

module.exports = {
name: 'name',
run: async (client,message,args) {}
}

#

I suggest doing this

earnest phoenix
#

@tight plinth i saw

#

Is the same thing

tight plinth
#

lol

astral yoke
#

i hate this dangg thingggggggggggggg

earnest phoenix
#

I wrote module.exports.run not module.exports.help, this is why the commands don't work

#

๐Ÿ™‚

astral yoke
#

why is it breaking on me out of the blue not wanting to workkkkk

queen needle
astral yoke
#

ughhh

turbid bough
#

does anyone know good http request libraries?

#

the one im using takes 300ms and 2000ms for big requests

delicate zephyr
#

node-fetch

pale vessel
#

node-fetch

#

i second that

#

so easy to use too

earnest phoenix
#

if i have a file in /Bot/commands/ how should i write in fs.writeFile to write a file in Bot folder?

turbid bough
#

yeap, node-fetch does look simple to use

delicate zephyr
#

๐Ÿ‘Œ

turbid bough
#

um, also, is there an await fetch? or do i have to use .then?

pale vessel
#

nope

#

you can do

const res = await fetch("something");
const json = await res.json();```
#

pretty pog

turbid bough
#

ah, ok, thanks

queen needle
turbid bough
#

you are using ' within strings

#

if you want to use it you would need to add an escape character \

#

\`

queen needle
#

where?

turbid bough
#

check the description

#

"You didn't give me anything to search."

hasty sparrow
#

The string is using `

queen needle
#

that message sent and worked

#

already

turbid bough
#

ah ok. idk pastebin does not like that i guess

hasty sparrow
#

What happens when you run the command? Any errors?

queen needle
#

it doesnt send the message of what i googled

#

no

hasty sparrow
#

Log the response, maybe res.links is empty

queen needle
#

so

#

console.log(link)

hasty sparrow
#

*res.links

turbid bough
#

res.links. the for loop looks fine.

hasty sparrow
#

Or just res

queen needle
#
else {
                       console.log(res)
                       message.channel.send(`**Link**: [${link.title}](${link.href})\n**Description**:\n${link.description}`)
                       
                       
                     }```
#

so i did it like that and nothing was logged

hasty sparrow
#

Maybe log it at the top of the callback!?

queen needle
#

where?

hasty sparrow
#

Before your for-loop

queen needle
#

um

pale vessel
queen needle
#
 console.log(res)
                   for (var i = 0; i < res.links.length; ++i) {
                     var link = res.links[i];
                     if (!link.href) {
                       res.next;
                     } else {```
#

and okay

#

so i did that

#

and when i ran the command i got this

#

i cant even send it

#

there

#

it logged that

hasty sparrow
queen needle
#

yes

hasty sparrow
earnest phoenix
#
const Discord = require("discord.js");
const ms = require("ms");

module.exports.run = async (bot, message, args) => {
    if(!message.member.hasPermission("MANAGE_MESSAGES")) return message.reply(":no_entry_sign: **Nu ai acces la aceasta comanda! **");
  
  let tomute = message.mentions.members.first() || message.guild.members.get(args[0]);
  if(!tomute) return message.channel.send(":no_entry_sign: **Mentioneaza un utilizator!**"); 
  if(tomute.hasPermissions("MANAGE_MESSAGES")) return message.reply(":no_entry_sign: **Nu ai acces sa dai mute aceste persoane!**");
  if (message.mentions.users.first().id === message.author.id) return message.reply(':no_entry_sign: **Nu iti poti da mute singur!**');
  if (message.mentions.users.first().id === "427449842139267072") return message.reply(":no_entry_sign: **Nu imi pot da mute creatorului!**")
  let reason = args.slice(2).join(" ");
  if(!reason) return message.reply(":no_entry_sign: **Te rog pune un motiv!**")
  console.log(reason)
  let muterole = message.guild.roles.find(`name`, "muted");

//creare rol muted
  if(!muterole){
    try{
      muterole = await message.guild.createRole({
        name: "muted",
        color: "#000000",
        permissions:[]
      })
      message.guild.channels.forEach(async (channel, id) => {
        await channel.overwritePermissions(muterole, {
          SEND_MESSAGES: false,
          ADD_REACTIONS: false
        });
      });
    }catch(e){
      console.log(e.stack);
    }
  }
  //sfarsit creeare role
  let mutetime = args[1];
  if(!mutetime) return message.reply(":no_entry_sign: **Nu ai specificat un timp!**");

  await (tomute.addRole(muterole.id));
  message.reply(`**<@${tomute.id}> a primit mute pentru ${(mutetime)}**`);

  setTimeout(function(){
    tomute.removeRole(muterole.id);
    message.channel.send(`:white_check_mark: **<@${tomute.id}> a primit unmute!**`)
}, ms(mutetime));
}
``` This doesn't work aswell, help ?
hasty sparrow
#

Define "doesn't work"

turbid bough
#

what does not work

earnest phoenix
#

If i use the command nothing happen

turbid bough
#

ok

hasty sparrow
#

Any errors or console output?

earnest phoenix
#

Nope

#

All clear

turbid bough
#

can you add a console.log right before the create role command?

earnest phoenix
#

Ok

#

@turbid bough no error in logs

turbid bough
#

no, not that. do you even get a console.log?

earnest phoenix
#

yes

#

Idk why on this bot command doesn't work, on my other bot it worked ๐Ÿคทโ€โ™‚๏ธ

hasty sparrow
#

Are you sure the command is actually being executed?

earnest phoenix
#

i think so

quartz kindle
#

show the code that runs the command

earnest phoenix
#
bot.on('message', message => {
  
    if (message.author.bot) return;
    const args = message.content.slice(botconfig.prefix.length).trim().split(/ +/g)
    const cmd = args.shift().toLowerCase();
    if (message.content.indexOf(botconfig.prefix) !== 0) return;
  
    try {
        let commandFile = require(`./commands/${cmd}.js`);
        commandFile.run(bot, message, args, botconfig)
    } catch (err) {
        return;
    }
  })  
  
#

other commands work

quartz kindle
#

you remove the prefix

#

and then you check if the prefix is in position 0

#

ah nvm its on the original object

#

add a console.log here then

#

to see if it gets there

sick cloud
#

if i have something like this:

const email = document.getElementById('email').value || null;
const password = document.getElementById('password').value || null;

what would be the way to convert it over to jquery

quartz kindle
#

$("#email").value

#

i think

#

havent used jquery in years

earnest phoenix
#

@quartz kindle still nothing

sick cloud
#

ty

wheat jolt
#

is there a way how I can skip author avatar url for an embed?

#

I want to set an URL but not the avatar too

#

d.js@12.2.0

cinder patio
#

embed.setURL(url);

sick cloud
#

@wheat jolt embed builder?

#

should be able to do (name, null, url)

#

so just use null

wheat jolt
#

doesn't work

#

I already tried that

#

it throws not well formed url

#

embed.setURL(url);
@cinder patio for author not for title

pale vessel
#

author is setAuthor(name, icon, url)

wheat jolt
#

._.

#

yes

#

and I want to set only the name and url

#

not icon too

pale vessel
#

put null

#

not that hard

wheat jolt
#

-_-

pale vessel
#

just put ""

#

it works

wheat jolt
#

no

#

it doesn't

pale vessel
#

discord embed sometimes take null as a string

sick cloud
#

try a dummy url

cinder patio
#

try with undefined

pale vessel
#

did you try

sick cloud
#

use http://some.meme/url or something

#

it'll go through but not set

wheat jolt
#

actually you're right

#

actually you're not

#

:(

sick cloud
#

does it error

#

or just not even set the url

sick cloud
#

show the 3rd param

wheat jolt
#
`https://https://www.youtube.com/channel/${streamer.channelId}`
sick cloud
#

https://https://www.

wheat jolt
#

urgh

sick cloud
#

i'd also console log the channel id to be sure it's not causing it

#

if nothing works, use an embed object

wheat jolt
#

ok it works

#

thanks

sick cloud
#

๐Ÿ‘Œ

pale vessel
#

i really want nitro just to send the pepega emoji

turbid bough
pale vessel
#

sorry off topic

earnest phoenix
#

(node:22933) UnhandledPromiseRejectionWarning: RangeError: Invalid bitfield flag or number.

at Object.module.exports.run (/app/commands/ban.js:5:24)
at Client.bot.on.message (/app/index.js:42:21)

ban code:

 if(!message.member.hasPermission("MANAGE_MEMBERS")) return message.channel.send(":no_entry_sign: **Nu ai permisiunea necesara!**");

index.js code:

  
    if (message.author.bot) return;
    const args = message.content.slice(botconfig.prefix.length).trim().split(/ +/g)
    const cmd = args.shift().toLowerCase();
    if (message.content.indexOf(botconfig.prefix) !== 0) return;
  
    try {
        let commandFile = require(`./commands/${cmd}.js`);
        commandFile.run(bot, message, args, botconfig)
    } catch (err) {
        return;
    }
  })  
#

why i got this error ?

queen needle
#

thats my code and i have a problem the skip doesnt work the stop doesnt work and the queue doesnt work all that works is playing

pale vessel
#

@earnest phoenix there's no MANAGE_MEMBERS

#

perhaps you mean MANAGE_SERVER

earnest phoenix
#

oh

#

@pale vessel tyvm