#development
1 messages · Page 1880 of 1
if you want 2 people to react, you need max 2
time is milliseconds
time 10 is 10 milliseconds lol
0.01 seconds
i need help with something
yea idk i prob dont understand what im doing but im just trying to get it so the user doesnt have to wait 10 sec after they react
time 10000
in the m.awaitReactions?
Whatever you need help with, you can just go ahead and ask 🙂
sorry if i dont understand what ur saying i mean i dont want the user to wait 10 sec after they react
yes, max 1 for 1 person, max 2 for 2 persons
aight
so like the bot reacts to a message, then the user reacts and it immediately does something. cause rn the bot reacts to a message, then the user reacts, and the user has to wait 10 sec before something happens
you know what nevermind, i figured it out
ill try max tho thx 👍
alr
i just saw this in an example embed lol
.addField("GOT YOUR ID FUCKER", message.author.id)
lol
could i remove time and just have max?
to achieve this
actually i do need help
how would i do an embed in a command handler that uses module exports with interactions
apparently my fixes were wrong so i gave up
Show some code
presumably the same way as without exports
imma put it in a pastebin
just with exports
Aight
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.
it's under ./commands with help.js
one sec
how do i get started with ts
https://pastebin.com/QWFPK936 modified code and now line 28 unexpected token ")"
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 you have your brackets lined up improperly and/or an extra )
On mobile atm so I can’t really look at formatting easily
i love it when discord.js throws a fit when you do code badly
});
SyntaxError: Unexpected end of input
you know what screw it
i will just put it in a google doc and pass it off at as a link
in the code
That's not Discord.js
tf
That's JS' parser telling you to fix your code
fuck
Create a new document and edit with others at the same time -- from your computer, phone or tablet. Get stuff done with or without an internet connection. Use Docs to edit Word files. Free from Google.

if i can't do the code i will put it in a doc
i gave up on it
Learn js before coding a bot
What's the error
unexpected input
I'm trying to add a role to a mentioned user, but I keep getting this error:
TypeError: Cannot read property 'roles' of undefined.
I've tried getting an user through mention and the current method of client.users.cache.get.
Code: https://sourceb.in/Es00bEa0BY
lemme redo it
users dont have roles
and your calling roles on a undefined variable
it's not that i didn't learn how to do js btw, it's that the new docs makes me wanna have an anuerysm
frick mb
message.mentions.members isnt a thing in v13 tho
yea i dont think it is at least. i tried it and it threw an error, but dont remember what it is lol. ill rq try it
it does
I mean, from the errors you’ve gotten they look like js-specific errors
Rather than issues with djs
...which is?
im dumb. it worked lol
thx
:)
dumfuk
description expected string to have a minimum length of 1 but got ``
oh shit
i'm a dumbass
nvm
Errors are in english
dumfuk

i have less braincells than a doorknob would have
Is anyone familiar with Discord Buttons Plugin for Discord Py, if so, can you help me?
you wanna know how much of a dumbass i am, i've overlooked one piece of code that could've been easily fixed causing me to waist 5 hours
an embed?
oh boy
what lang?
I can’t figure it out
D.js
i was just having issues with that 
did you try reading the docs and guides?
Im not familar with js
Official guide
Thx
What’s the error
Getting frustrated only results in worse code and more frustrations down the line
cannot send empty message
Sometimes it can help to take a small break
You’re trying to send an empty message then, check where you’re sending messages
You can't send a empty message
The errors are all in english it states the exact problem
If read correctly
i swear to god now i'm thinking i'm illegible
Just relax and try to think logically
Go through the process of thinking about what could be wrong
my discord bot - this thing "bot = commands.Bot(command_prefix = "$")" - is named "bot"
and then my top.gg thing is bot.topggy - this thing "bot.topggpy = topgg.DBLClient(bot, dbl_token, autopost=True, post_shard_count=True)"
are these 2 things both being named bot going to mess it up or is that what it's supposed to be
I just copied the automatically post server count every 30 minutes off the documentation
Try reloading your discord
reloaded, let's see what it does
the hell?
so none of my messages existed for the server
the commands i meant
Then you’re doing something wrong
yuppppp
Try following https://discordjs.guide
omg it's a catch block
you know what screw it, imma save the command for later
i'm really starting to question how i've been coding a bot for 3 years and when it comes to command handlers, i can't do jack shit
most of the above guide is copy paste tbh
interactions imo are an improvement, I think most people like them
It is unfortunately and their examples of how to register slash commands and handle them is shit as fuck
Also never got why they suggested this stupid code to register slash commands other than the inbuilt features of djs
Djs is just bad in general
The devs aren’t incompetent, it’s made as a “beginner friendly” abstraction of the more difficult backend processes
At least that’s what I see
beginner friendly does not exist anywhere in those new docss
They’re beginner friendly because it spoonfeeds you the code
interactions would've probably been received 1000x better if discord did a better job of announcing it and a ton of other things
not as much anymore
Just use detritus 
Better library for the discord api
Better is a subjective term, but in my opinion, it’s better
better be easier
Typescript on top
If you expect to be spoonfed the proper code for detritus off the docs, then look elsewhere
I think djs does the job of making a “working” bot pretty well
barely working
But scalability and general organization seems counterintuitive
I used to use djs v12
Then I was introduced to detritus by the resident detritus enthusiast, Erwin
I have no regrets about switching
oh and with djs you constantly have to work and maintain your bot bc of the obscene amount of breaking changes
Plus you have pretty much direct contact with the developer and maintainer of detritus
since discord started releasing gateway updates more rapidly you have to update eventually you cant just stay on an old version
Since it’s a less popular library
And detritus adds new features fast
Unlike djs where you have to either use some janky 3rd party garbage library, or wait for an entire version update to get new features
discord-rose™️
Not if you can’t do djs yet 

