#development
1 messages · Page 680 of 1
you can remove error event :/
'client.on('error', e => {
console.log(chalk.bgRed(e.replace(regToken, 'that was redacted')));
});' here
why would you remove the error event
why not :D?
its useful for handling errors
and also knowing what went wrong if something goes wrong
Alright..
Language: Python (3.7.4)
How would you get the x var from the first class to the second class?
class First:
def __init__(self, x):
self.x = x
class Second:
def __init__(self, y):
self.y = y
print(self.y + "X here")
Hi guys, you know how i can adding an image 16x16 in a text like a emoji ?
@pine edge go to your server settings and add a custom emoji.
You have to have at least Administrator perms on that server to do that tho.
And to use the emoji cross platform you have to have Discord Nitro
It is for discord bot @ruby talon
Oh
literally the same
No
Then type this in chat to receive your emoji id:
\emoji
If the bot is on other server he can't send the emoji i think
yes they can
sure ?
They can.
I go trying
I'm sorry I proposed my question wrong.
I mean like this:
class Client:
def __init__(self, secret_token):
self.token = secret_token
class User:
def __init__(self, user):
self.user = user
@property
def login(self):
utils.login(user_name=user, secret_token=token)
>>> client = Client(secret_token="xXxXxXxXxXx)
>>> user = client.User(user='name')
>>> user.login
So how do you assing the secret_token variable to the first self.token?
What the hell??
Is message defined correctly
Yes
Are you sure
I got this issue once for the past 3 weeks
It could be DMs
Ooo good point
That would make sense
I was going to say that I had already fixed this issue with regular messages
Try changing member to author and see if that works
Well I know message.author is a thing but I don't know about message.member if you want to get info about the person that sent the message it would be message.author
Hi
webhooks also dont have members
So happy my bot got accepted
same
Is it better to have 1 bot that can do everything
or 10 bots that do one specific task
generally people like a bot that's designated to do one thing
as then they can mix and match features to their liking
Trend goes to having
1-2 Features, perfectly implemented
instead of
10-50 Features shitty implemented
Are rpg bots actually worth making?
if you don't rush it and it's quality, yes
Whats this server's member count?
65032
epic
I think my bot just crashed
How make it ?
+help ping ?
Use option.match("ping") ?
I have a question : For discordv12 is guild.iconURL
but what is it for the current version?
Both guild icons and user avatars are functions now, so use the iconURL function instead
const fs = require("fs")
let coins = require("../coins.json");
module.exports.run = async(client, message, args, la) => {
let amount = args.join(" ")
if(!coins[message.author.id]) {
return message.channel.send("You do not have any Coins!")
}
let ccoins = coins[message.author.id].coins
let amout = args[0];
if(ccoins < amout) return message.channel.send("You do not have enough Coins!")
let result = ["lose", "win"]
let resault = Math.floor((Math.random() * result.length))
if(result[resault] === "lose") {
coins[message.author.id] = {
coins: ccoins - parseInt(amout)
}
fs.writeFile("./coins.json", JSON.stringify(coins), (err) => {
if(err) console.log(err)
});
const embed = new Discord.RichEmbed()
.setDescription(`You Bet **${args[0]}**\n🎰\nAnd lost **${amout}**`)
.setColor("RED")
message.channel.send(embed)
}
if(result[resault] === "win") {
coins[message.author.id] = {
coins: 3 * parseInt(amout) + ccoins
}
fs.writeFile("./coins.json", JSON.stringify(coins), (err) => {
if(err) console.log(err)
});
const embed = new Discord.RichEmbed()
.setDescription(`You Bet **${args[0]}**\n🎰\nAnd Won **the 3x Amount of your Bet**`)
.setColor("GREEN")
message.channel.send(embed)
return;
}
}
module.exports.help = {
name: "gamble",
aliases: []
}```
how can i make it that the `args[0]` gets displayed multiplied 3 times?
so that when i do !gamble 1000 and i win that this gets displayed: ```You Won 3000```
Python is so much easier
@twilit rapids so?
so use the iconURL function instead
use the iconURL function instead
but
Can you give me an example?
I'm not here to spoonfeed you
please
That's stable, not master
fuck
@earnest phoenix .setThumbnail(iconURL)
No
Hint: function()
no
bruh
thats what happens when you use youtube tutorials
YouTube tutorials are fine if you have knowledge yourself
Or don't learn the language itself and its basics
I mean, a function is one of the first things you encounter while developing a bit
I bet they all have them in their code
Well that's obviously
But do they know that it's named a function 
😩
return new Promise(async function(resolve, reject){
// Check if it's the good version
try {
guild.iconURL();
} catch(error){
if(error.message.includes("guild.iconURL is not a function")){
return reject("You must install and use discord.js version 12 or higher to use this package!");
}
}```
Where did you get that code from
install it by package...
npm i discord.js/discord.js afaik
thx @onyx summit
But just use the version property of d.js instead of checking if that function works
version 12 or higher
discord.js version 13 when????
no
probably never
But version locking for packages should be made in package.json / package-lock.json, not in the code
npm ERR!
npm ERR! error: cannot run ssh: No such file or directory
npm ERR! fatal: unable to fork
npm ERR!
npm ERR! exited with error code: 128
npm ERR! A complete log of this run can be found in:
npm ERR! /home/container/.npm/_logs/2019-08-23T12_31_05_041Z-debug.log```
Ok so I need some help here. 1 or 2
- I keep my current domain, vinniehat.tk, and append pbs.vinniehat.tk as my bot dashboard
- I keep my current domain, vinniehat.tk, and have a separate domain for my bot.
My bots name is Project BlueSquare, if we go route 2 what domain should it be?
I mean, tk domains are free, so I would just get a new one
@earnest phoenix my bad, it's npm install discordjs/discord.js
I was thinking you create pbs.vinniehat.tk as a bot page and pbs.vinniehat.tk/dashboard as the dashboard
That is what I was thinking
And then vinniehat.tk can stay as it is
Or I also do bluesquare.tk/dashboard
So I was stuck between pbs.vinniehat.tk/dashboard and bluesquare.tk/dashboard
const fs = require("fs")
let coins = require("../coins.json");
module.exports.run = async(client, message, args, la) => {
let amount = args.join(" ")
if(!coins[message.author.id]) {
return message.channel.send("You do not have any Coins!")
}
let ccoins = coins[message.author.id].coins
let amout = args[0];
if(ccoins < amout) return message.channel.send("You do not have enough Coins!")
let result = ["lose", "win"]
let resault = Math.floor((Math.random() * result.length))
if(result[resault] === "lose") {
coins[message.author.id] = {
coins: ccoins - parseInt(amout)
}
fs.writeFile("./coins.json", JSON.stringify(coins), (err) => {
if(err) console.log(err)
});
const embed = new Discord.RichEmbed()
.setDescription(`You Bet **${args[0]}**\n🎰\nAnd lost **${amout}**`)
.setColor("RED")
message.channel.send(embed)
}
if(result[resault] === "win") {
coins[message.author.id] = {
coins: 3 * parseInt(amout) + ccoins
}
fs.writeFile("./coins.json", JSON.stringify(coins), (err) => {
if(err) console.log(err)
});
const embed = new Discord.RichEmbed()
.setDescription(`You Bet **${args[0]}**\n🎰\nAnd Won **the 3x Amount of your Bet**`)
.setColor("GREEN")
message.channel.send(embed)
return;
}
}
module.exports.help = {
name: "gamble",
aliases: []
}```
how can i make it that the args[0] gets displayed multiplied 3 times?
so that when i do !gamble 1000 and i win that this gets displayed:
You Won 3000
Number(args[0]) * 3
^
wait thats to much for my retarded brain
Imaging getting 3x memes
Can anyone see anything blatantly wrong with this? I’m testing something and it keeps crashing my bot with no response. I think it’s stuck in an infinite loop, just not sure though
const a = '123446360538';
const b = a.split('');
for (let i = 3; i < b.length; i + 3) {
if (b.length - 3 > 0) {
b.splice(b.length - i, 0, ',');
} else {
break;
}
}
console.log(b.join(''));
why is i = 3
So I can start out inserting a comma 3 indexes from the end of the array
That’s what I thought
and what is the thing supposed to do
are you trying to join every item in the array with a comma
Insert a comma every 3 spaces of a string of numbers, like 123,134,124
Is there an easier way to accomplish this?
Yes
I mean, I just came up with this loop on the fly and clearly it’s flawed so
Just give me a minute
No problem
Oh wait... I just discovered Number.toLocaleString() 🤦
My actual value is a number, I was testing with strings since I remembered .splice
Damn I could’ve saved so much work for myself lol
Weird error... GuildAuditLogEntry.target is in the docs
My Code: https://gist.github.com/SinistreCyborg/e85fe2586e9dd3d8f9d4ce488f9dfc6f TypeError: Cannot read property 'joinedAt' of undefined
The target isnt defined
one sec
is this eris?
https://oliy.is-just-a.dev/hp2lav_1015.png is it any of these reasons it could be null?
Why you use eris
what version are you using
v12
How do you define MessageEmbed
const MessageEmbed = require ("discord.js")```
lmao
what ?
const { MessageEmbed } = require('discord.js')
Yup
it's up to the same
ok
It's called Object Deconstruction.
And you obviously don't know it, it's worth looking at
Not that it's very important, it's just nice to know
@earnest phoenix works now?
yes thx
Np
but
(node:14) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'calculatedPosition' of undefined
const { MessageEmbed } = require("discord.js");
module.exports.run = async (bot, message, args) => {
if(!message.guild.me.hasPermission("BAN_MEMBERS")) return ("**:x: Je n'ai pas la permission de bannir des membres !**")
let bUser = message.guild.member(message.mentions.users.first() || message.guild.members.get(args[0]));
if(!bUser) return message.channel.send("**:x: Veuillez mentionner un utilisateur.**");
let bReason = args.join(" ").slice(22);
if(!bReason) return message.channel.send("**:x: Veuillez joindre une raison.**")
if(!message.member.hasPermission("BAN_MEMBERS")) return message.channel.send("**:x: Vous n'avez pas la permission d'utiliser cette commande.**");
if (bUser.highestRole.calculatedPosition >= message.member.highestRole.calculatedPosition && message.author.id !== message.guild.owner.id) return message.channel.send("**:x: Vous ne pouvez pas bannir cet utilisateur.**");
if(bUser.hasPermission("BAN_MEMBERS")) return message.channel.send("**:x: Vous ne pouvez pas ban cet utilisateur.**")
bUser.send("**:warning: Vous avez été bannis du serveur " + message.guild.name + " par " + message.author.username + " pour la raison suivante : " + bReason + "**").catch(err => {
if(err) {
console.log("Impossible de DM")
}
}) ```
imao
message.guild.member(
I have questions
For information it worked in v11.5.1
That's ineffective, but valid
so ?
Search docs 
yeah
Probably something is deprecated
When you define buser
Or that
yes
What version
I can't find highestRole in master
Is v12 lauched?
So it's not
No that I know of, but it's stable enough to use in prod
npm install discordjs/discord.js
Mhm
you do not have to use it now but I prefer
I think he knows what it is, he just wanted to know if it was released
It's better in most ways
Because its taking quite a while
But internal sharding still has some problems, so you can't really call it completely stable
But you don't have to use internal sharding
ye
but
at Map.find (/home/container/node_modules/discord.js/src/util/Collection.js:173:49)
at Object.module.exports.run (/home/container/commands/admin/ban.js:19:37)```
so
but imao
let logs = message.guild.channels.find(`name`, "theking-logs");
looool
You need to use a function in find on master
ok
i don't find lol
client
createdAt
createdTimestamp
deletable
deleted
guild
id
manageable
members
name
parent
parentID
permissionOverwrites
permissionsLocked
position
rawPosition
type
viewable
Methods
clone
createInvite
createOverwrite
delete
edit
equals
fetch
fetchInvites
lockPermissions
overwritePermissions
permissionsFor
setName
setParent
setPosition
setTopic
toString
updateOverwrite```
i have just this imao
what
i don't find the channels.find in the doc
It's on collections
Put "collection" in the search bar
so interesting to see children learning
im not a children bro
I mean, are you looking at the right page?
https://discord.js.org/#/docs/main/master/class/Collection?scrollTo=find
then why are you doing channels.fn
but
but?
(node:14) UnhandledPromiseRejectionWarning: TypeError: fn.bind is not a function
code?
let logs = message.guild.channels.find(`name`, "theking-logs");```
so you arent actually reading it
or
interesting
let logs = message.guild.channels.find(c => c.name == "name")```
done ?
I guess
ok
wtf
TypeError: Cannot read property 'Client' of undefined
const { Discord, MessageEmbed } = require("discord.js");
const client = new Discord.Client();
const botconfig = require("./botconfig.json");
const bot = new Discord.Client({disableEveryone: true});
const fs = require("fs");
const Enmap = require("enmap");
const low = require('lowdb')
const FileSync = require('lowdb/adapters/FileSync')
const adapter = new FileSync('./db.json')
const db = low(adapter)
bot.commands = new Discord.Collection()
const giveaways = require ("discord-giveaways")```
oh boi
eeeek
what
Just a quick question, what are your indent sizes
5
const Discord = require("discord.js")
const client = new Discord.Client()
let prefix = "/"
client.on("message", message => {
if (!message.guild) return
let args = message.content.trim().split(/ +/g)
if (args[0].toLowerCase() === prefix + "clear") {
if (!message.member.hasPermission('MANAGE_MESSAGES')) return message.channel.send("Vous n'avez pas la permission d'utiliser cette commande")
let count = args[1]
if (!count) return message.channel.send("Veuillez indiquer un nombre de messages à supprimer")
if (isNaN(count)) return message.channel.send("Veuillez indiquer un nombre valide")
if (count < 1 || count > 100) return message.channel.send("Veuillez indiquer un nombre entre 1 et 100")
message.channel.fetchMessages({
limit: count
}).then(() => message.channel.bulkDelete(count))
}
})```
const Discord = require("discord.js");
const client = new Discord.Client();
let { prefix,token,presences } = require('./config.json');
let { remerciments,youtube } = require('../Commandes/index_commandes');
let { clear } = require('../Commandes/Modération/index_moderation');
client.on("ready" , function() {});client.on('ready', function() {
client.user.setActivity("/help | Codé par Ketji")
console.log("[LOGS]Bot connecté !")
});
client.login(" ");
client.on('message', message => {
const args = message.content.split(" ")
if(!message.guild) return;
if(message.author.bot) return;
if(message.content.startsWith(prefix + 'remerciments')) {
remerciments.execute(message);
} else if(message.content.startsWith(prefix + 'youtube')) {
youtube.execute(message);
} else if (message.content.startsWith(prefix + 'clear')){
clear.execute(message);
}
}
)```
can you send clear from ../Commandes/Modération/index_moderation
module.exports = {
clear: require('./clear'),
}```
okay then send ./clear
I have only that for clear
thinks
whats the best way of adding a white background to a canvas? i used to use sharp but for some reason it would just create a shit ton of issues and i cant find a better way of doing it
is it a good idea to mix arrow functions and regular nameless functions in the same library/package
If I said
if (message.guild.id == 264445053596991498 && !message.author.id == 184070212012736512) return;
That would make my bot(s) not respond to others on this server, right?
he is saying to use != but your way still works
wait you right, i had a brainfart 
@supple owl it wont, you are negating message.author.id
ah, hold up.
And one more issue that no one mentioned is that you probably meant to use || instead of &&
oh
wait, im retarded nvm
if (message.guild.id == 264445053596991498 && message.member.user.id != 184070212012736512) return;
this?
if (message.guild.id == "264445053596991498" && message.author.id != "184070212012736512") return;```
ok
then change it to ===
(so you might as well change them to === for even better practice)
@mossy vine yes you should make them strings
regardless of == not checking types
because of floating point rounding
Is Sentry used while developing to track errors or after the first version etc comes out
i'd rather get the errors on my terminal while developing
Same
Also one other thing. Do you know how I can use folders for my EJS files instead of just having them in the views section?
Sentry is meant for production
afaik
At least it doesn't make any sense to use in development, it's slower and less accurate than having the console output
Right
Is having one big server.js file better than having a separate file for each thing like login, etc?
anyone have problems with memory leak in js, when looping over promises ?
this works fine when i run it once, but as soon as i set it in a loop it eventually crashes from running out of memory
Well
@abstract crow Would be better to make the project modular. it makes everything more readable and modular
Do you ever remove stuff from postList
If you just keep looping and adding to it
Perhaps that's the problem?
wait is it adding more things to postList?
maybe make it show in terminal whats in postList maybe its duplicating itself
@unique nimbus
this is only from one run though
but it should clear the list before every loop
¯_(ツ)_/¯
in postList = [];
you dont need async in there, you also dont need to await postList.length
the end result is same right ?
you also dont need Promise.all at all, unless post.id is a promise, but im pretty sure its not
no
actually nvm
btw Promise.all(...).then(console.log(postList)) will ignore the result of the promises
yeah, first time im messing with promises inside a loop >.<
correction:
yeah, first time im messing with promises inside a loop >.<
if i understand what you're trying to do and what that reddit package is doing, you can rewrite the entire code simply into js postList = await r.getSubreddit(subreddit).refresh.getHot().map(t => t.id)
my main goal is just to loop through the posts of a subreddit, check their upvotes and save the id of posts with n or more upvotes
then add a filter
postList = (await r.getSubreddit(subreddit).refresh().getHot()).filter(t => t.ups > 1).map(t => t.id)```
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
same error
i've cut the code down to this now
are you joking
a while true?
never do while(true) without any way of delaying or stopping it, this will completely block the event loop.
and you run out of memory because you console log stuff
https://github.com/nodejs/node/issues/3524
console.log is async and will fill the memory, and because you are blocking the event loop it will never be freed
oh.
setInterval() exists
the idea was to have it constantly run, so as soon as a post got x amount of upvotes it would be saved into postList
and,
- your timeout won't timeout, it will instantly run in the next tick
- your loop will run as fast as it can and won't give a fuck about that timeout
so use setinterval() instead ?
you want to check every 2 seconds?
then setInterval will do
read that
you arent using setTimeout correct, it will run instantly
you also dont need to declare a timeout variable, you also dont need to declare an empty array in postList
in fact you dont need postList at all because its inside a function
you can return it directly instead
return (await etc).etc;
}
That code reminds me of my early js times lol
I understood the very basics in c# but in js It kinda looked like this
but honestly, i don't think i would ever realize that without your guys help xD
also, if i can't use console.log
is there an alternative to check that my loops work ?
you can use console.log
just not in while(true) ?
just not in a while(true) loop
aight
never use while(true) in general for anything
just remember:
while (true) without any delay or method to stop it, will completely kill js
while(true)
return;
very funny
yes
i thought, timeout would have added an delay
but apparently not
you're essentially queuing infinite tasks
but one of the only actual good use cases for a while loop is as an inverted for loop js let i = 100; while(i--) { //do something } because it is faster than a for loop
well, you can use timeout different, then it will work
for everything else, a regular for loop will do just fine
the performance difference is minimal
@onyx summit that timeout is correct```js
setTimeout(() => console.log(Date.now()), a = 2000); Date.now()
1566597563501
1566597565501```
<thing> = <value> evaluates to <value>

yes it does, its just an unneeded declaration lul
doesnt matter, the loop will still run without giving a fck bout the timeout
yup
tim: that's useless microoptimization
yup
any half decent compiler will be able to optimize
but confuses people, like me
microoptimization can be useful with heavy computation
but in 90% of the cases its really not needed
if you're doing heavy computation you wouldn't be using js
Natan always corrects me with tiny stuff and then I feel like I don't even know js 
you don't
and any language that's used for heavy computations will optimize that kind of thing
I probably get paid because I look good, and not for writing ts/js (jk I dont look good)
regardless, it exists and can be used, so why not
there are plenty cpu-intensive js stuff out there, such as pure-js implementations of some algorithms to be used in browsers
just write a cpp module and use it in node 
also the while is most likely going to be worse
make that while while(i--)
the pseudocode below is for that
so this doesn't work because the console.log executes before stuff is pushed to postList, right ?
why u awaiting postList.length
wait
interesting, that must be something new then
last time i tested (1-2 years ago), while was faster than for, now it isnt anymore
console.log( "Permissions " + server.me.permissions.toArray())
do you guys know how to list this like
PERM 1
PERM 2
PERM 3
This is one way to do it
I think he just wants to join this with \n lol
I mean
oh i found why i had problems
changed > to >=
Should I make a separate file just for managing my dashboard for ejs? Like I have all of my routing in 1 single server.js file and it is getting messy, so I didn't know if I should just call a separate file with the dashboard
I really think you should make it modular
just put all the code in a single file 
we have a 700 Lines mock express server at work 
whats the logistics behind everytime a user sends a message that gets censored, changing a webhook and sending it again with the words censored? because itd be doing a lot to change the webhook, it could be really spammy, not sure
You just pass the icon and name in the post request
don't waste your time on word filters, they'll always be bypassed no matter how much you try, context > profiling
to achieve what you want, you need to subscribe to the event which fires when you receive a message, compare it against your filter, if there's anything to be filtered, send the message with a webhook but it's username and avatar to match the author, delete the original message
Just get a team of slaves staff
https://vinniehat.is-inside.me/jrn8Md45.png What are some suggestions to put here?
@earnest phoenix ive already built everything around my bot and it works really well actually but thats besides the point
the issue is the actual webhook i feel like itd be spammed
How could I write a cooldown to my better-sqlite3 database
I already have the column in the db
It’s default set to 0
you mean a command cooldown?
sqlite probably isnt the best choice for that kind of thing
unless youre not doing what i think youre doing
What do you think I’m doing @hushed berry
I’m making a daily cmd
For my economy system
oh i see
command cooldown probably
like "wait 5 seconds before you can use again"
for a daily command, depends on your definition of "daily"
Every 24h
reset 24 hour from last command? reset at noon/midnight?
The cmd can be used
No
Say they used the cmd now
It’s 5:37pm for me rn
They’d have to wait till 5:37pm tomorrow
so 24h from last command
so when they use the command, save the timestamp
when they use the command again, check the saved timestamp, and compare it to the current timestamp
if the difference is smaller than 24h, display error
else execute command and save a new timestamp
the problem with this is that if the person forgets to use it again, or uses it later, then the 24h lock follows them
ie person uses at 5pm, next day person uses it at 9pm, the third day they have to wait until 9pm
so they use it again at 11pm or something
eventually they will lose a day
but this is the easiest method
How do I get the time stamp of when they last used the cmd?
when they use the command, you save it to your sqlite
then you get it back
how to save it and get it depends on your sql structure
Okay how do I get the time stamp though.
thats an option yes
with that option, you would check if the remain is negative or not
I was gonna check if remain is greater then or equal to 1 day.
assuming your cooldown is 1 day, that math will always get either a negative value, or a positive value smaller than 1 day
Wdym?
now will always be bigger than lastUsed
so if lastUsed + cooldown are smaller than now (more than 24h passed), the result will be a negative number
So my math is incorrect?
its not incorrect
just a different way
using that method, you would have to check if(remain < 0) { more than 24h passed }
yup
So I send the error message?
yes
Okay thanks
Wait
Wouldn’t I want to check if it’s less then or equal to?
Or just less then
the difference is 1 millisecond
so pretty much whatever
one has to be extremely unlucky to use the command exactly 1 millisecond before the cooldown passes
@earnest phoenix
Ok so I want to organize my work in a Trello Board(s). How should I organize the following:
Bugs
Suggestions
To Do
Finished
Do I put them all in one board etc or make separate boards for each thing besides the todo and finish
Colour code each thing?
@abstract crow change "doing" to "working on"
and "done" to "completed" ty
suggestions shouldnt be on the board imo cuz then the list would be hella long
Bugs can be in To-Do with a tag
I have a bit of a problem. One of my cmds just stopped working out of the blue (It is no longer responding or throwing any errors) . It’s acting like it doesn’t exist cause when I do -help setNick it doesn’t show the cmd info but it will for other cmds.
I need help
How do I know who invites a discord bot?
I keep on banning it but it keeps on rejoining
Now how do I fix this
@wheat carbon you cant ban a discord bot, you need to find the people who have Manage Server permissions and ban them. Someone is abusing their permission to invite it over and over again
Well what if they're higher than me?
Ok thanks
@loud salmon how do I know who invites them?
then you're kinda screwed if they are higher than you
¯_(ツ)_/¯
i dont think there is an easy way to tell
Ok thanks for helping
Ok so I need some more suggestions lol sorry guys! What should I add for stats about a guild, stats for a user, and stats for a user in THAT guild.
Like I have stats for the user, then the member in that guild, and I also just have guild stats
Can I get an image buffer from a Discord image's URL somehow?
I am trying to preserve images that are deleted with the use of a snipe command
@dusky marsh You can make a request to the image URL that you can get from Message#attachments, depends on the lib you use you can either turn decoding off or request a buffer, for example with node-fetch on .then you'd do response.buffer() and thatll give you a buffer
Yeah I was trying to get a buffer that way but none of it was working, so I just dug around in the attachments object and found I could use .proxyURL instead of just the .url
so that works ?
Yep
👌
Thanks for the help tho 👍
.setMentionable(true), .setHoist(true), .setColor() arent working
explain aren’t working, errors, what’s happening etc
@rugged whale what library (and which version) are you using?
hello
discord js
stable or master?
who can send me vedio how add bot to bot list
@main chasm noone. simply go to https://discordbots.org/bot/new
say now found
wrong link, i edited it with the right one
@rugged whale does your bot have the right permissions to interact with the role
bro
i tried in eval cmd too
is it above the roles youre trying to interact with
any errors?
const perms = ['ADMINISTRATOR', 'MANAGE_ROLES']
const k = args.split(' ').join(' ')
const role = message.guild.roles.find(m => m.name.toLowerCase().includes(k.toLowerCase()))
if(!message.guild.me.hasPermission(["MANAGE_ROLES", "ADMINISTRATOR"])) return message.channel.send("I dont have permission to perform this command!")
if (!message.member.hasPermission(perms)) return message.channel.send('No permission.');
if (!role) return message.reply("Couldn't find role named " + k)
if (message.guild.me.highestRole.comparePositionTo(role) <= 0 && message.member.id !== message.guild.ownerID) return message.channel.send('I dont have permissions to manage that role!!')
if (message.member.highestRole.comparePositionTo(role) <= 0) return message.channel.send(':youtried: You cant play with that role boi!:youtried:');
if (!role.mentionable)
{role.setMentionable(true).then(message.channel.send(`${message.author.tag} just pinged ${role}`)).then(role.setMentionable(false))
return
};
message.channel.send(`${message.author.tag} just pinged ${role}`);
}
}```
no error is coming
see code
i used function too
i know bro but say
is it sending anything?
catch too
wrong person
ye
@main chasm your long description field doesnt contain 300 characters
ok thanks bro @mossy vine
if (!role.mentionable)
{role.setMentionable(true).then(message.channel.send(`${message.author.tag} just pinged ${role}`))
role.setMentionable(false)
return
};```
thats not how you do callbacks
you are doing the callback incorrectly
see edited code
i tried tht too..
nd see ss i sent
it doesnt make role mentionable...
if (!role.mentionable)
{role.setMentionable(true).then(_ => {
message.channel.send(`${message.author.tag} just pinged ${role}`))
role.setMentionable(false)
return
}
};```
you could also do _.setMentionable(false) instead
i dont think it matters
...
it doesnt make it mentionable
// Set the name of the role
role.setName('New Name')
.then(updated => console.log(Edited role name from ${role.name} to ${updated.name}))
.catch(console.error);
Don't you think you'd have to await sending the message
setMentionable is a promise, as well as sending a message
It could possibly set it back before the message was sent
^
i hope you deleted it because you realized your obvious mistake
i have this :
(node:14) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'client' of undefined
at new MessageEmbed (/home/container/node_modules/discord.js/src/structures/MessageEmbed.js:13:60)
at Object.module.exports.run (/home/container/commands/utilitaires/help.js:9:25)
at Client.client.on.message (/home/container/theking.js:225:33)
at Client.emit (events.js:203:15)
at MessageCreateHandler.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
at WebSocketPacketManager.handle (/home/container/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)
at WebSocketConnection.onPacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (/home/container/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
at WebSocket.onMessage (/home/container/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:198:13)
(node:14) 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)```
but
in the help.js
i have
const { MessageEmbed } = require('discord.js')
module.exports.run = async (client, message, args) => {
var choix = new MessageEmbed()
.setColor("BLACK")```
how can i do
can you show your help.js file
so whatever youre passing as the client parameter is wrong
where are you calling it and what are you passing to it
const Discord = require("discord.js");
const MessageEmbed = Discord
const client = new Discord.Client();
first of all, what the fuck is that second line
second, thats not what i asked for
I translate because I am French and the translation is bad
i have this : where are you calling and what are you going to her
wot
where are you calling the function and what are you passing to it
lol
I call it in the index.js:
client.commands = new Enmap ();
fs.readdir ("./commands/admin/", (err, files) => {
if (err) return console.error (err);
files.forEach (file => {
if (! file.endsWith (".js")) return;
let props = require (`./commands/admin/${file}`);
let commandName = file.split (".") [0];
client.commands.set (props.help.name, props);
});
});```
and I want him to pass that `client = require ("discord.js')`
:\
so @mossy vine ?
still not helpful
lol
What do you want?
@formal basin do you wanna help or just say unhelpful things
i want to see where the function is called and what variables you are passing to it
uh ok
this @mossy vine ?
client.on("message", message => {
if(message.author.bot) return;
if(message.channel.type === "dm") return;
if(!message.guild.me.hasPermission("SEND_MESSAGES")) return;
if(!message.guild.me.hasPermission("EMBED_LINKS")) return;
let prefix = botconfig.prefix
if(!message.content.startsWith(prefix)) return;
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);
let commandfile = client.commands.get(cmd.slice(prefix.length));
if(commandfile) commandfile.run(client, message, args);
if(message.content.indexOf(prefix) !== 0) return;
});```
.
yes
ok
now how is client defined?
how do you define Discord
const Discord = require("discord.js");
dm bot
what
ok cyber
working still another 9 paragraphs if u wantt
are you just gonna post code without any context
???
nvm
do you need help with something or what
const fs = require("fs")
exports.run = async (bot, message, args) => {
if(!args[0]) return message.channel.send(`
You must provide an Channel! (without #)
`)
let report = JSON.parse(fs.readFileSync("./logss.json", "utf8"));
report[message.guild.id] = {
reportchannel: args[0]
};
fs.writeFile("./logss.json", JSON.stringify(report), (err) => {
if(err) console.log(err)
});
message.channel.send(`
The Logs Channel is now: **${args[0]}**!`)
}
module.exports.help = {
name: "setlogs",
aliases: []
}```
uh probaly an dumb question but why isnt it writing anything in `logss.json`?
That data is definitely getting corrupted sooner or later
Using a database is so much easier than JSON
Still
Using a database is easier than JSON
And JSON will get corrupted regardless of how many guilds your bot is in
Im having an Coin System on JSON and it never got Corrupted
just because it never did doesn't mean it never will
Well you do you, but we’re likely not going to help you with it
it's a mistake waiting to happen
@opaque eagle wym
IRL if you go to the doctor but refuse to listen to their years of expertise, there’s little they could do to help you with your problem. Same applies for our code suggestions.
kk
that should be pinned ^^
Thats the Error that i get when i run the Command:
Could not find node null, using 10
what does that mean?
opinions?
Nice @earnest phoenix
Looks great
i need to make it fetch users now instead of show ids
Add dark mode tho
thankfully, material ui allows that to be done easily
Lol
i literally just need to append type: "dark" to my theme object
i love it, both the ui and the way it works
uh i have a problem
bot.on('guildMemberAdd', member => {
member.guild.channels.get('607970023331332096').setName(`Member Count: ${member.guild.memberCount}`);
});
this event was running up to 2 minutes ago.
but its not working now
the event is for every guild
you need to fetch if the channel exist in the current guild
you're using an event
I don't see how that helps
Correct code bot.on('guildMemberAdd', member => { if(member.guild.id !== 'yourguildid') return; member.guild.channels.get('607970023331332096').setName(`Member Count: ${member.guild.memberCount}`); }); @tight forum
if a user joins a server that doesnt have the channel, it will error @broken shale
thank you sm @earnest phoenix !
np
what does that mean:
Could not find node null, using 10
Question: Can we get the total number of channels in a server i know there are certain commands but dunnoi how to umplement using discord js
@anyone form the worls
world*
@flat pelican
anyone form the whole world
why u ping an Mod? its unnecessary
sorry
just sayin
@stray garnet youknow answer?
have you tried reading the docs
I only code python cause the floor is java
java more like
@earnest phoenix looks really nice
thanks xx
hey i use glitch right . if i list my bot on dbl and i wanted to add voting system does the port have to be ran through 3000 ?
cause i have a dashboard running through port 3000 already
can u run vote system and dashboard through PORT : 3000
dont use glitch... glitch sucks. Forward from a raspberry pi, or a actual webhook server .... for christ's sake reeee
@earnest phoenix u can run a seperate route on ur website on glitch for the webhook
^
but just to be clear glitch is not meant to be for bots
^
its meant for websites
Your bot may suddenly go offline
^^
because it get banne
oh
ya sometimes glitch ips are banned from discord
let adduser = message.mentions.users.first()
if(!adduser) return message.channel.send("**:x: Veuillez mentionner un utilisateur. Exemple : t/ticket-adduser <@id>**")
await message.channel.overwritePermissions({
permissionOverwrites: [
{
id: adduser.id,
allow: ['VIEW_CHANNEL', "SEND_MESSAGES", "ATTACH_FILES"],
},
],
reason: 'Ajout de l\'accès à un utilisateur a un ticket.'
});```
Why does it put the whole server and not just for the person mentioned?
which d.js version is that
v12
For her it's been a week that I recode my bot to the module v12 xd 
@earnest phoenix tu sais comment faire un systeme de ticket ??
I need help because i have a discord dashboard hosted on my local host and its port forwarded
what do you need help with
you can use nginx as a reverse proxy and certbot to get ssl, and what cry said
@merry sail oui
Nginx is a
yes?
So I have alocal hosted database
what
what
Will it interfere with that
nginx is a web server
dafuq? no
nginx is a webserver, but can also work as reverse proxy and load balancing
Aahah
@earnest phoenix tu pourrais me montrer stp N
XD
What
Ok....
you generally shouldn't selfhost websites
nor a stable connection
Ok
and also you're prone to ddos attacks
hosting websites drains bandwidth and that ^
Okay thank you for that information
OwO
might wanna use that
Lemme look
- Hosting on your main pc is probably more expensive than renting a vps
- static ip?
- security issues
- bandwidth
AWS has web hosting for $11 /y
e.e
sure, do that
nothing
Its safe for my main
godaddy is ultra gae
anyways
https://billing.galaxygate.net/aff.php?aff=42 you should definitely use my affiliate link 
ngl thats pretty fucking expensive
Okie
@onyx summit where the fucketh
XD
go daddy
what the fuck
i can get that for $5 at GalaxyGate
milking money
ik
I dont use that
I dont use vps
k
Here
godaddy is trash anyways, their domain register is overpriced too
what domain thingy would you recommend?
I wanna get a second domain
namecheap has good offers
okay I'm not mentally challenged...
i got really good deals out of them
I’ll check out galaxy gate
@onyx summit wdym
Staten Island, NYC
you explain it like I'm mentally retarded and can't use a website
no not really
you can get free one year domain with any TLD on name.com through this year's github student pack too
that too
github doesn't accept my student bs tho
so
ravy.xyz is only 41 cents per year
so idrgaf
shit already taken
ım turkısh
Get a domain for cheaper on godaddy
türk varmi
Then transfer owo
but it is also very cheap
they're mostly used by spammers and phishers, as a result it's blacklisted from most services
well, not mostly, but in a large quantity
i have yet to confirm it
what i do know though is that xyz domains get pushed down on google search results
wait where can I use my student benefits on github?
ahh thanks
@earnest phoenix yeah but tbh if you try to get SEO with anything not .net, .com, or .org you're just lost
¯_(ツ)_/¯
true
.xyz is used because it's meant for misc things
and hence cheap
I own like 50 domains and none of them has good seo because they dont need to lol
oh since we're at .xyz
@twilit rapids your domain you mango
I need an a record to point it to
remember when everyone said github is going to get ruined once microsoft bought it lol
can you please type your message in one instead of
sending it
like this
its
quite annoying
Okie
i just got a domain
i have stopbeingabad.dev
Huskyprotector.xyz
cool
Mhm
im.being-a.fail/ure
XD
ok bois
but have you ever owned the let it go chorus
@earnest phoenix no
i
wont
just got being-a.fail
ovh is trash
is good?
:c
Is ovh good?
i think its kinda pricy
@onyx summit you better make im.being-a.fail/ure an image hosting domain
XD
imma buy
kill.my/self best domain
@mossy vine sure think!
I already got upload.chilo.space, but nahhh
dbl.sucks
Digital Ocean
@earnest phoenix i have owned something among the lines of pls-kill.me
i have plz-end.me
XD
pls-end.me was taken
How do I check the ping from my ubuntu server to the discord api?
With a ping command
in which library
Ubuntu




json database