#development
1 messages · Page 987 of 1
Oh, i'm trying to do it for my object thing
in the embed, you can use attachment://name for the thumbnail
name must have an extension
you can just put image.png
yes, i am looking at the source for top.gg rn
<p class="is-flex"><span class="bot-name">Centauri</span>```
So if it's in a folder then my current setup is correct?
"dankmemes": "./images/dankmemes.png",
if you're going to reuse those files, you could preload them into buffers
i'm assuming you can use path for attachFiles, if i'm wrong, you have to use new MessageAttachment()
Tim can you use paths for attachFiles?
pretty sure you can
I am able to use paths for embed.setThumbnail right?
not directly for local paths, only remote url's can be used directly
you need to use the name you gave from attachFiles()
local paths need to be in attachment form
so let's say you added an attachment called file.png using embed.attachFiles(subredditImages[subreddit], "file.png"), you'll need to set the thumbnail to attachment://file.png
Honestly if doing it with paths is just going to complicate stuff more than it should, i'll just upload the images to imgur like i did last time lol
it won't, just an extra line of code to attach the image to the embed
i gave you an example
you can use attachFiles like addField(), just add it to your embed
is there a way to set in an embed the days since the server was created?
I have 03/03/2019 and i want 03/03/2019, (105 days ago) for example
So do i just do this my subredditThumbnails[json.subreddit] thing and also include attachFiles without breaking my setThumbnail
yeah
attachFiles requires a second parameter which is the file name
how do i do that
its basic math lol
name is optional actually
Date.now() gives you the current time in milliseconds, in javascript
just add attachment:// before thumbnail name then
sorry for the confusion
and attach the file using attachFiles(path)
how do i know in miliseconds the date when the server was created?
Wait so i'd put "attachment://./images/memes.png"
just the name
in discord.js you have a guild.createdTimestamp property
that's why giving it a name is easier
path, name
name would be something like "file.png"
so that you don't need to change anything on the thumbnail
You mean in here that's what i am on about
embed
.attachFiles([{attachment:"./my/path/here.png",name:"randomNameHere.png"}])
.setImage("attachment://randomNameHere.png")
should probably just use file options since it's just one image
why i get this when running my bot?
I'm pretty sure doing it with paths will stop my custom object from working
Or not idk
how to clear memory?
Bruh so how do i add all 3 files .attachFiles
why three?
i think i just made code mistake to get out of memory
ah images
The 3 images to attachFiles
nah, only the ones that are local
hi
you only need to attach files when the file is local, you dont need to attach remote files, such as the urls you get from the subreddit api
how to make your bot offline?
delete it from discord developer portal
but if you want to attach more than 1 local file, .attachFiles takes an array, if you havent noticed: ([{}])
Well i have 3 images in my directory and i want to be able to use all 3 so that my Thumbnail will work properly
so you can just add more attachments to the array
Okay
you only need to use one per command right?
you dont need to use all 3 in a single embed tho?
why attach three?
unless you're using them in different places
only attach the ones that you need to use
Because the thumbnail will be random
like thumbail, image, icon
Anyone speaking Pascal here?
Because my subreddits are random
but each message only sends 1 embed, right? for 1 subreddit
can i loop this?
i tried loop that and get out of memory
But then the subreddit changes on the next command execute
@dapper lynx the embed.attachFiles() method works on that single embed, not all embeds. for each different embed you need to attachFile again
no reason why you cant attach a different file every time
but you only need to add one line and change the thumbnail to a fixed name
So then if i attach just the memes png for memes subreddit then the other 2 won't have thumbnails
the path will be different dude
it changes every time you send the embed
I only have the 1 embed, it uses an api
a single embed cannot have multiple thumbnails
no like the path is based on the subreddit you get
so it'll be according to the subreddit, random or not
so you only need to attach one image
But then that one image will display on all subreddits?
dude
what are you not understanding
on each command, you check which subreddit it is, then from this subredit data you pick an image, then you attach this image, and you send the embed
rinse and repear
ok, here's a simple example:
.setFooter("bla");
.attachFiles(subredditThumbnails [json.subreddit], "name.png")
.setThumbnail("attachment://name.png")```
Can't you just use setImage multiple times?
that will replace the previous image
Oh makes sense
Btw dumb question but is there an eval I can run that logs the perms for my bot in the guild?
But if i hardcode a certain image to attachFiles then how is it going to change to a different image according to the subreddit
it's not hard coded
it's based on the subreddit your bot got, i even gave you the example
So do you just literally put "name.png"?
yeah, any name
so that you can use the same name for the thumbnail
otherwise, you'd need to get the file name from the file path, etc.; annoying
@pure lion if you have an eval command, just do the same thing you would do in a command
But idk what it is
guild#me
Oh thx
something like message.guild.me.permissions
that would be your bot as a guild member, which then you can get permissions
LMAO
so you can't use local path
dude you can just use urls man
it's not even worth it at this point
just upload it to imgur
That's what i said about the imgur but you two are insisting that this will work when it wont
It will work just not how i intend
attachFiles(new Discord.MessageAttachment(path, "name.png")) try this @dapper lynx
- you receive a command
- you read the reddit data from the reddit api
- you receive the reddit data
- you check which subreddit it is from the reddit data you received
- based on this subreddit, you pick the relevant path that you have saved for this subreddit
- you use this path and put it in embed.attachFiles()
- embed.attachFiles() lets you define a custom name for the file
- you use this custom name you defined to set it in embed.setThumbnail()
- you send the embed
The api, changes the data after a refresh, so it isn't as simple as 1 command for only 1 sub reddit and then a different command for another, everytime you run the same command with the same code the api has different data, so putting a certain image will not work because that same code will have different data from the api when it is next executed......
nobody said that
oh my god
you dont hardcode anything
dude
you pick a path based on the subreddit information you received
this
it can be as simple as ```js
if(subreddit === "memes") { path = "./images/memes.png" }
else if(subreddit === "dankmemes") { path = "./images/dankmemes.png" }
else if ....
embed.attachFiles([{attachment:path,name:"randomnamehere.png"}])
where subreddit is the data you received from the api, not from the command
aka json.subreddit
do you actually understand now xd
if (message.member.hasPermission("KICK_MEMBERS") || message.member.hasPermission("BAN_MEMBERS") || message.member.hasPermission("MANAGE_GUILD") || message.member.hasPermission("MUTE_MEMBERS") || message.member.hasPermission("DEAFEN_MEMBERS") || message.member.hasPermission("MOVE_MEMBERS") || message.member.hasPermission("MANAGE_NICKNAMES") || message.member.hasPermission("MANAGE_ROLES") || message.member.hasPermission("MANAGE_WEBHOOKS") || message.member.hasPermission("MANAGE_EMOJIS ")) return;```
When i try to send a message(for an anti link) with a user without them:
`(node:27019) UnhandledPromiseRejectionWarning: RangeError: Invalid bitfield flag or number.`
Discord.js: 11.6.4
I hate array and this isn't the problem for this error i think
yeah that's why i said anyway
Oh wait
anyway
Ok sorry
@earnest phoenix
one of the name is an invalid permission
Yeah lol
Sorry
I have found this
one of the name is an invalid permission
@pale vessel yeah
When i have sent the message here I've been thinking about the spaces
you can use an array, like .some
ahh
@pale vessel good suggestion, thanks!
@earnest phoenix no problem 🙂
🙂
Ik lol
if (message.member.hasPermission(["KICK_MEMBERS", ...permissions])) return
robux
he's using || so he needs to use .some
will that behave like || tho? or behave like &&?
I use || because i check only one permission per one permission 
&& [Tim]
&&
@pale vessel and i need || not &&
he's using || so he needs to use .some
@pale vessel
just compare the bitfield directly :^)
bitfield & bitfield
tim mentioned the array (hasPermission(array)) so i said that it acts like &&
so yeah
Oh ok
&& would be .every
how would you get a link from the other args in a command? Like ?command (link) and have the bot respond with the link in the message, for example, "message (link from the command)". If that makes sense, I use discord.js
hey. does anyone here have any experience making web dashboards that could help me?
guys
yes?
the code wont work
i think all the videos are old
node index.js wont work
says MODULE_NOT_FOUND
i cant even ones form 3 weeks ago are not working
modules need to be installed
hi
or put in the proper folder
const Discord = require("discord.js");
const client = new Discord.Client();
const db = require('quick.db')
const economy = new db.table('economy')
const ms = require('parse-ms')
module.exports = {
name: 'work',
description: "provides users money for working",
async execute (message, args) {
let timeout = 3.6e+6
let amount = Math.floor(Math.random() * 900 + -100)
let timer = await db.fetch(`timer_${message.author.id}`);
if (timer != null && timeout - (Date.now() - timer) > 0) {
let time = ms(timeout - (Date.now() - timer));
message.channel.send(`You can only work again in **${time.hours}h ${time.minutes}m ${time.seconds}s**`)
} else {
if (amount > 0){
let embed = new Discord.MessageEmbed()
.setColor("GREEN")
.setTitle(`**Work Money**`)
.setDescription("You have received **`"+amount+"`** coins. Nice work kid!")
message.channel.send(embed)}
else if (amount === 0) {
let embed2 = new Discord.MessageEmbed()
.setColor("YELLOW")
.setTitle(`**Work Money**`)
.setDescription("You have received **`0`** coins [No Money] for doing a terrible job lol.")
message.channel.send(embed2)
}
else if (amount < 0){
let embed3 = new Discord.MessageEmbed()
.setColor("RED")
.setTitle(`**Work Money**`)
.setDescription("*You have gained* **`"+amount+"`** *coins for doing a great job*. Yeah we fired you for destroying our office. Goodbye")
message.channel.send(embed3)
}
db.add(`money_${message.author.id}`, amount)
db.add(`daily_${message.author.id}`, Date.now())
}
}
}
this is my work command's code
but the cooldown isnt working
im using quick.db
...
wat
cooldowns should be done in the command handler