discord-rose could do a bit of maintenance
Can’t speak on the reliability of other libraries since I’ve only used detritus and djs, I’m sure they’re good
Most if not all are at least better than djs however
discord.asm
Djs is by far the most popular though, you’ll find answers to many of your questions quite quickly since they’ve most likely been asked before
Waiting on a discord.base2 library
fun fact asm is easy
Idk about that one
it's just the simplicity that makes it difficult to work with
yeah
It’s TOO simple
Too many things to think about to make a simple instruction in asm
(Compared to modern languages)
asm > js
machine code is brutal its totally binary and doesn't have things like labels which asm has
C++ already kicks my ass and asm is like a 6 step jump down from that
I tried coding in machine code once with a hexadecimal editor
didn't enjoy it
it really makes you see asm as a luxury to have
Just the thought that people used to actually use asm all the time before C was invented haunts me
lol
asm isn't actually all that bad
make an os and you'll understand
it just requires a lot more labour to do one thing
instead of variables you have individual memory locations and cpu registers
there wasn't really any languages back then so people mastered asm
and made games in it
Just rename yourself to Erwin 
Not Not Erwin
No, not not Erwin but Erwin
Erwinception
Hi
nsfw commands all of a sudden stopped working on my discord bot. they have always worked fine from reddit now all of sudden they stopped working.
Anyone know how to create a message with a webhook with an API request? I'm using HttpClient in java, never worked with webhooks before
Or do I have this webhook thing wrong
(I'd prefer to not use any external libraries, but if I have to then so be it)
Got it, nevermind
m = await ctx.send(
embed=embed,
components = [
Button(label="1", style=ButtonType().Primary, custom_id="button1"),
Button(label="2", style=ButtonType().Primary, custom_id="button2"),
Button(label="3", style=ButtonType().Primary, custom_id="button3"),
Button(label="4", style=ButtonType().Primary, custom_id="button4"),
Button(label="5", style=ButtonType().Primary, custom_id="button5")
]
)
Anyone got any idea how to make this all go in 1 row rather than down in a column?
each entry in the Array signifies it's own row
if there's a button row constructor, then use that. Or if Button accepts more parameters, use that
alternatively, look at Discord.py's docs for buttons
Anyone know why I'm getting an Already connected error from this code? ```java
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
public class Webhook {
private final String webhookId;
private final String webhookToken;
private String webhookName;
private final HttpURLConnection conn;
public Webhook(String webhookId, String webhookToken) throws IOException {
this.webhookId = webhookId;
this.webhookToken = webhookToken;
this.conn = connectToWebhook();
}
public Webhook(String webhookId, String webhookToken, String webhookName) throws IOException {
this.webhookId = webhookId;
this.webhookToken = webhookToken;
this.webhookName = webhookName;
this.conn = connectToWebhook();
}
private HttpURLConnection connectToWebhook() throws IOException {
URL url = new URL("https://discord.com/api/webhooks/"+webhookId+"/"+webhookToken);
URLConnection con = url.openConnection();
HttpURLConnection http = (HttpURLConnection) con;
http.setRequestMethod("POST"); // PUT is another valid option
http.setDoOutput(true);
http.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
http.connect();
return http;
}
public void sendMessage(String content) throws IOException {
if(content.length() > 2000) {
throw new IllegalArgumentException("You cannot send a message with more than 2000 characters!");
}
String json = "{\"username\":\""+webhookName+"\",\"content\":\""+content+"\"}";
byte[] out = json.getBytes(StandardCharsets.UTF_8);
int length = out.length;
conn.setFixedLengthStreamingMode(length);
try(OutputStream os = conn.getOutputStream()) {
os.write(out);
}
}
}
Test
Enter message to send. Type ESC at any time to exit.
Test
Exception in thread "main" java.lang.IllegalStateException: Already connected
at java.base/java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.java:202)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.setFixedLengthStreamingMode(HttpsURLConnectionImpl.java:490)
at Webhook.sendMessage(Webhook.java:45)
at Main.main(Main.java:24)
Process finished with exit code 1
Not entirely sure how it could already be connected, but I'm probably missing something easy here
Oh wait
I'm stupid
I'm setting the fixed length streaming mode after connecting
whoops
ew java
Would it be a no no to set the streaming mode, connect, then disconnect on the next message to set the streaming mode again?
Seems like I can't do that, is there a way to do something similar to conn.setFixedLengthStreamingMode() but after connection?
Okay, fixed the first issue with using setChunkedStreamingMode, however on the second time around using the function, I'm now getting ```Exception in thread "main" java.io.IOException: Stream is closed
at java.base/sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.checkError(HttpURLConnection.java:3785)
at java.base/sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(HttpURLConnection.java:3774)
at java.base/sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(HttpURLConnection.java:3769)
at Webhook.sendMessage(Webhook.java:46)
at Main.main(Main.java:25)
Process finished with exit code 1```
And my brain is too small to understand what to do at this point
Not sure how to re-open the stream, if that's even what I'm supposed to do
ok, I'm here
don't use httpurlconnection
😔
it's ridiculously outdated
like, it's the very first http package integrated into java
without external libraries 
why not use external tho
project for a dumb company?
Project for self use, going to be working on it at school and I'm not sure if I'm able to access external libs on their wifi
Can't get the jar on their wifi is the problem
what exactly are u trying to achieve there?
pendrive
I feel java wasn't made to work with http request
doesn't work on school computers 
cause of how pain in the ass it is
oh trust me it isn't
it's just that HttpUrlConnection is outdated af
But the point is that I'm trying to use a webhook to send messages to a discord with friends, since discord is blocked at school and cellular data doesn't work
it's like using primitive JS http requests
Nothing needs to be incredibly efficient or fancy or anything
lmfao
I'm using outdated tech because it's built into java
Aka gonna build the UI with swing
lmao
ok so, use apache's
put the jar inside ur project
and reference it there
or are u already in school?
At home atm
I'll try out apache
If it doesn't work then I'll figure out a different solution
But thank god get me away from this shitshow of an http request
I love working with kotlin projects and having to turn them into a jar file that uses java libs and need the depos built into the jar
Took me a solid 3h to figure it out cause im dumb
@wheat mesa
this is basically how u open a connection, send, retrieve response and close
looks much cleaner
do note, JSONObject is a custom moshi adapter I wrote
but u can use org.json if u don't mind optimization
I always wondered how to parse a request body into json with kotlin
moshi
gson is bloated af
dear god does java not have a package manager
yea
and a configuration hell
that's basically the reason moshi was created
cause all the shit I saw was for gson or some other lib
give moshi a try, you can directly switch libs and do only minor changes
they tried to make migration as easy as possible
how tf do you even install a library
raw java or maven/gradle?
raw java
download the jar and set classpath
I like gradle
gradle is fine if its not kotlin
except when I'm making libs, then I use maven
kts files annoy the shit out of me
Eh
Even dumber question, how do I set classpath
I can't be bothered to learn smth new
go is already using up my last brain cells

you'll ned a json parser waffle
and I hardly even know actual java
org.json is the easiest
no one uses raw java anymore
it's just not worth it
I figured
it's like using js without npm
ouch
is that even possible bro
I couldn't do it
Anyone who uses js without npm are freaks
I guess the reason most people hate java is how they were introduced to it
like
my university used java 1.8 without any package manager
java 1.8 is literally the barebones regarding features
that's what my school is using rn lmfao
so it always ended up being a setup hell coupled with lib version mismatch
that resulted in many people raging on java
if only they were introduced to java 11 + maven...
idk why they stick to such outdated version
tbf, check if it doesn't already come with apache
checked
many libs already have it as a dependency
doesn't come with the httpclient
baeldung
If I had the motivation
One thing I disliked about java/kotlin
was when getting stuff from github
like depos
and you had to use the commit hash but sometimes the hash was wrong
u can use jitpack for that
Yea
jitpack was the easiest thing to use for me but also the most annoying
lmfao
I'd use the commit hash and it'd tell me its not correct
never had issues with it, maybe the commit didn't build sucessfully
Mmm maybe yea
oh
Okay, how do I send a POST request using Apache now?
(Combined with org.json)
Just trying to rethink the structure of my program since it's different from HttpURLConnection
! play กอดในใจ
this look about right from this website?
(The concept, at least)
agh
more magical things to import
stringentity
wait nvm
is a raspberry pi good for hosting a python bot?
bruh why do I not have the StringEntity class
ugh
@lyric mountain you sure that was the right JAR to download? I'm getting ClassNotFoundExceptions
Alright, got that fixed up
The program still works completely as intended, but the console spits this nastyness out for some reason
I'll deal with it for now
late at night and I'm tired of this
But thank you for the help KuuHaKu
Resident java enthusiast
👍
if anyone can help me.. very new to python, https://stackoverflow.com/questions/69231583/how-to-send-a-message-to-channel-after-reaction-discord-py
async def on_reaction_add(reaction,user):
id = user.guild.id
r = requests.get('https://eternaltesting.xyz/privacy/accesskeys.php',params={'guildid':id})
fullstring = r.text
substring = "
where is user defined
async def sendmsg(bot,user,msg):
user = await bot.fetch_user(user)
await user.send(msg)
i think?
that code as working fine unti i added in the error report stuff 😦
O
how do i read a txt file from attachments
when using attachment.read() it gives me bytes but not the content of the file
You have to convert it iirc
oh
Thanks
yup
How to create bots @blissful coral
Please don't ping people especially staff for questions like that
OK
How to Add code
open notepad and write code ???
Why?
isn't dpy deprecated?
yes
-m 785472586883530753 Be helpful or don't use #development. Sharing nuking code to "help" a newbie. | 3d
Let's also ignore the command name
The double mute
@rose warren why double mute
Not a py dev. Thanks for pointing that out! Upgraded to a bonk
Does djs v12 have an attribute to make a message only be visible to 1 user
with slash commands, yes
slash commands..
thats Luca,which is double instanced
oh-
use some other advanced code softwares or websites,its 2021
Use nano in terminal to edit code
:)
imagine using notepad
import prompt from 'prompt-sync';
SyntaxError: Unexpected identifier
Did I do something wrong? (Trying to convert everything to ES6 based.)
i got an intents error, here is my base code
Is it possible to catch this error?
DiscordAPIError: Unknown interaction
at RequestHandler.execute (/root/cb/node_modules/discord.js/src/rest/RequestHandler.js:298:13)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/root/cb/node_modules/discord.js/src/rest/RequestHandler.js:50:14)
at async ButtonInteraction.deferUpdate (/root/cb/node_modules/discord.js/src/structures/interfaces/InteractionRespo> method: 'post',
path: '/interactions/id/token> code: 10062,
httpStatus: 404,
requestData: { json: { type: 6 }, files: [] }
}
is it js or py?
that's es6 syntax 
only works on typescript or deno with js
python you can do from bal import bla
I thought
maybe he was using py
it kind of hard if he doesn't say he's using js, ts or py
js
yeah I can see that
py doesnt uses ; in importing
can you show the error?
as far as i know
Error [DISALLOWED_INTENTS]: Privileged intent provided is not enabled or whitelisted.
when learnt py
aah
is your bot in 76 or more guilds?
because if it is
no
mmh
it is in only one guild
did you enable the privileged intents?
tf are those
all i did for the intents was gone through the docs
done
Catch your methods
How can an interaction be unknown and i have no idea ,how i can catch it :C
an interaction is unknown when u delete it
and then try to edit it
or do something with it
so ,when you defer it?
so after 15 mins?
@tulip ledge I tried enabling the intents. The bot comes online but it does'nt replies.
ur not getting the eror anymore right?
can u show ur code again
maybe, not sure
say what
k holdup
Does someone know how to send an embed into another server, like a bugreport, using slash commands?
switch(args[0]){
case `${prefix}hi`:
message.reply('hello there!');
break;```
still no work
another thing you can do is <Message>.content.slice(prefix.length).split(/ +/g)
/g ?
It's regex
ye
what does it mean
Complicated to explain
it allows for iterative search
it stands for global search
yep
it stil deosnt work
otherwise if u do "hello this is a string".split(/ +/) it will only do ["hello", "this is a string"]
can u log args[0]?
lemme try
Hey. I'm getting this error when I'm trying to install canvas on a rpi zero w with armv6l v11.15.0 node
@rose warren
DONT CLICK THE LINK
ty
Thanks
Do click the link
oy
gyp moment
do u have node-gyp installed?
doesnt even logs the message
'how do i'
Trust instincts trust flazepe
npm install -g node-gyp
did it and same errors.
@livid jackal oh who's dis den?
u sure node-gyp got installed?
i just installed it
hey, can anyone help me
I have created a discord.py Button calculator
but when I click on any button it says
"This Interaction Failed"
Is anyone here to help?
show code
it didn't give any errors?
big code can i send here?
sure I suppose
make it a txt tho 👀
file size?
top answer on stackoverflow:
sudo apt-get update
sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
Then install canvas
gotchu
file size or message length
Note that libgif-dev, librsvg2-dev and libjpeg-dev are optional, and only required if you want gif, svg and jpeg support, respectively.
@surreal sage
message length
im still here
there we go
@surreal sageyeah thanks for help
I don't know py very well and the slash commands n buttons and shit. I'm a legacy coder you can say (v12 discord.js'er)
Does the error ocur when you press a button
if you are a legacy coder then help my ass
so the button is the interaction which fails right
wdym
yeah
send code
that means you're probably returning before doing stuff
can you log message
nor replies
before checking if it starts with prefix
no
before checking if it starts with prefix
why do you not have the annoying taskbar on win11 https://a-blob.is-inside.me/DH7YxDgn.png
the fuck you mean its windows 11
im not stupid
There is a bug in the win 11 taskbar
also its better than 10
what is it
u guys have windows 11?
ye
What'd you think
is it pre version or global?
aah i see
beta
preview
Windows 11 Pro Insider Preview 64-bit
^^
@earnest phoenix can u log the message before checking if it starts with prefix
the 1 thing is that security takes alot of cpu and re-enables itself after each (re)start
my help?
lemme see
client.on("messageCreate", message => {
console.log(message)
// Rest of code
});
oh
let me get a line of code 4 u
const args = message.content.slice(config.prefix).trim().split(/ +/g), command = args.shift().toLowerCase();
if (message.author.bot) {
if (message.author.id === client.user.id) { } else { return; }
};
if (!message.content.startsWith(config.prefix)) return;
if (message.content.charAt(0) === config.prefix && message.content.charAt(1) === " ") return;```
this is from 1 of my bots
thats what i did
dont make args const
why
it works for me so dc
when do you even edit args
I do
thats just stupid
my ways man
still no work
command const if fucked tho, it keeps the prefix
//Importing libraries.
const fs = require('fs');
const discord = require('discord.js');
const myintents = new discord.Intents()
myintents.add(discord.Intents.FLAGS.GUILD_PRESENCES, discord.Intents.FLAGS.GUILD_MEMBERS);
const client = new discord.Client({intents: myintents});
//Config
const config = require('./config.json');
const prefix = config.prefix;
const token = config.token;
client.on('ready', () => {
console.log(`Successfully logged into ${client.user.username}`);
console.log(`Serving ${client.guilds.cache.size}`);
});
client.on('messageCreate', (message) => {
console.log(message)
if(!message.content.startsWith(prefix)) return;
/*
let args = message.content.slice(prefix.length).split(/ +/g);
switch(args[0]){
case `${prefix}hi`:
message.reply('hello there!');
break;
default:
message.reply('ok.');
console.log(args[0])
}*/
})
client.login(token);
no lol
did you save the file?
use this for args message.content.slice(config.prefix).trim().split(/ +/g)
*try that as args
no
that won't fix it
ye
does your bot have access to the channel?
lemme check it
that won't fix it
yes
well, if your message event isn't triggering that means the bot isn't recieving any messages
so it probably doesn't have access
did u restart the bot?
anyway to create ramdisk without any 3.rd party libs ( c# or python)
@tulip ledge canvas installed, thanks
np
i've got this code to get all command files ```js
const commandFiles = readdirSync(join(__dirname, "commands")).filter(file => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(join(__dirname, "commands", ${file}));
client.commands.set(command.name, command);
}``` but i want to make custom categorys cause now it gets all files from the "commands" map but i want to make for example "commands/general" and "commands/moderation" but how would i have to find them?
im not very experienced with reading files sorry
you put it in a function and check if the "file" you're "scanning" is a directory or not, if it is you run that function but change the directory to include that diretory
fs has a isDirectory method
i dont know where to start with that
u do like:
const fs = require("fs")
const path = require("path") // npm i --save path
function loadCommands(dir) {
files = fs.readdirSync(dir, error => {
if (error) return console.log(error)
});
for (const file of files) {
if (!fs.lstatSync(path.join(dir, file)).isDirectory()) {
// Load the command
} else loadCommands(path.join(dir, file));
}
}
I think something like that should do the trick
that gives JSON errors
woops
stop copypasting
forgot a )
i was just checking
also what is a JSON error?
with this its trying to find files in the command directory that arent there
why tf does this still return false?
//Check if it's the weekend (for upvoting)
var date = new Date();
if(date.getDay() === 6) { var is_weekend = true }
if(date.getDay() === 0) { var is_weekend = true }
else { var is_weekend = false };
the else overrides it
it passes the first if check, goes onto the second, doesn't pass it and jumps to the else clause
Hi. Why when I using
bot.users.fetch()
it returning
DiscordAPIError: 404: Not Found
thank you
yea
Is it because of Discord politics and i have to be whitelisted?
I'm trying to get users count.
When i did it with bot.guilds. It returned MAP object of guilds
and keep them in ur cache
what in the shitcode
i am sure this might work:
var date = new Date();
var is_weekend;
var done;
if(date.getDay() === 6) {
is_weekend = true;
done = true;
console.log(is_weekend)
}
if(date.getDay() === 0) {
is_weekend = true
done = true;
console.log(is_weekend)
}
else {
if (done === true){
return;
}
else{
var is_weekend = false;
}
};

how am i supposed to define command here? ive tried alot alr but got no idea```js
function loadCommands(dir) {
files = fs.readdirSync(dir, error => {
if (error) return console.log(error)
});
for (const file of files) {
if (!fs.lstatSync(path.join(dir, file)).isDirectory()) {
const command = "??"
client.commands.set(command.name, command);
} else loadCommands(path.join(dir, file));
}
}
loadCommands(__dirname);```
Sounds fun
Can I cook fried egg on it?
yes but no
const comand = require(`./FileName/${file}`)
So, what is the way to get users count and don't explode my PC?
bro it's literally just
let day = new Date().getDay();
let isWeekend = (day === 0 || day === 6);
wdym
yeah
i am mental type of
My bad lol
is what ive done now
this is #development right?
Yep
LMFAO
lmao
dont forget to change the } to ) lol
yes
btw <Client>.users means its global users
what i mean is
u can get every single user without needing the bot to be in a mutual server
afaik
Yep. I want to get global user count. I don't need another data about 'em
that's only cached users
the fastest and easiest way is to sum memberCount of every guild
function loadCommands(dir) {
files = fs.readdirSync(dir, error => {
if (error) return console.log(error)
});
for (const file of files) {
if (!fs.lstatSync(path.join(dir, file)).isDirectory()) {
const command = require(`./commands/${file}`)
client.commands.set(command.name, command);
} else loadCommands(path.join(dir, file));
}
}
loadCommands(__dirname);```
```Error: Cannot find module './commands/blacklist.json' ``` why?
Sounds like non-optimised thing that can explode PC too
can someone help?
its just located here, why does it error
look at where blacklist.json is then look at the error
@errant flax said that if I use bot.user.fetch() it can "explode my PC".
What happens if I load all guild and all members on them?
what i mean by "explode my PC" is if djs allowed that to happen(which prolly not bc of discord) then all users will be on the bot's cache
and btw discord probably has 1M+ users
so ye
bot.users.fetch() is used to fetch a user individually, you can only fetch a single user, given that you give the id in the fetch method
you can only get a user count of the guilds you're in, you can't get all users on discord.
ye i was meming about "explode your pc" part
this code totally doesnt work where it was intended for
OK, I understood. Thank you. I'll try to make it as you say
You have to set the initial directory to be commands so when u call the function u do loadCommands("commands")
(node:14972) UnhandledPromiseRejectionWarning: ReferenceError: AbortController is not defined it says its at the client.login line
update node to 15.0.0 or higher
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for n@7.4.1: wanted {"os":"!win32"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS: !win32
npm ERR! notsup Valid Arch: undefined
npm ERR! notsup Actual OS: win32
npm ERR! notsup Actual Arch: x64```
well they say it can
npm is a package manager for node
ah, well didn't know that
they said it could be done on windows with that but sure
who is they
aliens
it's clearly written in n's readme that it doesn't work on windows
given[key] = def[key];
^
TypeError: Cannot create property 'shardCount' on string 'a beautiful bot token has been censored here'```
what to do
hey, how would i kick a user out of a channel?
Not a server, but a channel in djs v12
a voice channel?
at Bot\node_modules\discord.js\src\util\Util.js:336
text
you can't kick them out per se
ah i am dumb, i have perms set for a role. I will just remove that role.
can someone help
how could i make a message that's sent by a bot only be visible to 1 user?
using slashcommands
how would i add that into my discord bot which already uses normal commands?
you can only make a message visible to 1 user with slashcommands
can't i combine slash and normal commands into 1 bot?
yes
but only when the command gets called with slashcommands it can be shown to only 1 user
or will that become a bad example of intervened events.
alrighty. Not sure how to do it, but will have a look rn
ephemeral messages are only possible when you receive an interaction
otherwise just dm the user
and shout at them if they have dms disabled
hmm okay
i got this from the docs:
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if (interaction.commandName === 'ping') {
await interaction.reply('Pong!');
}
});```could i use this inside my message event
without fucking everythin up>?
no
because there's no interaction in the message event
interactions are button clicks, dropdowns, slash commands and context menus
uhh okay.. how would i do it then?
because in this case you would have to use /ping
which i think is okay
is this slash command thing even available in v12? And how would i "register" the slash command?
you'll have to implement a whole another command handling system for them
not sure if they're in v12
/home/ubuntu/node_modules/discord.js/src/client/Client.js:544
throw new TypeError('CLIENT_MISSING_INTENTS');
^
TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Clien t.
npm i top.gg```
So they are not in v12?
I guess that i will switch to v13 and implement one slash command that's needed, and the rest all normal command handlers.
Without importing any other shit you can use the existing methods in client.interaction.commands to register/edit/delete interactions
you are on fucking v12
Yes i am. Why>?
hmm alright. I will try it out then.
The guide cry mentioned is trash, useless extra work and doesn’t even use djs inbuilt features even if it’s djs guide
does this method support v12?
As that's what i am using atm
v13 best
No they got built in with v13
There’s no real reason why not to update
strangely i see lots of people using v12 + slash?
I am just anxious to change everything again with 0 api knowledge of the next version
I didn’t say you can’t use them but they aren’t built in into djs
But instead of using v12 to write the correct structure of every obj down manually you would be better to update your code and use the existing methods after
Aha thanks!
if(!message.guild.channel.name === "gauntlet-game"){return message.channel.send(":x: **You can only kick users in an active game!**")}
let userToRemove = message.member.mentions.first();
let real = randomWords({ exactly: 5, join: ' ' })
let collector = message.channel.createMessageCollector(m => m.author.id === member.id)
collector.on("collect", m => {
if(m.content == real){
console.log("tetstt")
}
})```one thing tho, how would i ever implement this code in slash form.
As i cannot fetch arguments using slash commands can i?
this returns the wrong number of usersjs client.guilds.cache.get('guild_id').members.cache.filter(member => !member.user.bot).size
not all users are cached
??
You don’t need to as a command interaction allows you to predefine a parameter you need to enter, in this case a Discord user, and it will automatically pick the ID of the selected user
@trail patio one more
And send it as command option via the event
Also works with channels etc.
U will just enter @user like usual and it will be available as command interaction option
aha okay
Sounds more complicated than it actually is
yeah i kinda need something visual to go from
In your message event you have declare your arguments yourself
In your command interaction event they’re already available as interaction.options
Let’s say you create a slash command with one required parameter /ban discord-member
discord-member will be available as command.option receiving the interactionCreate event
oowh!
You just have to get the option’s value and that’s the argument the user entered with the command
so /ban parameter >> will give me the parameter to work with
How would i create a message collector then?
After using the slash command
as i suppose that the message collector won't work.
Maybe i could define it in a different command rather than slash ones
If you set the parameter as discord member, the user using the command can not enter anything else
Why would you need a collector?
The message content will be an privileged intent in the feature which means you won’t have access to it anymore
(Without being verified)
i am trying to create a game where you type /kick @short wraith, it will send a pre-generated word, and boom the collector should pick it up.
my bot is verified, so i won't need to change that.
you could use a /verify command or some sort and receive user input through that
mmmh yeah.
Sounds awesome actually.
Let me have a look, will get back in a few minutets
i am having a hard time to set the user variable
Hmm?
i make a calculator command using simply-djs package it's working but when i click on delete button it's show a error in console how to fix it?
can someone help me make a website like this?
https://blogs.snowflakedev.org/
I think there's a react component which allows you to make blogs
im not making it in react tho
Looks like the bot is missing the permissions the delete messages
it's happening in v12
managed has been a property since early days of Discord
managed entails if the role is managed by an integration like if it's a bot role or if it was created by twitch
yep
const embed = await inter.reply({ embeds: [startEmbed], components: [row], fetchReply: true })
const filter = (filter) => {
if (inter.user.id === filter.user.id) return true
return filter.reply({ embeds: [embedManager.errorEmbed(`${language(inter.guild, 'YOU_CANT_DO_THAT')}`)], ephemeral: true })
}
const collector = embed.createMessageComponentCollector({
filter,
})
collector.on('collect', async (i) => {
i.reply({ content: 'Enter Field Title' })
})
DiscordAPIError: Unknown interaction
requestData: {
json: {
type: 4,
data: {
content: 'Enter Field Title',
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
}
},
files: []
}
}
Webhooks are only available for 4s
You need to defer them in order to reply after 4s
aka. delay
3s
Shhuush 
Got it
I had .deferUpdate()
and then after that .reply()
Code:
console.log(value + " | " + title)
await embed.edit({ embeds: [startEmbed.addField({ name: `${title}`, value: `${value}` })] })
Console:
geg | sdsd
Error:
RangeError [EMBED_FIELD_NAME]: MessageEmbed field names must be non-empty strings.
so guys I'm currently trying to work with the python youtube-dl package, but when downloading a playlist I get this error: youtube_dl.utils.DownloadError: ERROR: Unable to extract yt initial data
I looked online and found someone else who seemed to have the same problem and this fix in particular seems worth trying, but I'm on windows and have no idea how to achieve what this guy did https://stackoverflow.com/a/66092779
Quick solution: don’t use python
That doesn't help
ok thanks for the help, I will redo my entire project I am working on for about a year now in another language :D
Also I'd not play with YouTube after they started hunting bots
they are only hunting bigger bots that monetise their services, this now is for private use anyways
Well... youtube can hunt any bot down that it feels like for any reason they specify
Still, too much risk
As long as it’s breaking their ToS they can send you a C&D
They're hunting mostly because bots bypass ads and don't give views
yeah as I said it's for private use and I'm fine with the risks
And YouTube is all about that sweet sweet ad rev
Also, if u use the api they already know what you're using for
It's just that the list is too big
They go after the big bots because they cause the most loss
So that's how groovy shut down


so noone has a solution to this?
Remove the <html> tags. Then add a html comment underneath to bulk your long description up to 300 characters.
<!--THIS IS A HTML COMMENT, PUT SPAM HERE-->
Remove the HTML tags and <p> tags as well

I only can see my iframe in preview but not on the public page
why?
btw my description is hidden
Try to reload the website
I did
And/or to clear the cache
Hm
function draw() {
t++;
ctx.fillStyle = bgColor;
ctx.fillRect(0, 0, cvs.width, cvs.height);
ctx.fillStyle = foreColor;
ctx.strokeStyle = lineColor;
ctx.lineWidth = lineWidth;
ctx.beginPath();
ctx.moveTo(offset, cvs.height - offset);
for(let i = offset; i < cvs.width - offset; ++i) {
ctx.lineTo(i, noise(i + t))
}
ctx.lineTo(cvs.width - offset, 200)
ctx.lineTo(cvs.width - offset, cvs.height - offset)
ctx.closePath()
ctx.fill()
ctx.stroke();
requestAnimationFrame(draw);
}
does someone knows why it doesnt work
Nothing appear in screeen when i type requestAnimaton in draw function
Did you try another browser?
const MsgCollector = inter.channel.createMessageCollector({ filter, time: 15000, max: 2 });
MsgCollector.on('collect', async collected => {
})
I want to make that the first item which was collected is var1. then the second item which is collected (the last one) will be var2.
But I dont know how to do that
const MsgCollector = inter.channel.createMessageCollector({ filter, time: 15000, max: 2 });
MsgCollector.on('collect', async collected => {
let item1 = collected.first()
let item2 = collected.last()
//kind of this
})
if your doing it in the collect event you'll need to make the variables above that scope, then check if item1 is set, if its not then set it. if it is, then set item2
above which scope?
the collect event scope
Ah ok
let item1
let item2
MsgCollector.on('collect', async collected => {
if(!item1) item1 = colllected
...
})
Dont understand it really
both items will be set because none of these are defined
let item1
let item2
MsgCollector.on('collect', async collected => {
//all code here runs every time a message is collected
if(!item1) item1 = collected;
else item2 = collected; // set if item1 was already set
//all code here runs every time a message is collected
})
didnt thought about an else state xD
it honestly doesnt matter if your not using either yet.
let item1
let item2
MsgCollector.on('collect', async collected =>
if(!item1) item1 = collected;
item2 = collected; // set the first time, and set the second time, so it will be correct by the time you use it
})
but there the items are set both at the first time
so? you hopefully wouldnt be using it yet
programming wise it shouldnt matter, its just easier to read/understand with the else
nevermind, with else it works fine because there is just ONE option when collecting. At the second code snipet you sent, there are 2 options. But nevermind first one works, thank you
The damn commands to setup applications don’t work
./apply ./register ./report
None of them work
https://srcb.in/3QO9FJc1mf i have this code and i get an error saying DiscordAPIError: Cannot send an empty message am i making the embed wrong in some way?
are any of the field values empty string?
{ name: 'WANTED', value: `${target}`, },
{ name: 'Condition To Claim', value: `${requirement}`, },
{ name: 'Reward', value: `${reward}`, },
{ name: 'Additional Info', value: `${information}`, },
)```
when i log it (line 40) it says [ 'afas', 'xcg', 'sxa', 'no extra information' ]

@pale vessel

