#development
1 messages ยท Page 897 of 1
@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
display: none !important;
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
it responds with the id?
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)})
define it in headers maybe?
reaction.users.first I think
@true ravine
I did that and it doesnt cancel the bots reaction tho
and gives the bot the reward
but i get headers from the site the url directs to
reaction.users[1].id Then
@true ravine
Where at tho
Because the reaction collector still deletes the message when the bot reacts
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?
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
on the id?
It wont do anything
Becaus ethe message would delete before the user has a chance to react
dude you're literally deleting the message before checking for anything
what i wanna know is how to fix it
I assume this some code you got off the internet?
you're talking to a verified bot developer @true ravine
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
if they did then way less devs would be verified
Bruh my code is super inefficient, but it's all mine. The fact it's inefficient is because it's my own work lol
bruh
Bruh

The embed doesn't even show up
there
why the fuck is there a discord embed showing up
Idk
login with discord
lol
Use brakets like <this> e.g: < https://url.com > so the embed doesn't show up
Hm.
If send loads of queries to a database all at once will that cause any issues?
If you define loads and database we might be able to help ๐
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
I'm still getting the invalid user error, but i don't know from where it comes
Any idea ?
what are you using to define member
kinda
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
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.
Theres no error or nothing it should do it.
discord.js
debug
go through your code
try catch for possible errors
and console.log at closures
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.
might needa wait a bit for an update
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
For old messages?
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
Bot can't find message.
the author*
You can use partials.
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
try {
await reaction.message.fetch()
} catch (err){
console.log(err)
}
}```
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?
Done
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.
It works! @zenith orchid thanks for the help
@clear wraith Can you show your code for me?
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
I think there is no error, wait i'm trying this code
ok
just https://tryitands.ee
@clear wraith hey, there is no error.
someone can help me my bot does not work
what doesn't work
my bot
yes but what part of it
Is that nsfw...
logging in? message event? what doesn't work
{
"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
}
i swear that's an nsfw image
Same
imagine testing your bot in an nsfw channel
the image is indeed nsfw
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
{
"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
where it says message it says the problem but i dont understand
yesh but like
show your code
ffs
am I supposed to guess what your code looks like?
this?
No
use code blocks
TOKEN
aa
TOKEN ALERT
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
im sorry i just starting
ok
programming practices*
i think the bot stop working because i change the name
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
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 }?
it's the same in the end
oh so either one
i suppose ill use hex then if its easier to read
if I see 0b0000'0001 with no context I won't instantly know what it is
tho if I see 0x1
then
ah
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
can't think of one
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?
fetch returns the message object, i don't think it updates the existing one
You can tell the fetch function to cache when fetching
well now actually that I think about it, its the exact opposite, old messages work, but new messages arent even detected by the event
@final stone it wont detect event from uncached messages
because you locked that behind a partial check
new messages aren't going to be partial
which means you'll have to store the ids for the messages you want to track, or enable the reaction event partial
The partial is enabled.
const client = new Discord.Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
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
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.
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
so that should fix the issue of not being able to see new messages?
what do you mean its not caching new messages? discord.js caches all new messages unless you'd told it otherwise
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.
im confused by the statement, new messages arent going to be partial? (Im still getting used to partials)
they're going to be in cache
New messages wont be partial, since they are being cached when they are recieved
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
so wait if it sends over the id it should be very simple to get the object right?
that's what you're doing with fetch, yes
yea just fetch the pre-existing message
which is where you would use Channel.messages.fetch(id, true)
Hello guys! How can I give a role to the person who write the message without having him to ping himself in the message?
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
get the message author from the context
https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context.message
https://discordpy.readthedocs.io/en/latest/api.html#discord.Message.author
the context also has an author property if you want it to be shorter
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)
thanks cry
@final stone which lib ver are you using? because that's incorrect for d.js v12
yeah d.js v12, still getting used to it.
aah
make sure to await fetch and you're all set
wait so the above Is valid? if corrected, so I can fetch using just partials?
the above isn't valid, no, what i posted is
and yes, partials contain the id in them which means you can fetch them
thanks a lot! I will test it out now
doesnt fetch also allow you to store the message in cache after fetched
I modified my code to ```js
let usermsg = await reaction.message.channel.messages.fetch(reaction.message.id, true)
oh woops
๐
also is it the same thing for user? do I have to fetch that or does user provide an obj?
my commands are not working and the only one that worked was my 8ball command
Someone knows why this isn't working (to verify a dc bot, idk if this is the correct channel lmao)
ex: would i have to do this, or is this redundant
let usr = await client.users.cache.fetch(user.id)
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
ah cool
@pale wadi go to discord.gg/discord-developers
I knew that fetch had a boolean but didnt know it was true by default
tbh why would you not cache it? :p
stop you spamming the api when you already have the data
memory
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 
you're still locking that code behind the partial check
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
you only need to fetch the message if partial is true though
it doesnt matter as it looks through the cache first
if you want to nitpick performance then yeah
and remove the partial check
just entirely?
you're still locking the rest of the code behind it
yea I know but realistically
if (reaction.message.partial) {
// fetch here
}
//code here since 'message' will be from cache anyway```
the ideal code would be something like above
var m = msg.partial ? await fetch() : msg;
//proceed to use m normally
yep
that is beautiful
wait so where are you getting the msg arg? from reactions.message?
yes
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?
v a r
@pale vessel shut
don't forget to actually call fetch on the objects and fill out the args
other than that
yes
oh I thought ? await fetch() : msg; was fetching
that was just pseudocode telling you what you are supposed to do
ah my brain turned off lmao got it working
that took WAY too long for such a simple issue, thanks a lot!
you used msg.fetch() right? it's shorter
oh yeah better do that
hi, how can i fix this? 
SyntaxError: Unexpected token o in JSON at position 1
the error is coming from: ```js
let banned = JSON.parse(fs.readFileSync('../../../blacklisted.json', 'utf8'));
ok the actual file
{
"id": "oof!"
}
that's it?
yes
why not require?
../../../ does not look right for fs.readFileSync
bc they're updating it
@sudden geyser do you know what ../ means?
yeah
the upper dir
the parent dir, yes
so, _dir/../../blacklisted.json?
how do i check if a number is NaN or not? I am using JavaScript
nono
no
does ../ not read from the root of where your project started
Unless you added more ../ than necessary
at least it does for me
no
@sudden geyser no
from the current dir
if(!NaN) @earnest phoenix
mine read from where my project started though
which is why i use __dirname
that's why I asked if you knew what ../ was
bc what you were saying said otherwise
๐ฟ
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.
@digital ibex thanks
np
who me?
./ is "in this dir"
../ is the parent dir
is the utf8 needed btw
ok
me?
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
2 ../
You've put more than necessary
when i do thw require(' in vsc
it like shows where u r
so
i fillowed that and it made me do ../../../
yeah
oh shit you're right
maybe havng folding lines would help you lol
wait
you never told us the error you were getting
What's the first char in your json?
ah lol
and the error wasn't coming from anything to do with the ../.. thing lol
the file must look like this
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
{ "": "" }
oh
not like a formatted file
let me see here
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
so
Just noting, notepad actually messes your json file
ae.eval require("fs").readdirSync("./")
So don't edit it with notepad
sorry
even tho that is a syntax error zsnails?
omfg
@digital ibex go to https://jsonlint.com and paste your whole json
JSONLint is the free online validator and reformatter tool for JSON, a lightweight data-interchange format.
how can I get API latency ๐ค
lib?
you send a request then check how long it took
djs
request to which page? does it matter?
doesn't matter
@copper cradle same error
the most basic would be to send a message
your json is cursed man
then edit it
how2uncurse
did you save the file
yes
what is the exact error
why don't you try removing the JSON.parse and console.log the output
why are you using JSON as a database in the first place
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
Show us output
ok
Also, you cant let banned = console.log()
it's just for testing
But won't that cause errors?
Js is weird
"" == false
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
javascript
Weirdscript
ok, it logs object object
So we have an issue here
just got back mb
Because it was supposed to output a string
oh
Try using require instead
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?
hm?
pretty sure it doesn't
the error is so easy to fix
set the file to {}
omg
I can't believe you put {"":""}
the json file needs to be parsed
i'm kinda very confused
You're Officially Lost
mad confuso man
Try doing Object.entries(readfilesync())
I wanna see what kind of object is being returned
ok
?
Lol
i'm so much more confused now
Your json became an array of arrays
oh
{}
``` is just what what the blacklisted.json file looks like
oh lmao
wait, idk
its got numbers in it tho
Try require
require instead of?
Maybe there might be some dangling unicode chars in your json
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]
JSON.stringfy()
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:
- Fix the JSON file to be actual JSON.
- Use
JSON.stringifyin yourfs.writeFileSync
3 (bonus). Avoid using JSON as a database.
use quick.db for a starter database its pretty good and helped me setup my setprefix command
or sqlite (or any db) so you can use sql
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
if that file becomes corrupted don't blame us
^
ye and as i said lol, i don't plan on blacklisting many users
as we said, if it breaks dont run to us
ok
Also sqlite will barely use any space at all
noted ๐ฟ
so i do ```js
let banned = JSON.stringify(fs.readFileSync('../../../blacklisted.json', 'utf8'));
?
o, ok
so fs.writeFileSync('../../../blacklisted.json', JSON.stringify(banned));
?
Yes
i get the same error, ```js
SyntaxError: Unexpected token o in JSON at position 1
That's because your json is already dead
what should my json look like then?
Simply reset it to {}
i did
Then it's in the wrong path
See if in 3 folders above your project one there's a file named blacklisted.json
@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/)
require instead of what tho?
also sorry to ping
keyv has highly serve vulnerabilities
let banned = require('../../../blacklisted.json');
``` this what u mean?
Yes
ok
iirc relative, @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
oh
i guess that's where it starts out
you can always make a path to it with path.resolve() and __dirname though
hmm
for me i had to do this
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`);
}
how would i do that? its my first time using a json as a db btw
my console path?
why are you using message.channel.createMessage tho
eris
me angry

