#development
1 messages · Page 1708 of 1
not "the" command file, I mean Command file (capital C)
ok the base
is it internal or you have the file?
/**
* Abstract class for classes that represent a module
* @abstract Command
*/
module.exports = class Command extends Base {
constructor() {
super();
if (new.target === Command) throw new TypeError('Cannot construct Command instances directly.');
this._cooldowns = new Map();
}```
Is this commando or are you implementing your own
async loadMainCommands(directory = this._config.paths.commands) {
const files = await Utils.readdirRecursive(directory)
for (const file of files) {
this.registerCommand(requireReload(file))
}
}
/**
* Register commands to client
* @param {Command} Command command class to add to client
* no async/await for performance
*/
registerCommand(Command) {
let command = new Command(this._config, this.beta)```
That's just a comment
cant
what then?
The error is different though
^
abstract classes cant be instantiated
for every command?
Is that your own command handler or is this commando or something
registerCommand(command) {
//let command = new Command(this._config, this.beta)
...
}
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
then use command
So you made it and don't know how it works?
no i made it, its used to work, now it just stopped
I bet that never worked
sus
that's a fundamental error which would never ever allow the program to run
register(Command) {
console.log(this.client.commands)
let command = new Command(this._config, this.client);
command.ensureInterface()
if (command.aliases && command.aliases.length) {
for (let alias of command.aliases) {
this.set(alias, command);
}
}
}``` it works on the main bot?
abstract classes are called like that because they can't exist as objects
I highly doubt you wrote that code Astrah
"sample" yes
"copy-paste code" no
k can I have a sample
I just need understanding
who else wrote it then?
A simple API wrapper for top.gg written in Python. Contribute to top-gg/python-sdk development by creating an account on GitHub.
where exactly is the vote rewards?
you asked for a sample, that's a sample
obviously there'll be no EXACT example of vote rewards
@fierce ether ```js
registerCommand(command) {
//let command = new Command(this._config, this.beta) | Pass the command as parameter
command.ensureInterface()
if(command.aliases && command.aliases.length) {
for (let alias of command.aliases) {
this.registerCommand(alias, command)
}
}
}
well I'm kinda confused
oh
you'll not find a paste-ready "example" of a vote rewards command
that isnt register the command tho, (node:17780) UnhandledPromiseRejectionWarning: TypeError: command.ensureInterface is not a function
that link has examples on how to retrieve wheter the user voted or no
the rest is up to you
because you just pasted what I changed
read the comment after the second line
await self._ensure_bot_user()
data = await self.http.get_user_vote(self.bot_id, user_id)
return bool(data['voted'])
'get_user_vote' basically detects if the user voted or not?
this.registerCommand(requireReload(file)) this returns a constructor, so what your trying to use is incorrect?
this.registerCommand(requireReload(file)) acc this should return a constructor but its return the first aliases
well, you can't instantiate a new object from Command class
you need to figure a way of calling the subclass constructor instead of the super's
what you could do, is not use a constructor
but a function that builds the object and return as result
or just skip commands that arent a constructor?
if you do that you'll ignore commands
fixed it
like (example)```js
class AddRole extends Command {
constructor(...args) {
...
}
function getInstance(...args) {
return new AddRole(...args);
}
}
registerCommand(Command) {
let command = new Command(this._config, this.beta)
command.ensureInterface()
if(command.aliases && command.aliases.length) {
for (let alias of command.aliases) {
this.registerCommand(alias, command)
}
}``` i was trying to register each alias as a command instead of using `this.set`
then call <class>.getInstance(this._config, this.client)
question does <@roleID> still work?
yh
<@&roleID>
its @&roleid
ty
im getting the same sending after closing is not allowed error on my weebsocket that i smh fixed a few days ago
you cant send to a closed websocket
but how tf did it suddenly close
idk where to look at
found the error
heartbeatInterval is undefined
but hold up
data.d.heartbeat_interval should be defined tho
thanks linter for making me rename that to camel case
Based
false
vsc good and free. Linter rules exist for a reason
indeed
bruh reddit safesearch isn't good enough in the api
linters are for the weak
apparently u can change the channel to pictures of shit in the meme channel
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
thats what my friends did lol
im confused:
message.delete({timeout: 10000}) is 10 seconds right? when i run the command its on it deletes after .5 seconds
then write 20k and see if its 10 sec
sa
as
https://dis.gd/contact , we're not Discord.
And my nitro finished 2 days ago
wat
My label was 4023
oh it's gd
I changed it
And when my nitro finished its 9573
Ok
ask them for help, we cannot help you
discrims get randomized when nitro ends
you can't recover your old discrim
don't even bother asking discord
Would the same thing happen if I didn't change it
no, if you didn't touch your discrim it'd have stayed the same
Ok thanks
if (!this.isReady || (message.author && message.author.bot) || !message.channel.guild) return false; always returns false idk why?
whats this.isReady
jus a boolean to make sure everything is loaded, it returns true
true false false
Looks like this.isReady is always false
maybe you change the value somewhere?
needs more context. show more code ^_^
moar cod
async setup() {
const fetchAllLoaders = Object.values(Loaders).map(L => new L(this))
const [ preLoad, normal ] = fetchAllLoaders.reduce(([ pl, n ], l) => (l.preLoad ? [[...pl, l], n] : [pl, [...n, l]]), [[], []])
for(let l of preLoad) { await this.initializeLoader(l) }
for(let l of normal) { await this.initializeLoader(l) }
this.isReady = true
await this.login()
}``` setup is run when the bot starts, message event wont work until isReady is true
when you said true false false
if (!this.isReady || (message.author && message.author.bot) || !message.channel.guild) return false;
that in order
did you log this.isReady or !this.isReady?
this.isReady
'use strict';
const { Event, CommandContext } = require('../');
class MessageEvent extends Event {
constructor(client) {
super({ events: ['message'] }, client)
}
async onMessage(message) {
if (!this.isReady || (message.author && message.author.bot) || !message.channel.guild) return false;```
and how do you know its returning there?
console.log all 3 conditions above and below
it'd be funny if that wasn't a message object, right Tim?
Like, say it was a client var
console.log(!this.isReady, (message.author && message.author.bot), !message.channel.guild)
also 'use strict'; wth
message.content returns content
console.log(this.isReady, message.author.bot, message.channel.guild) log like this or same order?
with !
on all?
no
jus ready?
exactly like i said
So they're ALL false.
yes?
And that means, it's not going to return
so it should never return
and you're debugging the wrong thing
i logged underneath aswell?
console.log(!this.isReady, (message.author && message.author.bot), !message.channel.guild)
if (!this.isReady || (message.author && message.author.bot) || !message.channel.guild) return false;
console.log(!this.isReady, (message.author && message.author.bot), !message.channel.guild)```
How can I show the avatar of bot in embed?
yeh worked but now fetch dosent work either
this is why i never use ifs without brackets
i never rlly see the point tbh
you just saw the point right now lol
lmao true
How can I do
Whenever anyone vote my bot then my dm automatically that user?
:D
what is that?
whats your discord.js version?
client.api is the rest manager
v11.6.4
then there you have it
thats very old
v11 deprecated
ads
your bot needs to be verified
umm
okey 1m
your bot doesnt have access to something
catch the request to get more information
my bot is in 1 server
you getting applications via guildid?
not userId?
im fairly certain you need to use userId for applications
but before that
what are you EVEN trying to do?
im trying slash commands
then why not use what i suggested above?
where
literally 10 messges above
right here
this is NOT d.js btw
just gotta find the counterpart
as tim said, use
erm
hes doing the counterpart already
something soemwhere
hes doing exactly the same thing
hes doing /applications/:userid/guilds/:guildid/commands
thats confusing af but okay
discord.js's rest handler is a proxy object
.applications("abc") turns into /applications/abc
detritus has handlers too, its just the raw thats like i sent above
.rest
.rest.raw => post/get/put/patch
confusing

i'll let you handle this tim


client.api.applications("abc").guilds("xyz").get()
get("/applications/abc/guilds/xyz")
it doesnt
its a proxy object
if a new endpoint gets added you'd need to update it no?
the methods are converted to strings
if you do client.api.huehuehue("xyz").get()
it will do get(/huehuehue/xyz)
proxy object
The Proxy object enables you to create a proxy for another object, which can intercept and redefine fundamental operations for that object.
what should I do ?
i've never used slash commands
so i'd be telling you how to do it with raw requests
does /applications/userid/guilds/guildid/commands exist?
How to add Bolt bot into my server help pls
dont think so tim
await message.client.rest.raw
.post({
body: {
name: 'cat',
description: 'Send a random animal photo',
options: [
{
name: 'lel',
description: 'The type of animal',
type: 3,
required: true,
choices: [
{
name: 'Dog',
value: 'animal_dog',
},
{
name: 'Cat',
value: 'animal_cat',
},
{
name: 'Penguin',
value: 'animal_penguin',
},
],
},
{
name: 'only_smol',
description: 'Whether to show only baby animals',
type: 5,
required: true,
},
],
},
route: {
path: '/applications/:applicationId/commands',
params: {
applicationId: message.client.userId,
},
},
})
.catch(console.log);```
this is the example they give in the discord docs, i just put it in there to test it out
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
and then you just listen to this event
as simple as that
it does exists
GET/applications/{application.id}/guilds/{guild.id}/commands/{command.id}
my problem is solved thank you @opal plank @quartz kindle
np
imagine doing code right and then say it wrong
couldnt be me
@earnest phoenix i dont accept random friend requests
okey :(
how to log a message to the console
console.log(message.content)
that's literally how you log the message content to the console
Assuming you're in a message event and your variable name is message. Also assuming javascript because you failed to actually provide any useful information so I had to assume a whole lot.
the profile pic alone is enough for me to take a wild guess and assume they dont know coding, at all
hello
I... ... Erwin that sounds... uhm... probably racist?
okay i did that but now i get "message.content is not cached ", is this normal? @umbral zealot
can you please help me
I've literally never seen that error message in my entire life
show what you're doing? show your code.
you dont know where that troll pic is from?
bro
I have no idea and honestly don't care to profile people based on their name or avatar
whatever
Didn't expect this from you bro
Erwin is a racist
Ignore that, and please show your code
Well we can't help you then .
Lol
cuz I can't leak my codes to you either.
this guy is trolling
he isn't gonna sponfeed you evi.codes use your own codes
Can't share my code either, so good luck!
lmao
Thanks!
stop trolling Jort
lmfao
Tim nice haircut
its 100% normal to show code when asking for help
if you want good codes go to https://getmycode.com
if you dont want help when to elsewhere lol
no it's not
I think i'm gonna report you also
lmfao
you are a thief
troll
dmca claim maybe?
@umbral zealot now you get it?
don't pog with my codes

I'm don't trolling
yeah @elfin cave this is only serious dev talk
you don't even now what a partial is
sorry Tibo
np
bye
please go away now
@quartz kindle that is fixed 😂
lmao
tim i heard you telling that 50% is gonna quit when discord.js is gonna update to node.js 15
wat
oof
I'm gonna quit to I think
btw
go to detritus.js
what is node.js
that's a excellent idea
much better lib
yeahyeah
what do you mean?
is it for ts?
you can use it for js too, but preferrably you would be using ts for it
Anyone know why the mongodb container doesn't save any data when I use it in docker
when I restart the docker compose the data just removes itself again
missing access perhaps?
version: '3'
services:
api:
links:
- mongo
- bot
ports:
- "6969:9001"
restart: unless-stopped
build: ./src/api/
bot:
tty: true
links:
- mongo
restart: unless-stopped
build: .
mongo:
image: 'mongo'
volumes:
- mongo_data:/opt/anti-nsfw_data
ports:
- '27017'
volumes:
mongo_data: {}
networks:
default:
external:
name: antinsfw_network
compose file
dunno whats ur setup, but the user the docker is using would need access
it runs on my pc rn
linux?
xd
hmmm not sure how to work with that on windows
the vm's run linux

y e s
xxd
...
@marble juniper it does seem like that's a volumes thing because by default docker compose up should retain volume information unless you pass a specific flag
I just do right click on the compose file in vscode
it doesn't use any -v flags
lol
ify ou check the last paragraph it mentions something about on a windows machine
so i dunno
I mean
its only a thing for when I test it on my pc
its not gonna lose its data when on the server
lol
but yeah
kinda bugged me
whatever
time to deploy the rewrite of the bot
hmm
building the images shouldn't destroy the data volumes
good luck on the deploy 😄
probably just a windows thing
should be easy
feels more like a docker thing :p docker is a pain like that sometimes
as I have a webhook setup for my github repo
if I push code it just deploys that
lol
github piplines is great
we still use jenkins 😢
🥳
deploying takes like 6 seconds
lol that's pretty fast
don't you run any linting/tests?
its that fast because docker caches node modules
hahaha
it was a pain in the ass
ez way to fix long build times i suppose
so yeah
I mean im the only one working on this bot
so
its fine
if I don't use a linter
exactly
or have tests
Ik how my own project works
lol
im pretty sure I wont mess stuff up
i'd hope not lol
got a problem, punk?
all commands it has
not a lot
the set-logs and show-files commands are the only ones that even use the database
lol
is that an open eval?
no

okay good
it only shows owner commands to me
looks pretty cool 😄
for others the eval command
wont be in there
its a dynamic help command ofc
lol
all i have is a web interface soundboard bot :p
if (message.author.id !== client.owner) commands = commands.filter((command) => !command.ownerOnly)
I have this in my help command anyways
so if they don't have the id as me they wont see it
even if they tried to do eval
it would just
do nothing
it wouldn't even respond lol
it will just pretend like the command doesn't exist
i need to work on this interface 😦
and i need to start uploading and converting soundbytes
but i haven't had the heart to start modelling it
anyone have experience in database related stuff in .netcore? 😄
definitely check out efcore
I got this error while trying to run my code:
https://paste.gg/p/anonymous/8ca9d5ab09d64a9bacf2adc0919c02cb
Here's my code: https://paste.gg/p/anonymous/648e7e4a72d24337852feeeadf8de9aa
Can anyone please help me?
hi, my bot is suddenly spending much more ram than normal, it usually uses about 50-80MB and suddenly it is using even 200MB
I think the problem is because I made a level system
And well, that makes the bot have to always be doing something every message that is sent
And the ram memory of my bot is limited to 512MB so I need some advice to improve the performance or I will directly remove the tiering system
if you're using discord.js the problem is likely discord.js itself
how many guilds are you on?
28
Let me see
what is your bot doing on every message?
according to my bot 21k
client.on("message", (msg) => {
if (msg.author.bot) return;
if (msg.channel.type === "dm") return;
niveles.create(${msg.guild.id}.${msg.author.id}, {
experiencia: 0,
nivel: 1
});
let user = niveles.get(${msg.guild.id}.${msg.author.id})
user.experiencia += (Math.random() * 10) + 1; // Se sube la experiencia del usuario entre 1 y 10
if (user.experiencia >= (5 * (user.nivel ^ 2) + 50 * user.nivel + 100)) { // Si tiene la experiencia necesaria para el siguiente nivel
user.nivel += 1; // Se sube de nivel
msg.reply("has subido de nivel! Nuevo nivel: " + user.nivel); // Y le notifica al usuario con tal hecho
}
user.save();
});
I'm spanish so niveles is like level
what database are you using?
MeowDB
const MeowDB = require("meowdb");
const niveles = new MeowDB({
dir: __dirname,
name: "nivelesUsuarios"
});
its a json database
and by the looks of it, it keeps a copy of the entire database in memory
no it doesnt
but even worse
lmao
on every single get, it reads the full file again
Ok, thanks
i dont know if this is the cause of the high memory usage
but i dont think this is a good database
me neither
can you use aiohttp to get stuff from reddit
yes
ok
lmao
rfszu
how xD
I got this error while trying to run my code:
https://paste.gg/p/anonymous/8ca9d5ab09d64a9bacf2adc0919c02cb
Here's my code: https://paste.gg/p/anonymous/648e7e4a72d24337852feeeadf8de9aa
Can anyone please help me?
Reddit gives you the best of the internet in one place. Get a constantly updating feed of breaking news, fun stories, pics, memes, and videos just for you. Passionate about something niche? Reddit has thousands of vibrant communities with people that share your interests. Alternatively, find out what’s trending across all of Reddit on r/popular....
depending on what you want to get
you use different endpoints
can someone explain what the difference between sending a embed and a webhook?
they are completely different things
webhooks are messages
both messages and webhooks have embeds
yh i meant the difference
so if anything you have to compare sending a message to sending a webhook
a webhook can be sent from anywhere
without needing a bot program
nor a bot token
but webhooks need to be allowed in a channel
messages dont need to be allowed, but need a bot token
say for instance dyno, sends webhooks for logs instead of messages, why is that?
webhooks can also send multiple embeds and change the displayed username and profile
since webhooks dont use a bot token, their rate limits do not affect a bot
possibly why big bots prefer them
You use web hooks if you don't want to create a full on bot to interact with user input
If you just want to send data to a channel due to an outside event and for informational purposes, just use a web hook
poll: what language for bots do you prefer?
🇦 - discord.js
🇧 - eris
🇨 - discord.py
🇩 - discord.net/DSharpPlus/Discord4J/etc.
🇪 - some other one not listed here
@long crow why are you reacting to all of them?
Choose what you comfort with?
E > C > A > B > D (never tried D)
But that's just my choice. Yours will probably be different
Can you filter roles and channels by their reason tag
what is e
serenity
none of those are languages kek

why thou fuck are you importing padding for an encryption method
djs is not typescript
djs-next is
Yea, but iirc they're rewriting the main branch to ts too are they not?
that's for type declarations
Oop
Hi
is there a on_member_nickname_change event on discord.py
on_member_update, check the 'before' and 'after' nickname
alr
ty
@earnest phoenix will the process.on('Uncaugh....') work only in main file or will it also work from a required file?
That works on all files since Node.js links the primordial objects in all of them
ok
primordials are the objects defined globally pre_context rather, such as the process object
oh ok
someone knows this?
aah then what should I use?
I think he meant he doesn't use it
o okay
Its not tho
Which part are you confused about?
I think the webhooks one though
I get it how you can use webhooks for bot client. But how to use it for servers is not mentioned
In the python docs
What do you mean by "fake vouches"
Generating fake nitro codes.... ew
Please keep in mind that those docs are for v1.0
And the latest version on pypi is v0.4
So that version is not published yet?
can someone help me with a news command that I wanna add to my bot? (discord.py)
hols
How to use this class?
discord.abc.User
With the snowflake id?
Not exactly
It's not advised to be used if the user doesn't know what the fuck they're doing
do I need to have roles of a server cached in discord.js in order to be able to check a members permissions
yes
also do I need to have guilds cached for it to fire the guildCreate and guildDelete events
How do you remove the caching behaviour? djs-light?
yeah
lol
djs-light
I only have caching roles enabled rn
idk if caching guilds is enabled by default
Generally, you should have at least all guilds cached - I dunno how you're caching roles if you're not caching guilds, too.
idk
lol
also
guess what I wake up to
lol
guess I can't give anyone access to my private untill then
bump the version
nah
0.4.0
it has a conflict
with other dependencies
for whatever reason
but someone already created an issue for that package that uses jpeg-js
just have to wait until they release a new version
which fixes that vulnerability
I mean no casual user will attempt it anyways
lol
I have a little problem with my VPS, when I try to connect to SSH or SFTP, it puts me Connection closed with error: end of file. The connection information is correct.
The VPS is not offline because my site is working! What do you think this is the origin of?
Of course, I have already contacted the support service and I am waiting for an answer. I also launched a rescue mode under Debian 9 Live and of course it works but I don’t have my bot files…
that's what I did
@earnest phoenix
Index: const { token } = require("./config.json")
Client.login(token)
Config.json:
{
"token": "you bot token"
}
@earnest phoenix edit:
const client = new Discord.client()
and delete
const client = new client()
how would I execute code once the shard is ready without using the ready event in djs
Why not use the ready event?
and Feud strikes again 😛
how to make my bot send message on specific time?
js
ok
do u know how to do it?
only thing i can find
if you want to run messages at certain times use cronjobs or timeouts
im suprised js doesnt have a nice date features
kinda send message at 05.00pm like tht?
what system is this bot running on ?
Dont spoonfeed him 
hey,
var test = args
if (subcommand === 'join') {
const banned = require("./banned.json")
const manga = banned.userids
if (manga.includes(message.author.id)) {
message.channel.send("``Sorry, but you have been blacklisted! You cannot join!``")
return;
}
if (queueMessageId === 0) {
message.channel.send('A queue does not currently exist Arena-Boss '+ "<@" + message.author.id + ">");
} else {
message.channel.messages.fetch(queueMessageId).then(queueMessage => {
if (addUserToQueue(message.member.displayName, message.member.id, test)) {
console.log(test)
fs.appendFileSync("./levels.txt", message.member.id + " " + test[1] + "\n");
assembleQueueMessage();
const userQueueDuration = timeInQueue(message.member.id);
queueMessageText += ' ' + message.content.slice(Config.prefix.length).replace(/ *join/, '').trim()
if (Config.useEmbeds) {
queueMessage.edit(embedQueue.setDescription(queueMessageText));
} else {
queueMessage.edit(queueMessageText);
}
} else {
message.channel.send(`${message.author} already entered the Arena-queue!`);
}
})
.catch(console.error);
}
}
``` so the embed is indeed adding levels behind someones name, but why does it disappear once someone else joins?
if anyone knows the answer, please ping me,
m
why have u defined test as args when u could just use args?
hmm?
Hi
How can I check if parseInt() something is not an integer?
because NaN == NaN is false
how?????
how can I check if something is NaN
uh got it
isNan()
const webhooks = await sendChannel.fetchWebhooks();
let webhook = webhooks.first();
if (!webhook) {
webhook = sendChannel.createWebhook('Attitude', {
avatar: 'https://cdn.discordapp.com/attachments/735940794107822081/832575026791841792/Attitude_White_Logo.png',
});
};
await webhook.send({
username: 'Attitude',
avatarURL: 'https://cdn.discordapp.com/attachments/735940794107822081/832575026791841792/Attitude_White_Logo.png',
embeds: [embed],
});
im trying to do this but it says webhook.send({... is not a function
welp
I got it but thanks
isNaN
try to log what it is maybe
just wanted to search it for you
like console.log(webhook)
some people told me about dealing with a promise, didnt understand
you seem to have it fine, your await is at the right place
but why tf NaN != NaN
but if there's no webhook.send it might be that it's not a webhook object for some godawful reason
just why?
just log it and check
its not a number
but doesnt know what it is
so it cannot know if its equal or not
Filmed in Paris on Nov 30th, 2012. More talks on http://dotconferences.eu
lol
Promise { <pending> }
... are you Chill ?
No, but if it's not working, then it is supposed to be <pending>
yeah ok but why are you telling me. I konw how the hell promises work 😛
this.utils.hexToInt((color ? color : '#748bd4').rgb(true)) how would i use ??= to make this simpler?
If it says pending it means it didn't await correctly
sounds like you didn't actually save the code
I did
if (!webhook) {
webhook = sendChannel.createWebhook('Attitude', {
avatar: 'https://cdn.discordapp.com/attachments/735940794107822081/832575026791841792/Attitude_White_Logo.png',
});
};
Not here you didn't
createWebhook also returns a promise
it is simple
what can i do tho
you need to await sendChannel.createWebhook
just do that
let me try
it takes time to make a webhook -_-
Got a problem with $sum
ik but i want to start using ??= to make code smaller
idk abt ??=
its baso this a === undefined || a === null ? b : a
that took 2 seconds holy hell
it works :)
thanks
Anyone help me ._.
this.utils.hexToInt((color ?? '#748bd4').rgb(true))
@fierce ether
or just this.utils.hexToInt((color || '#748bd4').rgb(true))
On my economy cmnd after using it for a lot of time it won't change , it always shows problem with $sum
send code @swift cape
Ok
$nomention
$title[Balance]
$description[ moneybag Money $onlyIf[$mentioned[1]==; ]
$getUserVar[money]۞
credit_card Bank $onlyIf[$mentioned[1]==; ]
$getUserVar[Bank]۞
receipt Total
$sum[$getUserVar[Bank];$getUserVar[money]]۞]
$footer[$username balance]
$addTimestamp
$thumbnail[$authorAvatar]
$color[#17FF00]
which language is that? can't be php
go complain to the developer of the app
its bdfd lol
Bdfd
get out
nobody here uses bdfd, we cant help you
Lol
console.log(color ?? '#748bd4') this while always select color tho because color always returns Color { _rgba: [ 0, 0, 0, 1 ] }
what are you trying to do
Should I make the code public for my magic wrapper which makes editing gifs super ez in js?
just 4 lines
trying to check if there is a color entered if not use '#748bd4'
then verify if the color is correct
Built in enums are gonna slap
what's the problem
color always returns Color { _rgba: [ 0, 0, 0, 1 ] } so color.rgb(true) returns #fff000
why not check if an argument is provided beforehand
but i cant use color === '#fff000' then use #748bd4
bc i check for the argument in the constructor
use some validating regex
you don't need regex
return typeof hex === 'string'
&& hex.length === 6
&& !isNaN(Number('0x' + hex));
}```
{ type: 'string', full: false, missingError: 'admin:addRole.failures.noStringParameter' },
{ type: 'color', required: false },
{ type: 'boolean', required: false }]```
try this
ive got something similar
/**
* Convert hex color to integer
* @param {String} color Hex value of color
* @returns {Number} Hex color as an integer
*/
hexToInt(color) {
return color.startsWith('#') ? parseInt(color.replace('#', ''), 16) : parseInt(color, 16);
}```
I wish I could share my secret Color utility code
then why not use this
i do already, but it isnt checking if their is a color entered
what's your code
can't you do Color(isNaN(hexToInt(color)) ? "default color" : color)
code to check if a hex is valid
isHex (hex) {
return typeof hex === 'string'
&& hex.length === 6
&& !isNaN(Number('0x' + hex));
}```
i done this var hexCode = this.utils.hexToInt(color.rgb(true)) hexCode === 0 ? hexCode = '#748bd4' : hexCode
that's not valid js
var hexCode = this.utils.hexToInt(color.rgb(true))
try {
var createdRole = await guild.roles.create({ data: { name, color: hexCode === 0 ? hexCode = '#748bd4' : hexCode, hoist: hoist }})```
it returns 0 if no input
but if the output is invalid, it returns NaN
hexCode wont run if they enter a invalid color
bc of color
hexToInt always return NaN if the color is invalid, I just tried
it checks the input and uses regex to check its a valid color
it's not this? #development message
yes, but the code wont continue if they enter a invalid color
I c
i use all this in the constructor so i dont have to use if(!param) return message.channel.send("no param")
bc it saves me alot of time and likes for instance a string type: 'string', full: false, missingError: 'admin:addRole.failures.noStringParameter' if no string is entered or the input isnt a string it translates missingError into the guild language and sends a embed
couldn't you just create a template Object so that you aren't creating a new instance in memory and clogging the old space
I updated my bot's biography, but when I threw f5, the article I updated does not appear.
Hello I need help
biography
Did you save it?
My bot apparently got rate limited. I have no idea how nor do I have the slightest idea how to fix this.
I have read https://discord.com/developers/docs/topics/rate-limits but still have no idea what to do
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
what library are you using and are you sharding
to check up on the ratelimit you can manually make a request and see the headers
how to check if sharding
If you don't know what sharding is or if you are then you aren't
I have no idea how to do this. I literally just started developing bots 2 days ago 😅
nothing?
don't do an action so many times within a short timespan. Only do what you actually need to do
Is there a way to limit requests so that I don't get rate limited? cuz I can't even turn the bot on now bc it's rate limited
Your lib should be handling that for you
It doesn't really slow down on requests
so, if you send a message 10 times, it always sends them as fast as it can and doesn't stop briefly after 5?
Not that I am aware of. The command that caused the rate limit is a command called 8ball. It's just like a mini game where someone types -8ball questionhere and it randomizes and answer. It's been working fine for the past 2 days, ppl could use it whenever
and then out of nowhere it just said "you're being rate limited"
and I got a message to go read https://discord.com/developers/docs/topics/rate-limits to prevent this from moving forward but Idrk what any of it is saying
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
what's the code for it
@client.command(aliases=['8ball', 'test'])
async def _8ball(ctx, *, question):
responses = [
'It is certain.', "it is decidedly so.", 'Without a doubt',
'Yes - definitely.', 'You may rely on it', 'As I see it, yes.',
'Reply hazy, try again.', 'Ask again later',
'Better not tell you now.', 'Cannot predict now',
'Concentrate and ask again', "Don't count on it", 'My reply is no.',
'My sources say no.', 'Outlook not so good.', 'Very doubtful.'
]
await ctx.reply(
f'Question: {question}\n:white_check_mark:Answer: {random.choice(responses)}'
)
implement cooldown 
Yeah, idk how to do that tho
I doubt that's what's causing issues unless people are spamming it
^ ppl are
So, then you should look into how to add user cooldowns
also why make 8ball an alias, I'd make it be the name instead 
can't have a number as a command it won't work
so I had to alias it
I'm not talking about your function name, rather the command name
name="8ball" isn't it?
^
uh
Command name: _8ball
Aliases: 8ball, test
looks weird, at least to me 
Lol ik but like why doe
why what
why is it like that
The env var side bar creates a .env at runtime
idk where that is ;-;
the env system was removed and replaced with an option in the sidebar
you dont know whats a sidebar?
nop
thats just my 2nd time making a bot
eh idc what it looks like if it works
so do I just have to wait for my bot to stop being rate limited?
or do I have to do something for it to stop being rate limited. Obviously besides later putting in a cooldown. But like I can't even start my bot now
if you got temp banned you have to wait 1 hour
guys can someone help me
they can only be <= 5MB
oh
if(command === "download"){
ytdl('https://www.youtube.com/watch?v=dQw4w9WgXcQ')
.pipe(fs.createWriteStream('song.mp3'))
await delay(10000)
const buffer = fs.readFileSync('./song.mp3')
const attachment = new discord.MessageAttachment(buffer, 'song.mp3')
message.channel.send(`${message.author}, here's your song!`, attachment)
}
ig thats why
ok ty
download yt songs?
distributing illegally downloading songs
oh
YT only has licenses to stream through their official clients unless the user is a premium user
external json
In the Key or Value?
value
value ig
Ok
key is what you use to access the token
in this case, it might be TOKEN
so, process.env.TOKEN
client.login(process.env.TOKEN) or whatever you put as the key
scroll up
In the black area?
yes so we can see the actual error
are you sure you set the proper key and value for the env
yeah so you didn't put your bot token in the .env file
not the file, the section on the sidebar
TOKEN=yourtokenhere in a file called exactly .env
I actually did
Im sorry i new to making bots TwT
@raw pawn what did you put in key and value?
I put "TOKEN" in key then i put my bots token in Value
then it should work
what does it show in the terminal if you do console.log(process.env)
Im getting this Extermely long error while trying to install discordjs/opus using npm on Linux. Can anyone help me?
Okay ill try it again
the error is self explanatory. You might want to remove the .mp3 at the end of the URL
it's just trying to find pre-compiled binaries for opus. Since it 404's, it builds a version of opus from source for you
you may want to actually give your file a name
you're trying to write an mp3 file with the youtube url as the file name
hey
how do i search for someones id if i have his name?
For example Awsome. How would i find that user and get his id?>
names aren't unique so you won't be guaranteed to get the actual user
Now when i try to start my bot and play some music on it, then this error appears and forces the bot to quit my channel. On Windows it works just fine. And no the embed description is not at all over 2048 caracters. Just maybe like 100
how would i do it tho?
whats a good api without watermarks that make your a blue/bright/triggered/wasted etc
i already tied
tried*
let finalreverse = reverse.map((x) => x[0]);
console.log(finalreverse)
let id = client.users.cache.get('name', `${finalreverse}`).id;```
(node:2960) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
.get() is only for keys
and keys are IDs
you want to find users by name so use find() and provide a function
and you might need to use a loop
you can't provide an array for collection.find()
or .map(), like names.map(name => users.cache.find(({ username }) => username === name))
but the values can be undefined
aha omkay
how do i use the script to see the request thats being made
becuz i used requestbin and it works properly but my own script doesn't work
remember guys, hashmap is unordered 
wat am i looking at