why not do all of them in the command handler
if your command handler is in index.js, yes
you using discordjs @dire stag ?
this guide is up to date 100%
tells me to make a index.js file and run a code
it also tells you to install some things
like discordjs, nodejs, linters, code editors
you need to explain whats going on better, else we cant help
like showing the errors, showing your code
for example you said you were getting module not found
which module? show the full error
i will redo again
i deleted the codes 3 times
Error: Cannot find module '/Users/private'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
what command did you run?
did you run it from cmd or from visual studio terminal?
or from powershell
show which files you have in your bot folder
show the contents of both main.js and index.js
also show the contents of package.json
Somewhere in your code you are requiring /Users/private wich doesn't exist
...
bot.on('message', async message => {
if (!message.content.startsWith(PREFIX)) return;
let args = message.content.slice(PREFIX.length).split(" ");
let messageArray = message.content.split(" ");
let command = messageArray[0];
if (!cooldowns.has(command.name)) {
cooldowns.set(command.name, new Discord.Collection());
}
const now = Date.now();
const timestamps = cooldowns.get(command.name);
const cooldownAmount = (command.cooldown || 3) * 1000;
if (timestamps.has(message.author.id)) {
const expirationTime = timestamps.get(message.author.id) + cooldownAmount;
if (now < expirationTime) {
const timeLeft = (expirationTime - now) / 1000;
function cooldown () {
return message.reply(`please wait ${timeLeft.toFixed(1)} more second(s) before reusing the \`${command.name}\` command.`);
}
}
}
once i have re coded them i will
Then press ctrl + S
im pretty sure this is how a cooldown is written
but it isnt working
^
can someone help
No its not that
oh
He made a function but he isn't calling it
you're defining command as the first word in the message content
not as a command from your command handler
Also that
what
You also have to call your function or it won't work either
you did this ```js
let messageArray = message.content.split(" ");
let command = messageArray[0];
meaning
messageArray is the content of the message split by spaces
and command is the first word of the message
so command is a string, a piece of text
i need to stop giving people guides on what they want.
they skip to the part that says what they want, and ignore everything else
therefore, command.name and command.cooldown dont exist, because command is a piece of text, not an object

oh
@solemn latch many people just come here expecting people will do the work for them and not do anything themselves
I used to aswell but then I realized it's way more fun if people set you on the right track but you find the solution yourself
bot.on('message', async message => {
if (!message.content.startsWith(PREFIX)) return;
let args = message.content.slice(PREFIX.length).split(" ");
const command = args.shift().toLowerCase();
if (!cooldowns.has(command.name)) {
cooldowns.set(command.name, new Discord.Collection());
}
const now = Date.now();
const timestamps = cooldowns.get(command.name);
const cooldownAmount = (command.cooldown || 3) * 1000;
if (timestamps.has(message.author.id)) {
const expirationTime = timestamps.get(message.author.id) + cooldownAmount;
if (now < expirationTime) {
const timeLeft = (expirationTime - now) / 1000;
function cooldown () {
return message.reply(`please wait ${timeLeft.toFixed(1)} more second(s) before reusing the \`${command.name}\` command.`);
}
message.channel.send(cooldown)
}
}
i changed it to this
what
cooldown()
its in the guide
if you want to use command.name and command.cooldown you need to define command as a command object from your command handler
ie client.commands.get(command) or something like that
https://discordjs.guide/command-handling/#command-handling
start there,
then work your way through the next three pages.
it covers everything you need in a command handler
idk where your commands are stored
and on the next page...
where do i store the index.js files?
ppl say that it should not be in the node section
in the same folder as package.json