ur icon is now ironic
well it's all personal preference
for enmap do I need slqlite
answer cry's question
Enmap?
oh?
wait, what?
no
it's like referring to a property but instead you're defining it
idk how to explain honestly
banned = {user: somebody, reason: something}
huh
or banned[id] = { "reason": reason }
that
but banned = require
so
{
"id": {
"reason": "blabla"
}
}```
JSON.parse()
if you require you don't need it yeah
i'm confused
officially lost
my name is not
you are officially lost
no my question was
what i was confised about was
i ahve banned = require
and u said
please take your time writing
banned[id] = { }
yes?
but how does that make sense?
you need to put it to the file
which is why you need JSON.stringify()
- fs
do you understand now
reason?
i'm just gonna store the id
if it was sql it'd be only INSERT INTO Banned VALUES (:id, :reason) tsc tsc
just id and not reason
then you can make it an array
you could've done "banned": [] and push it if you don't need reason
or just made your file the array itself
so the file {[]}
no
ye
if you want it to be just the array, without objects, what would be the file content
i wonder
i want the file to just look like```json
{
"id": "an id",
"id": "another id"
}
why
that's not how json works
where id would be the user's id
that would both waste JIT's time and lookup time
so ```json
{
"590455379931037697": true,
"234703377999593472": true,
"350836145921327115": false
...
}
but still
an array would be better
ik, but whatever
ok, i'll use cry's way
mono-valued jsons are as useful as a maserati in dirt road
make sure it's not {[]}
ok
ye, i know a bit more about json than that lol
ok
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?
Ya know I did try it and it seemed to overwrite everything... no need to be rude
chill
sounds like something createOverwrite would do
don't know why it replaced everything
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.');
}
eval must be bot owner only
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
@summer torrent ah ok, hmm, why tho? It doesnt seem dangerous
from util
it has only inspect
Anyone could execute any arbitrary code within the context of your app
I can reset your vps with eval
you can't make a truly sandboxed eval
simply don't give people you don't trust permission to use anything relating to eval
aight,thanks. Wasnt 100% sure
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.
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.
anyone know how to make a command that can give people tokens that are stored in a json file
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
@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
Ok, Thanks!
np
@copper cradle It says "cannot read property 'first' of undefined"". Would i just remove the .first()?
show your code
let Invite = message.guild.cache.first().createInvite();
Oh, wel Duh. Im half asleep. There we go! Thank you again.
I just made myself look dumb
lol
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?
show the entire log
anyone here using the sharding library kurasuta?
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
}}
wait is chalk broken
no
wait is having a command that sends an invite to your server against the rules?
@earnest phoenix unrelated to your issue
if you where inputting user generated data like you have your database could be easily be compromised
Fully encrypted all data
and when they drop all your tables then you have no data lmao
how do we throw up if no one has access?
?
How can I make my bot's description yellow? I tried and I made the whole page yellow instead of the description box
check the classes
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.
is chalk some kind of library to color stuff?
i want to make a website for my discord bot can i ask for help at there ?
currently stuck at this phase
this is my first init since before I changed to command handlers
do you have it where it like console.logs("bot online?")
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
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);
How do i get the discord API ping? I am using Eris
send message, edit, get difference between timestamps
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?
does the everyone role have an id
yes, it's the guild id
<@&264445053596991498> a fun little trick for mentioning it
Can someone help me with the welcome message setup?
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
as in discord.js or discord.py etc.
Sorry, I really donโt understand. Never seen that before. Itโs just for a clan server Iโve made
what are you using to make it
go to their support server
-wrongserver
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 :(
Oops
lol it is okay
Sorry for the inconvenience
dw
show ur package.json @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"
}
}
chalk is 4.0.0 now
it surely doesn't show one.
even a return misplaced?
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?
what doesnt work
^
Nothing if i type $unblacklist nothin happens
r u sure the command is properly registered
Yes, it worked on my other bot
chalk is 4.0.0 now
@pale vessel
should I update it? maybe thats why?
with the exact same code?
isnt it suppost to just be exports.run
discord.js v 11.5.1 not v12
module.exports = {
name: 'name',
run: async (client,message,args) {}
}
I suggest doing this
lol
i hate this dangg thingggggggggggggg
I wrote module.exports.run not module.exports.help, this is why the commands don't work
๐
why is it breaking on me out of the blue not wanting to workkkkk
https://pastebin.com/jGhzfJxZ
thats my code if i do the command like ^google fish it doesnt send anything back
ughhh
does anyone know good http request libraries?
the one im using takes 300ms and 2000ms for big requests
node-fetch
if i have a file in /Bot/commands/ how should i write in fs.writeFile to write a file in Bot folder?
yeap, node-fetch does look simple to use
๐
um, also, is there an await fetch? or do i have to use .then?
nope
you can do
const res = await fetch("something");
const json = await res.json();```
pretty pog
ah, ok, thanks
does anyone know how i can fix my google search command https://pastebin.com/jGhzfJxZ
you are using ' within strings
if you want to use it you would need to add an escape character \
\`
where?
The string is using `
ah ok. idk pastebin does not like that i guess
What happens when you run the command? Any errors?
Log the response, maybe res.links is empty
*res.links
res.links. the for loop looks fine.
Or just res
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
Maybe log it at the top of the callback!?
where?
Before your for-loop
um
please use something like https://hastebin.com next time because pastebin is unbearable
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
Are you using https://www.npmjs.com/package/google ?
yes
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 ?
Define "doesn't work"
what does not work
If i use the command nothing happen
ok
Any errors or console output?
can you add a console.log right before the create role command?
no, not that. do you even get a console.log?
yes
Idk why on this bot command doesn't work, on my other bot it worked ๐คทโโ๏ธ
Are you sure the command is actually being executed?
i think so
show the code that runs the command
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
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
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 still nothing
ty
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
embed.setURL(url);
doesn't work
I already tried that
it throws not well formed url
embed.setURL(url);
@cinder patio for author not for title
author is setAuthor(name, icon, url)
discord embed sometimes take null as a string
try a dummy url
try with undefined
did you try
show the 3rd param
`https://https://www.youtube.com/channel/${streamer.channelId}`
https://https://www.
urgh
i'd also console log the channel id to be sure it's not causing it
if nothing works, use an embed object
๐
i really want nitro just to send the pepega emoji

sorry off topic
(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 ?