read a line, understand what it does, then add it.
then go to the next line, read what it does then add it.
repeat.
@solemn latch 


okok
what type of screenshots you need?
everything you got
aaaaaaaaaaaaaaaaaaa
bot.on('message', async message => {
if (!message.content.startsWith(PREFIX)) return;
let args = message.content.slice(PREFIX.length).split(" ");
try {
bot.commands.get(command).execute(message, args);
} catch (error) {
console.error(error);
message.reply('there was an error trying to execute that command!');
}
if (!cooldowns.has(command.name)) {
cooldowns.set(command.name, new Discord.Collection());
}
const now = Date.now();
const timestamps = cooldowns.get(command.name);
const cooldownAmount = (command.cooldown || 3) * 1000;
if (timestamps.has(message.author.id)) {
const expirationTime = timestamps.get(message.author.id) + cooldownAmount;
if (now < expirationTime) {
const timeLeft = (expirationTime - now) / 1000;
function cooldown () {
return message.reply(`please wait ${timeLeft.toFixed(1)} more second(s) before reusing the \`${command.name}\` command.`);
}
message.channel.send(cooldown)
}
}
this is it now
still says command is not defind
lol
...
you need to define command 
how
woo can yall help me than help him?
@dire stag you showed exactly the file i dont need lmao, but good now i can see how your folder looks like
show your package.json and your index.js
yes
what do i do
@vale garden combine this with what you had before
take the word from the message content, like you were doing before, and use the word to obtain the command from the command handler
yessir
@vale garden just a heads up, it did say
"At this point, you can take that entire if/else if chain and delete it; you won't need anything past the const command = ... line. Instead, you'll be replacing it with this:"
instead you deleted everything, and copy pasted their code in.
which is why it didnt work
https://discordjs.guide/command-handling/dynamic-commands.html#dynamically-executing-commands
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@dire stag now in your package.json, where is says "main":"main", change it to "main":"index.js" and again save the file
bot.on('message', async message => {
if (!message.content.startsWith(PREFIX)) return;
const args = message.content.slice(PREFIX.length).split(/ +/);
const command = args.shift().toLowerCase();
if (!bot.commands.has(command)) return;
try {
bot.commands.get(command).execute(message, args);
} catch (error) {
console.error(error);
message.reply('there was an error trying to execute that command!');
}
if (!cooldowns.has(command.name)) {
cooldowns.set(command.name, new Discord.Collection());
}
const now = Date.now();
const timestamps = cooldowns.get(command.name);
const cooldownAmount = (command.cooldown || 3) * 1000;
if (timestamps.has(message.author.id)) {
const expirationTime = timestamps.get(message.author.id) + cooldownAmount;
if (now < expirationTime) {
const timeLeft = (expirationTime - now) / 1000;
function cooldown () {
return message.reply(`please wait ${timeLeft.toFixed(1)} more second(s) before reusing the \`${command.name}\` command.`);
}
message.channel.send(cooldown)
}
}```
see this
looks good to me
but the cooldown doesnt work
alright
@dire stag now open your terminal, and send a pic of your terminal
plus you need to define cooldown in your command itself, if you havent yet
should ı run it ?
confirm that your terminal is in the correct folder
run ls
and if its in the correct folder, it should show your index.js and package.json files
This doesnt work```ts
const server = http.createServer((req, res) => {
if (req.method === "GET") {
res.writeHead(200);
res.end("Hello!");
}
});
// Discord Bot List Client
const dbl = new DBL(token, {
webhookAuth: password,
webhookServer: server,
});
// Post Server Stats
const postStats = () =>
dbl
.postStats(guilds.size)
.then(() => log("Posted Stats", "DBL"))
.catch((err) => handleError(err, "Posting stats to DBL"));
postStats();
setTimeout(() => postStats, 1800000);
const webhook = dbl.webhook;
if (typeof webhook === "undefined")
throw new Error("DBL Webhook is undefined!");
webhook.on("ready", (hook) =>
log(Webhook running at ${JSON.stringify(hook, null, 2)}, "DBL")
);
// Every upvote means an extra boost
webhook.on("vote", (_, userId) => {
const main = async () => {
// If user exists good else create one
const userDoc =
(await User.findById(userId)) || new User({ _id: userId });
// Add one boost or two on weekends
userDoc.availableBoosts += (await dbl.isWeekend()) ? 1 : 2;
await userDoc.save();
log(User voted! ${userId}, "DBL");
};
main().catch((err) => handleError(err, "DBL Webhook"));
});```
What is this?
Ngrok Logs ```HTTP Requests
GET / 200 OK
POST /
GET / 200 OK
Console Logs[DBL] Webhook running at {
"hostname": "0.0.0.0",
"port": 0,
"path": "/dblwebhook"
}
[DBL] Listening on 5000
[DBL] Posted Stats
What do you mean by what is this?
plus you need to define cooldown in your command itself, if you havent yet
@solemn latch how
all i saw in the guide was
Anyone??
cooldown: time
ye
okay
@daring musk why are you doing (_, userId) => {
@daring musk why are you doing
(_, userId) => {
@quartz kindle I dont need the botId, Just need userId
yes but the event gives you a single object
WTF
The types are fucking messed up
assuming you're using dblapi.js
I am
user[message.guild.id] = {
userid: message.author.id
}```
I want to list all the values in the array as <@user[message.guild.id] .userid> how can I do this?
or how should I search this on the internet my english is not good
TimeoutOverflowWarning: 86400000000 does not fit into a 32-bit signed integer.
This is the second time I see your discord lib is mesed up
never trust ide/ts intelli/typings
did you run ls as i told you?
never trust ide/ts intelli/typings
@quartz kindle Welp, tsc complains if I dont trust them
dont use ts then :^)
WTF
@dire stag what text
ls
whats ls
(node:9148) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
cans-MacBook-Pro:JARbot ckara$ ls
index.js package-lock.json
node_modules package.json
ok
is your index.js saved?
did you save it again after putting your token back in?
yes
then run node index.js
nhandledPromiseRejectionWarning: 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(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
ok
cans-MacBook-Pro:JARbot ckara$ node index.js
(node:9155) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
at WebSocketManager.connect (/Users/can/JARbot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:135:26)
at Client.login (/Users/can/JARbot/node_modules/discord.js/src/client/Client.js:221:21)
(node:9155) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:9155) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
invalid token
where are you getting the token from?
you have to get it from the Bot section not the Application section
Any idea on how to sort strings in javascript? I know array.sort() would sort all strings in the array in ascending order but the problem is that the array contains objects, not strings
@dire stag no
if it says that the token is invalid, it means everything else is correct, except the token
I could map the array so it contains the strings that need to be sorted, but I need the array with the objects sorted as well
sort takes a sorting function
bruh
WTF Still doesnt work
hmmmm
so you can do .sort((a,b) => b.string - a.string)
if the object is {string:"something"}
stop spam
But doesn't string - string equal NaN?
function sortByDate( a, b ) {
if ( a.created_at < b.created_at ){
return -1;
}
if ( a.created_at > b.created_at ){
return 1;
}
return 0;
}
myDates.sort(sortByDate);//myDates is not sorted.
!p panda
so it's not sorting them
Last login: Tue Jun 23 10:56:17 on ttys000
cans-MacBook-Pro:~ ckara$ node index.js
internal/modules/cjs/loader.js:969
throw err;
^
Error: Cannot find module '/Users/can/index.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
cans-MacBook-Pro:~ ckara$
token is correct
Every article about sorting strings is using .sort() and .sort().reverse() but that's if the array is containing strings only? I can't imagine what the function for sorting strings in an ascending/descending order
@cinder patio ```js
function compare(a, b) {
if (a is less than b by some ordering criterion) {
return -1;
}
if (a is greater than b by the ordering criterion) {
return 1;
}
// a must be equal to b
return 0;
}
thats what the .sort() function wants to receive
^
I know, but how would I compare the strings
That's a thing??
@dire stag you opened your terminal to the wrong folder now
have i
function compare(a,b) {
return a.localeCompare(b)
}
localeCompare is good because it handles accents and stuff as well
i said something useful
oo
@dire stag what error now
how can i see which file im opening it from?
you see the current folder in the text before the area where you write
thanks
which file do you want me to open it from ?
from the same folder
in your previous terminal, you had cans-MacBook-Pro:JARbot ckara$
in the current you have cans-MacBook-Pro:~ ckara$
the previous was in the JARbot folder, the latter is not
ok
im on it
Last login: Tue Jun 23 11:50:51 on ttys000
cans-MacBook-Pro:~ ckara$ cd JARbot
cans-MacBook-Pro:JARbot ckara$ node index.js
(node:9206) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
at WebSocketManager.connect (/Users/can/JARbot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:135:26)
at Client.login (/Users/can/JARbot/node_modules/discord.js/src/client/Client.js:221:21)
(node:9206) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:9206) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
cans-MacBook-Pro:JARbot ckara$
well then you're either doing something wrong or using the wrong token
token is correct
recoding it wont make a difference
how are you inputting your token?
copy and paste
and you're copying it from the Bot section of your developer portal?
did you try regenerating it?
lets do it agaın
Just checking my logs while at work and noticed several 500 errors from Top.gg. I'm assuming this is just failing to post server/shards, etc?
ok i have regenarated it
Ehh... little issues here and there, so best you try to ignore them and wait until it's fixed
@slender thistle - Cheers. It's not affecting anything or causing any issues on my end. Could that be why my vote count seems to differ from Top's? Seems it missed sending me some
I assume so, yup
Yeah that should work @dire stag
its node
😩
https://anidiots.guide <<<<<
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(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:9242) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
cans-MacBook-Pro:JARbot ckara$
followed everything on the guide
E h?
https://anidiots.guide <<<<<
@restive furnace use thiw guide
eey
server.createChannel("testy", "text")```
so i have this
and it says server not defined
i tried `discord.server` but doesnt work
@royal granite message.guild
Lol
Oh ye that too-
wait so message.guild or just guild
Message.guild
@royal granite message.guild
Does anybody how to resize the image that's filled to a circle in canvas by clip so it doesn't zoon in like this?
Message holds all the info including IDs of the guild, roles, and other cache shit
oh rip message.guild.createChannel is not a function
Display image can crop and resize.
Uh
Or just resize
<message>.guild.channels.create()
@royal granite
@solemn latch i mean an image filled into a circle
Not one before it's filled
Why not resize it first, then fit it to a circle
Can't you use ffmpeg?
Not entirely sure but doesn't it have an image resize function ://
<message>.guild.channels.create()
@earnest phoenix wow it actually works, thx
I've made a few canvas games, resizing is entirly possible in canvas
Its just not very efficent
yeah its message for me lol
iterate through them
You shouldn't delete a group of channels imo.
Thats just one mistake command from deleting a lot of stuff
ill make a confirmation thing i guess
im making a bot which will automatically set up a premade discord server
so u just choose a template and u type start and it works
@solemn latch this is what i did... Have no idea
let canvasC = canvas.createCanvas(700, 329);
let ctx = canvasC.getContext("2d");
let mit = await canvas.loadImage("https://wompampsupport.azureedge.net/fetchimage?siteId=7575&v=2&jpgQuality=100&width=700&url=https%3A%2F%2Fi.kym-cdn.com%2Fentries%2Ficons%2Ffacebook%2F000%2F027%2F424%2Fjoke.jpg");
await ctx.drawImage(mit, 0, 0, 700, 329);
let itl = await canvas.loadImage(message.author.displayAvatarURL({
dynamic: true,
size: 2048,
format: 'png'
}));
itl.width = 50;
itl.height = 50;
await ctx.beginPath();
await ctx.arc(465, 150, 115, 0, 2 * Math.PI, true);
await ctx.closePath()
await ctx.clip();
await ctx.drawImage(itl, 0, 0)
await ctx.beginPath();
await ctx.arc(0, 0, 25, 0, 2 * Math.PI, true);
await ctx.clip();
await ctx.closePath();
ctx.restore();
message.channel.send({ files: [{ attachment: ctx.canvas.toBuffer(), name: "Canvas.png" }] });
})()```
//for of loop.
for let c of message.channels {...}```
I'd make it not be able to delete groups of channels that are older than a few days then
Since that function will likely only be used during the setup process anyway, it'll stop a lot of mistakes
Just a thought tho
im going to restart from scratch again
i already told you, changing the code wont help
the issue is the token
for some reason the token is invalid, and it will keep being invalid no matter how much you change the code
@earnest phoenix
ctx.drawImage(image, x,y, desired width, desired hight)
Where should i put that tho
for some reason the token is invalid, and it will keep being invalid no matter how much you change the code
@quartz kindle - From his post earlier he's using the secret, not the token
Is itl the users avatar?
@solemn latch yea
i already told him to get the token from the Bot section, he claims he did
Thats what you wanna scale, add , desired width, desired height
To it
Then make the circle the size you want
Lemme see
i will make a new bot
@dire stag Don't copy the secret from General Information. Copy the token from Bot.
the coding is wrong probably
I can get a screenshot
nooooo
nooooooooo

haha
stev you are right
guess who will be coding the 6 time today
i told you to get it from the Bot section before, and you said you did it...
love you stev
I could tell because you posted your client secret earlier...
Ohmygod well done-

ohhhhhhh
No, when you posted an example of what you were trying earlier, it had the secret that you were trying.

yessir
that was the porblem
anyways
il get back to you guys soon
thanks @quartz kindle for your effort
and the rest
i kinda enjoyed it
time to recode 2 bots to use MongoDB instead of Mysql. yay ....
mongodb is performanter. got already a Cluster Running -> 3 Nodes that work as a single Database
Is array random function possible?
i can set it up to write over the master node and read over the slave nodes
what did you want to have random?
some texts
you want to get a random thing from an array?
array[Math.floor(Math.random() * array.length)];
what do you mean
just make a rng function then
What Kyoya?
message.guild.channel.delete()```
`TypeError: cannot read property 'delete' of underfined`
Channel must be defined
message.guild.channel doesnt exist
you need a single channel instance
so you need to get the channel first
If you want to delete the channel the message was sent from
message.channel.delete()
Or what Steven said
yeah i want to delete the channel where the message was sent in
If you want to delete the channel the message was sent from
message.channel.delete()
@solemn latch
Sorry for the @ woo
Np
message.guild.channels.forEach(channel => channel.delete())```
`message.guild.channels.forEach is not a function`
did you...you know... upgrade to v12?
?
Are you using Discord.js v12
lol how do i check that
i tried to avoid asking that because it's so obvious what i was going to say lol
console.log(Discord.version) or npm ls discord.js
it literally says (empty)

well, read the migrating guide
channels have a manager now so you have to use channels.cache to access the cached channels
this applies to channels, roles, members, emojis, and users
the documentation for discordjs is really good
https://discord.js.org/#/docs/main/stable/general/welcome
and there are entire sections for changes on the guide
https://discordjs.guide/additional-info/changes-in-v12.html#commonly-used-methods-that-changed
everything you need like, how to get the channels in a guild, or how to get the channel a message was sent from is easily accessable on the docs
@weak willow you can ask the API how many guilds the bot is in
heya
could someone show me the usage of .delete
to delete webhooks, ive been struggling to do it for ages and i can't find example online
Hello guys, I know how to make bots and I just wanna know how do I invite my bot in this server?
you can ask the API how many guilds the bot is in
@lusty quest dumb question, but how buddy ?
Or get the role?
@earnest phoenix https://discordjs.guide/#before-you-begin
@weak willow what coding language did you use?
@earnest phoenix sorry
I know how to use discord.js I just wanna know how to invite my bot in for testing?
wrong
I know how to invite bots
then a button Add Bot appears on the top row
@weak willow what coding language did you use?
@lusty quest js
But will my bot be in the website? I wanna invite my bot in this server for testing, like #commands
For the Bot developer role.
if you add the bot to the website they will add the bot for Approving it, If Approved you get the Role and can use the bot here (if he uses a non common prefix)
Okay, will they test it?
K
console.log(bot.guilds.cache.size)
@lusty quest thnks sir
if yes ```javascript
webhook.delete([reason])
@lusty quest
I can't do it
it just deletes the message and not the webhook itself
did you got the webhook object?
(wb => wb.delete(['e']))
i never worked with webhooks inside of d.js but its possible that you cant delete them with code
ohh oops
Bruh, adding a brief description can be hard because of the errors.
I don't know if I have like 300 characters of letters in there.
just wait until the errors are fixed it shouldn't take long
its 300 or more isnt it 
did you count spaces or empty chars
hello
I counted spaces
Just copy the whole thing with ctrl + a and paste it into a character count website
And empty spaces
how do i get the amount of members in a guild
What library are you using?
its 300 or more, not less lol
d.js
it actually looks like you have two errors
Are you able to ban users using ID anymore? djs v12
guilds*
your breif description is too long, and your detailed description is too short
it says at least 300 and hes got 281
id is a member resolvable
That's actually a bit more complicated since the members are not guaranteed to be cached, you should fetch them all with await guild.members.fetch(); and then run guild.members.cache.size
If they are not in the guild
https://gyazo.com/fa56a66ee1675657b53983a4056a9a34
I don't know what I should put in this description
you can't ban a member that doesn't exist
so i need async
If you'd like
@misty sigil you can combine all guild's .memberCount property
your commands, and a explanation of your bot
you dont need to fetch all members
like reduce
Oh true discord returns that
so just message.guild.memberCount
yeah
@earnest phoenix in that black text area is where you should write a description with 300 characters or more.
Of what the bot is about?
yes
no
Bruh, This detailed description thing is so hard...
I am having trouble setting this up.
its just 300 chars
just use html/css
I don't know what I should do with html/css
you dont need to put anything in html or css, you can just write text
discord bot
i can easily get up to 2000 chars with html+css
they won't count those
ah ok
you dont need to put anything in html or css, you can just write text
@solemn latch Bruh
https://gyazo.com/d66603cbf5cce1d3376e75158756521a
This is getting on my nerves...
I didn't put anything in it in html description
you have to put something
Like what?
List your bot's commands, info about the bot... etc...
hi this bot is "bots name"
it is a general purpose bots
its commands are
!help - get help info for the bot
!ban - ban a user
etc etc
thats all it wants
yes
It says Spaces or empty spaces are not counted...
aslong as it is 300 chars
they are not counted for 300 chars no
300 chars is just a few sentences
how do i add a background to my bot site
background-image
Finally my bot is now pending!
😐
What's happening? https://kyoya.why-am-i-he.re/MtxDPP
sxcu.net free ShareX uploader
Anyone know of a way to reward users who vote for your bot?
I have an economy system but i can't figure out how to give them a rewards AFTER they voted
using a webhook #topgg-api
My bot doesn't respond to any command , any idea why ? I got no errors and the bot worked 2 hours ago, i didn't change anything in the code
yes, the bot is online
which means you cant control it
@amber fractal I know.
@willow river no 😇
what language are you coding in @willow river and what library?
JS 😊
https://discordjs.guide/
a fantastic guide with pretty much the basics of discordjs in it
I just want the code ready ,Please @solemn latch PLS PLS PLS PLS
no one's gonna give you code
🥺 😖 OK TY
I'm still having trouble trying to link voting rewards with the webhooks. The examples it gives is just for a specific user. How do i change it to recognize any user that votes?
Can i somehow make bot to send message in random channel?
anyone?
client.channels.random()
Guys help me
How i can find the the word A in a Array
let array = ["a", "b", "c"]
ty
array.includes('a')
?
lol
nah that is checking does array has a
you want to see if it exists in the array? or you want to get it from the array?
just use .find if you need something advanced
and want to get it from array and then change it
that requires splice
change it inside the array?
{
"comp":["beta"]
}
you can use .findIndex()
well this is the json file
is there a difference between findIndex and indexOf
and i want to find "beta" and change it to "alpha"
object.comp[0] = 'alpha'
Is there any ways ?

@pale vessel
you can find the index and change the value using splice if the index exists
@earnest phoenix ```js
a = [1,2,3,4,5];
a[a.findIndex(item => item === 4)] = 20;
console.log(a) // [1,2,3,20,5]
:0
that is more easier
if(!a[a.findIndex(item => item === 4)]) return console.log("error")
this will work ?
a = [1,2,3,4,5];
How i can delete the 5
using splice would probably be the easiest way
a.splice(index, 1) will delete 1 item from a at index
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice you can also use it to insert if you'd like
at index ?
Yes, the index provided
i have a problem
how can i fix it?
yep
yea just dont use the cmd for a few hours
ok thanks
Can i somehow create channels with bot like client.channels.create()?
yes
discord.js v12?
ty
How do I get how many times a certain command was used? for example: .addfield('Case', '#16')?
save the already used numbers somehow. since you say case, i assume this is for mod actions, then you'd want to persist this number in a db
Not for mod actions, each case for a contact command
https://hastebin.com/idipuyozew.js
(node:1500) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined
at module.exports.run (C:\Users\kenra\Desktop\Frosty Rewrite\src\commands\Utilities\Rank.js:16:46)
do you want it persistant or since the bot was last booted?
if just since the last boot, just add one each time a command is run
still, save the already used number somewhere. array, object. whatever. If you want to keep it even if the Bot restarts, persist it in a db
discord.js?
@earnest phoenix In discord.js v12 (I'm assuming you're using this) avatarURL needs to be a function
bruh
ur trolling
it's a rhetorical question
because they couldn't differentiate a function and an assignment
We don't need ur code lol
I said what you had to do
avatarURL needs to be a FUNCTION
hint ()
xd
Woo don't spoon feed xD
it's hard not to tbh
I say .setThumbnail(client.user.avatarURL) and it isn’t show it
@earnest phoenix it's .setThumbnail(client.user.avatarURL())
True
^
This kid is just full on spoonfeeding lol
no need for you to be salty about it
Wellp I tried to guide him 🤷♂️
some people just don't get it until they see it
Not salty lol
^
bruh
unless they just copy and pasted it and now it knowing that it does
bruh x2
think again, can you use that?






