#development
1 messages · Page 1921 of 1
make sure your bots invite link has the applications.commands scope
Make sure you have the application.commands scope
and reinvite it
ah ok
auto responses
that?
tim has a streamdeck full of preset keybinds
doesn't even visit the channel he has a chat bot that does it for em.
yes
tim is a computer
pov you program on a 13 inch
yes
dont bully others
huh?
it's tiny!
Keep the bot scope as well
Your monitor is just tiny
i used to code on a tiny display
im sure you hear that a lot
If you don't just use slash commands
im on the phone, i cant even type fast
mhm sure
Imagine getting to the stage of hearing that
LIAR
dont lie to us tim
i am lol
tim you must use all your fingers then
tim is the among us imposter
no way do you type faster than me on a keyboard
ah nice photoshop
dont worry tim we keep your secret
im typing slow as fuck actually
yes
youre just lagging
puffin clouds
that shit is so heavy
that's what I call a workplace
Mother.
too long
What's the resolution??
12k
basically no
just buy 3 thin 4k monitor
Fr.
No dude, a projector.
11520 x 2160p to be correct
Fr. 
time to play vAlOrAnT on a projector
Holy, 3 4k monitors. 
yeah perfect to work with
huh err.. 1080 Ti
With 3 moni- bruh.
actually monitors are really cheap
actually they are not
but gpu are expensive as ..
In Dubai, I barely find any good monitors. 
yeah today... they weren't that expensive 2-3y ago
C19 and stock prices just going up.
Even prebuilt pc with rtx 3080 are cheaper
170 euro for 1 4k monitor
hmm maybe if it's the cheapest one, yeah

yes it was the cheapest one,but you can get gd one for 200-250
yeah these ones cost ~ 270 bucks
affordable
If you necessary need an IPS panel or more than 60 Hz for whatever reason it's getting expensive really fast
.. when you have money. 
but laptop,pc,gpu prices huh,fr they are overrated
That's what I'm talking about.
144hz is really expensive.
ips is a must tho
Imagine working every day and earning money
What you do then?
or amoled 
truck driver :^)
lol
Not since TN panels nowadays got quite good
nah
Sys admin?
driver for eu politicians
lol I've got nothing to do with IT jobs lmao
I'm here building my IT portfolio.
oh
just doing whatever I do the last 15y for fun
How can Google Certificates benefit me? 
Get cisco cert like ccna
???
oh btw modifying the bios worked but had no affect on what I tried to do
lol rip
now ended up need to install the shit on a slow SSD
install some boot loader like clover
while creating a ZFS RAID1 for the NVME drives to put the VMs on it later on
Was thinking about that, too
Does that decrease the performance or does the kernel really boot the NVME then?
once the boot loader its done its job, it shouldt be needed anymore
all the relevant stuff will sit in ram
how can I join spaces? like if a player a "Magical Sword", in the code is magicalsword: {... so i want to be "MagicalSword" to make it lowercase
<String>.replace(" ", "")
did you ever do that before? does it need a whole OS or can I throw on any drive/stick?
and in a if it'll be if(<thing>.includes(" "))?
ok
<String>.replace(" ", "") // As per what KuuHaKu said.
<String> = <String>.toLowerCase()
Strings are immutable in js, right
You're good to go, then.
or just <string> = <string>.replace(" ", "").toLowerCase()
I know for sure they’re immutable in Java but never tested js
Yeah that
.. or that.
wdym immutable
cannot have state changes
meaning?
that it cannot have state changes
example pls
Ok so, ```js
let mystring = "aaaabbbbb"
mystring.replace("a", "b")
console.log(mystring) // "aaaabbbbb"
mystring = mystring.replace("a", "b")
console.log(mystring) // "bbbbbbbbb"
The string methods only return new strings, they dont modify the content of the calling string
and by not being able to have state changes, it means... ?
It means this
use gradle pls
no
...

Gradle made me instantly stop wanting to use Java, so I did
pov you use java again
I have not touched Java in a personal project for quite some time now
I plan to keep it that way
Otherwise I would’ve made mc mods
yay it detected them now
pov: you're new to coding
friend.hack.get.password(pls);
Better idea for what to do with Java:
nah java isn't bad
That’s called bedrock edition
yeah but no one uses it
C++ probably would’ve made modding for mc way harder than in Java though
in c++ i wouldve been at the stage of writing the mod by now
right now im trying to install the dependencies lmao
I suggest to directly edit the pom.xml
then use mvn install
btw you can use vscode to for java projects
decked out ide?
Intellij idea
@frozen mesa thanks
Ahh, look at that.
Old times. 
I can already feel the pain I used to go through when I was new to coding.
Banning a user with make.user.banned; 
Using JSON databases, not getting the developer badge after August 20 or 21, I really don't know, just Discord 2020, and you know what's better? 2021. 
I can't wait for 2022, input message components (fr feature), what else, verified badge? User verified badge? YouTuber badge? Banned badge?
It’s going to be 2020 Two soon

2020 was alpha, 2020 One was beta, 2020 Two is release
I coded this last night
thoughts?
and it stores a different id for different servers so if you set the id to 1234 in server a it wont change server b's 4321 :)
so, its a vote tracker for servers?
Yea kinda
You can set a link and you click the button to vote for the server
I couldn't figure out how to track the amount of votes sadly
Vote webhook
why not just get the id of the server from the guild the command was run in?
no configuration that way
I thought abt that too
wait
I could set that to the default
and you can config if you want
So before you use the update cmd it's the server's id that your in
finished
it
now do the webhook stuff ^_^
what is the function for closing an stage channel in djs?
let logs = [];
setInterval(async () => {
let webhook = webhooks.filter((w)=>w.type === "Incoming" && w.token).first();
if(!webhook){
webhook = await Channel.createWebhook(botname, {avatar: client.user.displayAvatarURL({ format: 'png', dynamic: true, size: 128 })})
} else if(webhooks.size <= 10) {
//
}
webhook.send({ embeds: logs.slice(0, 10).map(log => DeletedLog) })
logs = logs.slice(10)
}, 5000);
E:\C) Developing\Wolfy Djs-13\node_modules\discord.js\src\rest\RequestHandler.js:298
throw new DiscordAPIError(data, res.status, request);
^
DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (E:\C) Developing\Wolfy Djs-13\node_modules\discord.js\src\rest\RequestHandler.js:298:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (E:\C) Developing\Wolfy Djs-13\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
you never assign logs to anything
also collection.filter(...).first() = collection.find(...)
Hey guys whats the code to add a discord button to a message i forgot?
components
which language?
js
ok
What why?
You don’t need a third party package to make buttons and stuff easily
You can use the component builders djs offers if you really want to
But third party packages are generally not a good idea since you’re relying on someone else’s code to stay updated constantly
how do i do that?
Thanks @wheat mesa Not the First time you've helped me
Gl 🙂
What’s your code
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if (interaction.commandName === 'ping') {
const row = new MessageActionRow()
.addComponents(
// ...
);
const embed = new MessageEmbed()
.setColor('#0099ff')
.setTitle('Some title')
.setURL('https://discord.js.org')
.setDescription('Some description here');
await interaction.reply({ content: 'Pong!', ephemeral: true, embeds: [embed], components: [row] });
}
}); ```
there @wheat mesa
You didn’t define client
maybe this is the issue?
How do i?
You have to make a discord client variable called client
How?
Perhaps you should follow the djs guide from the beginning to get started, it’ll be a lot easier that way
I am
How do i add a variable?
HELP
You should try learning some javascript if you’re not sure how to set up a variable, it’ll be very difficult if you don’t know how to do that :p
You need to instantiate a discord client for that to work
I am but im confused
Show your code
@wheat mesa
@wheat mesa whats the issue?
@wheat mesa Help me quickly i gtg soon please
You need to either put this code in your index.js file or you need to set up an event handler similar to the way you set up a command handler
I highly recommend not copy pasting code in the future though
Bottom probably
OMG @wheat mesa IT WORKED
In the future I recommend you should take a moment to understand the code rather than just copy pasting it into a cloned GitHub repo (I assume that’s what it is)
But Im confused on how to do the command?
You should learn javascript a little
Because a discord bot of that size can be a complex program
And it’ll be basically impossible to understand unless you know js
Update node
Has replit started blocking uptime robot stuff yet?
I still think eveventually they will
woo
ads in #general
i don't wanna blatently ping another mod lmao
Error: TypeError: Cannot read properties of undefined (reading 'includes')
const { authorized_access } = require("../bypass.json")
let user = message.mentions.users.first();
if(!user === authorized_access.includes(message.author.id)) return; message.channel.send(`You may not Ad Warn Administrators.`)
```
Probably a simple fix but I am super confused.
afaik that means authorized_access is undefined
But it is defined tho-
can anybody help me?
<script>
window.onload = () => {
const url = window.location.href;
const accessToken = url.slice(43);
console.log(accessToken)
if (!accessToken) {
return document.getElementById('login').style.display = 'block';
}
fetch('https://discord.com/api/users/@me', {
headers: {
authorization: `Bearer ${accessToken}`,
},
})
.then(result => result.json())
.then(response => {
const { username, discriminator } = response;
document.getElementById('info').innerText = ` ${username}#${discriminator}`;
})
.catch(console.error);
};
</script>
I'm getting the error: GET https://discord.com/api/users/@me 401
I'm kind of a beginner in these things
I've tried everything and nothing
wtf are you trying to do
js in html?
wait
you're right 😐
Okay so I fixed mine but, now it still proceeds with the code below it.
let user = message.mentions.users.first();
if(!user === ["694367588464984095", "772609860100423700"]) return; { message.channel.send(`You may not Ad Warn Administrators.`) }
How do I make it so it stops after It sends that message?
I did this following the Discord.js tutorial on their website and said to do this
poor waffle got pinged 6 times during that
:c
I count 8 lol
oof
Erm, that doesn't look right.
What you are essentially doing is if the if statement returns true you are just returning the code and not letting anything after the return run
You'd most likely wanna move return inside the brackets before the message.channel.send
let user = message.mentions.users.first();
if(!user === ["694367588464984095", "772609860100423700"]) { return message.channel.send(`You may not Ad Warn Administrators.`) }
also your if statement is wrong
You can't compare a string to an array of strings, you wanna see if the array includes the user
Here's documentation on what would be the best method to use for checking if the string given exists in the array
Ohhh
Makes sense
Thats not how arrays work
user returns a user object, and comparing it to a array is always gonna return false
Will try rn ty
It works, yo your fr amazing, tysm @carmine topaz !
and to all of you who helped!
Life saver my man 💯
completely wrong
Does replit not support node 16?
Nvm, go it 🎉
Wait no, it still says 'node:events'
@earnest phoenix May I borrow your expertise one more time good sir/ma'am/or neither
🤣?
of?
Thats the error I get
all im trying to do is run the bot
Of which file?
const Discord = require("discord.js");
const db = require('quick.db')
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
const http = require("http");
const express = require("express");
const app = express();
const fs = require("graceful-fs");
const config = require("./config.json");
/*
app.get("/", (request, response) => {
console.log(Date.now() + " Ping Received");
response.sendStatus(200);
});
*/
var server = require("http").createServer(app);
const listener = server.listen(process.env.PORT, function() {
console.log("Your app is listening on port " + listener.address().port);
});
client.on("ready", async () => {
client.user.setActivity(`Noah AH Utilities`, {
type: "WATCHING"
});
console.log(`logged in as ${client.user.tag}`);
});
client.commands = new Discord.Collection();
const commandFiles = fs
.readdirSync("./commands")
.filter(file => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
const cooldowns = new Discord.Collection();
if (message.content.indexOf(prefix) !== 0) return;
const args = message.content.slice(prefix.length).split(/ +/);
const commandName = args.shift().toLowerCase();
const command =
client.commands.get(commandName) ||
client.commands.find(
cmd => cmd.aliases && cmd.aliases.includes(commandName)
);
if (!command) return;
if (command.guildOnly && message.channel.type !== "text") {
return message.reply("I can't execute that command inside DMs!");
}
if (command.admin && !config.administrators.includes(message.author.id)) {
return message.reply("You must be an administrator to run this command!");
}
if (command.args && !args.length) {
let reply = `You didn't provide any arguments, ${message.author}!`;
if (command.usage) {
reply += `\nThe proper usage would be: \`${prefix}${command.name} ${command.usage}\``;
}
return message.channel.send(reply);
}
try {
command.execute(message, args, client);
} catch (error) {
console.error(error);
message.reply("there was an error trying to execute that command!");
}
});
client.login(config.token);```
There ye go
How would my main file affect my bot starting tho?
It started in Glitch and VSC just how it is.
Replit keeps saying 'node:events'
Glitch yeah
VSC haven't tried
Fixed, holy moley there were so many problems
It was one after another
Finally got it on djs v13 tho
Replit makes stuff so confusing frfr lol
nice
slr, you fixed it already?
- Send the whole error stack
lol, i pressed esc but discord for some reason said that this was the latest message and did not refresh the channel
Did that
Now I get that
if(member.permissions.has(Permissions.FLAGS.BAN_MEMBERS))
const embed = new Discord.MessageEmbed()```
Works ty
Idk what https://discordjs.guide/additional-info/changes-in-v13.html#guildmember-haspermission
is but they needa update their guide
Wait no
Now its saying that even if the user has Ban Perms
Also, how come my slash commands show they are working, but they don't actually work?
Okay, literally disregard all of that^^ I figured out reality. 🤣
I want to keep my bot playing music 24/7 , I've eliminated clear players and queue end , player destroyer. It still disconnect vc
Yup I'm hosting it in gcp
I didn't check it. Can it be related to lavalink server? I'm hosting? Do we need to setup lavalink server differently for 24/7 music?
Exactly what I said if you read on instead of not reading
I was reposting to show him a fix to his first issue
then told him how to fix the bigger issue
nvm lol mb
yea
I was just not trying to give him the full code since its better for them to learn how to read docs
:p
@earnest phoenix do you know anything about my problem?
What exactly is your issue?
True True
module.exports.run = {
capitalise: function(value) {
return value.charAt(0).toUpperCase() + value.slice(1);
},
};
const { capitalise } = require("../../functions/functions.js");
Did I do something wrong when requiring the function?
Is that even how that works?
I think, so?
Actually thinking about it I think that should work 🤔
It isn't. 
TypeError: capitalise is not a function.
How are you using capitalise
module.exports = { ... };
can't you just do
module.exports = {
capitalise: function() {}
}
dang it flaze
;c
Oh, let me try that, my bad.
flaze too fast
I was going to do it like this.
module.exports = class Capitalise {
constructor (value) {
this.value = value;
};
capitalise() {
}
}
static capitalise() {}
Also, off-topic, how do you do it like this, just for curiosity.
For this part, basically. return value.charAt(0).toUpperCase() + value.slice(1);
Is it this.charAt( or this.value.charAt( or value.charAt(.
If you need to set values then you need to instantiate the class
Otherwise a static method will do
this.value.charAt()
👍
Anyways, using the old method.
Thanks. 
Any NPM that gives like a 6 - 20 random character code or something?
Bruh.
I kinda have it planned on my mind, let me try.
Is this good?
Kinda long. 
this is basically the regex required to match 1 character

also if you're trying to use this to generate something like keys/anything that needs to be secure, just use a package for it
yes
module.exports.run
const { run } = require("the function.js");
const { capitalize } = run;
???
const { run: { capitalise } } = require("the function.js");
according to javascript, the file exports an object called run with the property capitalise instead of directly exporting the function
remove .run
I see.
I eat
why on the GuildMemberAdd I use await member.guild.invites.fetch() but the invite doesn't update
await?
await message.guild...
You wait for the for each function to end, probably.
Use a for loop instead of forEach
It was fun while it lasted.
Is there such things called message dm collectors?
A user performs a command, the bot sends a dm to the user waiting for a message to be sent, the user sends a message and that bot reads it and uses it to do something.
.forEach is always synchronous, even if u specify async
use await instead of .then
you probably want to do
SELECT * FROM guild WHERE id = ANY($1);
const guilds = await db.get(query, guildIdsArray)
or the sqlite version of that query i guess
not exactly that is synchronous, ifyou do async, then its async. the problem is that forEach takes a callback function for each iteration in a "fire and forget" way, so even if you await inside it, the other iterations are still executed concurrently as they are in separate callback functions
can someone give me a vote notification template? I have a functional vote command but i want that when voted, the person will not have to use the vote command again, instead the bot will give the reward to him and send a DM
ik that it goes in message.js and that but idk how to make it
You will want to use webhooks to use topgg vote events.
#topgg-api https://docs.top.gg/
Error:
0|index | Something went wrong installing the "sharp" module
0|index | Cannot find module '../build/Release/sharp-linux-x64.node'
0|index | Require stack:
0|index | - /root/kpop-v1/node_modules/sharp/lib/sharp.js
0|index | - /root/kpop-v1/node_modules/sharp/lib/constructor.js
0|index | - /root/kpop-v1/node_modules/sharp/lib/index.js
0|index | - /root/kpop-v1/node_modules/join-images/lib/main.js
0|index | Possible solutions:
0|index | - Install with the --verbose flag and look for errors: "npm install --ignore-scripts=false --verbose sharp"
0|index | - Install for the current runtime: "npm install --platform=linux --arch=x64 sharp"
0|index | - Consult the installation documentation: https://sharp.pixelplumbing.com/install
0|index | at Object.<anonymous> (/root/kpop-v1/node_modules/sharp/lib/sharp.js:30:9)
0|index | at Module._compile (node:internal/modules/cjs/loader:1101:14)
0|index | at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
0|index | at Module.load (node:internal/modules/cjs/loader:981:32)
0|index | at Function.Module._load (node:internal/modules/cjs/loader:822:12)
0|index | at Module.require (node:internal/modules/cjs/loader:1005:19)
0|index | at Module.Hook._require.Module.require (/usr/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39)
0|index | at require (node:internal/modules/cjs/helpers:102:18)
0|index | at Object.<anonymous> (/root/kpop-v1/node_modules/sharp/lib/constructor.js:8:1)
0|index | at Module._compile (node:internal/modules/cjs/loader:1101:14)
``` how would i fix this?
you either didn't install sharp or you built it on a computer with a different architecture than the one you're running it on
node-gyp was intervening with the installation. So i removed it from the modules and it worked
thanks for the advice tho!
How can I see the memory usage in a command?
Math.floor(process.memoryUsage().heapUsed / 1024 / 1024)
I've did this
Anyone know what this is? discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body In 0: Invalid application command id provided
use .rss thats more accurat
to me?
yes
Math.floor(process.memoryUsage().rss / 1024 / 1024) (?)
Yes
discord on mobile, is trash, change my mind
ty, I have the exact ammount like in the vps
Anyone know?
code?
Yes it is
Check your command schema
Or actually, it could be from where you're posting commands
Ah, okay
Don't assume that they could read
that's cruel
Invalid application command id provided
For every collector that is used to collect one thing, should I always use collector.on("collect"...
For example, when you press a button, you only use collector.on('end', while for dropdown, you use collect and end.
Should I be using collect in buttons even though it's one time?
its optional, you can just change the button timeout to anything you want. But if you clicked the button then you will get no output since the timeout is done
you can use collector.on('end', for editing the response if your button's timeout is done
while collector.on('collect', is used to trigger the upcoming response for the button
and its required. Discord will return "This interaction failed" because the main button collector is missing
@Override
public void execute(SlashCommandEvent event) {
final Guild guild = event.getGuild();
if (guild == null) {
event.reply(REDCROSS + " You need to execute this command in a guild!")
.setEphemeral(true)
.queue();
return;
}
slashCmdMan.getCommands().forEach(cmd -> {
final CommandData cmdData = cmd.getCommandData();
if (DEV_COMMANDS.contains(cmdData.getName())) {
guild.upsertCommand(cmdData).queue();
} else {
event.getJDA().upsertCommand(cmdData).queue();
}
});
guild.retrieveCommands()
.queue(commands -> {
commands.forEach(cmd -> {
cmd.updatePrivileges(guild, CommandPrivilege.enableUser(Env.get("DEV_ID"))).queue();
});
});
final MessageFormat formatter = new MessageFormat(Resources.getPattern("update"));
event.reply(formatter.format(new Object())).queue();
}
so this command refreshes all slashcommands of my bot, but it feels quite redundant, because first im upserting all commands but then need to iterate through the guild commands to update the restrictions (because the dev commands are disabled) to enable my user id to use them. is there a better way to achieve that?
tf
\`${client.users.cache.get(money[i].ID.split('_')[1]) ? client.users.cache.get(money[i].ID.split('_')[1]).tag ? client.users.cache.get(money[i].ID.split('_')[1]).username ? client.users.fetch(money[i].ID.split('_')[1]).tag : "Unknown User#0000"}\`
it says } is unexpected
but it's not
for (var i in money) {
if (money[i].data === null) money[i].data = 0
finalLb += `**${money.indexOf(money[i]) + 1}.** \`${client.users.cache.get(money[i].ID.split('_')[1]) ? client.users.cache.get(money[i].ID.split('_')[1]).tag ? client.users.cache.get(money[i].ID.split('_')[1]).username ? client.users.fetch(money[i].ID.split('_')[1]).tag : "Unknown User#0000"}\` - ❂ ${money[i].data}\n`;
};
``` this is the full part
homie have you heard of variables
please break this down into separate variables, I can't even understand what's going on here
you have an entire function embedded inside a template literal with a triply nested ternary statement
ok
you're missing the else branch for the 2 other ternaries
but like you should never ever have a triply nested ternary
also money.indexOf(money[i]) + 1 is just i + 1
make a function that maps a row in your moneys array into a line in the message you're going to send
how
and the rest is just
const lines = money.map(createLine)
sendMessage(lines.join("\n"))
just make a function and call it
you don't have to use stuff like map if you're not familiar with it, but definitely use functions to break your problems down into smaller sub-problems. That's like the entire point of programming
ok (?)
And don't use var
I don't get the python one
do they think floating point arithmetic is only broken in javascript?
dunno but that rounding error doesn't happen on C++
I think it's an artifact of how js implicitly converts types
seen PHP do it but not usually on such trivial things, you usually need to divide
possibly
I think you may need to use double not float, like js does,.to duplicate it every time
3.00000000000000004 can't be represented in 32 bit float can it?
with no loss of accuracy
oh that could be it
#include <iomanip>
#include <iostream>
int main() {
std::cout << std::setprecision(17) << 0.1 + 0.2;
}
seems like it is a truncation thing
yeah, I'm pretty sure you can't represent it in float anyway
if you tried to store 3.0111111111111111111111 or something it would probably display it as ending in 111115
not enough bits to store it at 100% accuracy
lmao at D and Go
just upgraded to discord js v13 and got this error
if (!msg) throw new Error(`An invalid error message key was used: ${key}.`);
^
Error: An invalid error message key was used: Error when sending fetchProp response to master process: Cannot read properties of undefined (reading 'replace').
at message (C:\Users\KrAzZ\Documents\GitHub\Rose\Rose\node_modules\discord.js\src\errors\DJSError.js:40:19)
at new DiscordjsError (C:\Users\KrAzZ\Documents\GitHub\Rose\Rose\node_modules\discord.js\src\errors\DJSError.js:16:13)
at C:\Users\KrAzZ\Documents\GitHub\Rose\Rose\node_modules\discord.js\src\sharding\ShardClientUtil.js:199:21
at processTicksAndRejections (node:internal/process/task_queues:96:5)```
not sure if its my shards or something else
do you have .replace in broadcastEval or something?
Major updates usually require entire codebase refactoring
Found the issue. Apparently my statuses were outdated
find the problem
<script src="https://cdn.jsdeliver.net/npm/bulma@0.9.1/css/bulma.min.css"></script>
Lmao script
Anyone know how to simulate a guildCreate event? Trying to test it out and reinviting over and over would be annoying
AYO C# HAS A DECIMAL TYPE?
client.emit("guildCreate", someGuild)?
I'll try this out, probably makes it easy since I have an eval command as well
Yeah doesn't seem to work. For some reason it's not receiving the guild correctly so payload.guild is undefined
Lemme debug some more
you using djs or detritus
I think you should pass the guild as { guild: someGuild }
You start as a whole
Then you become detritus
as the error says no payload.guild
i forgot the old docs existed
I need to write a surface-level github tutorial for handling command arguments in detritus
On replit, how would I make it so it does not shut down my whole bot whenever it runs into a error, rather than it just telling me the error in a channel?
try catch the error
I did, but it always does "exit status 1" and shuts the bot down.
then you're not catching it properly
Do what you must but dont ever think about using a global exception ignorer
That is, unless you enjoy being blind af
Those are for 0.16.3
or use a library like detritus that has error catching built in
why wouldn't I use the updated version
I mean, using a catch-all is fine if you want to centralize error handling
just don't mute exceptions
use it but there aren't docs for the beta branch
who doesn't like to use beta version on production
Hey! How would i send a message to a specific channel in a specific guild? I've tried client.guilds.cache.get("id"), but i get an error saying TypeError: Cannot read properties of undefined (reading 'guilds'). Any help is appreciated :)
cannot read properties of undefined
The problem lies at .guilds tho?
how will i find the members count of a server with its ID?
Hi! Just a little question. Is there any way to know when a membre has accepted server rules (the discord rule thing with the community feature) ? I haven't found anything on the documentation about it, but my issue is that my bot currently gives new members a role automatically on join, which triggers discord to automatically makes them valide the rules :/
not my bot crashing on type errors on node v16
don't think so
oh my outdated package I forgot to update detritus
hm sad
correct
Guild members have a pending property which indicates if the member has accepted the rule gate rules
yeah i saw that thank very much :p
well, your client is not defined
define it
if you dont know what that means, show your code
interaction.client.guilds....
(node:4529) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'low' of undefined
can you help me? i'll send the entire code
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.
very useful
at least show the full error so we can see the stack trace
you have 54 instances of .low in your code, the problem could be any one of them
(node:4529) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'low' of undefined
at Object.run (/home/runner/Clash-Chest/commands/box opening/open.js:500:13)
at Client.<anonymous> (/home/runner/Clash-Chest/index.js:106:23)
at Client.emit (events.js:314:20)
at Client.EventEmitter.emit (domain.js:483:12)
at MessageCreateAction.handle (/home/runner/Clash-Chest/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/runner/Clash-Chest/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/runner/Clash-Chest/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/runner/Clash-Chest/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/runner/Clash-Chest/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/runner/Clash-Chest/node_modules/ws/lib/event-target.js:132:16)
(node:4529) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
``` everytime it's different line but the error is in that lines `.low`s
why it's undefined? all is correct like I have Goblins and in the chh array is goblins and i did chh[<myObtainedThing>.toLowerCase()]
show line 500 from open.js
it's the same thing again and again to evade the undefined but it still appears
so i'll delete that
const config = require("../config.json");
const Discord = require("discord.js");
const db = require('quick.db')
const { version } = require("discord.js");
const moment = require("moment");
const m = require("moment-duration-format");
let os = require('os')
let cpuStat = require("cpu-stat")
const ms = require("ms")
https://freeimage.host/i/BHP0JV
module.exports = {
name: "emergency", // Command Name
description: "List all of my commands/info about a specific command.", // Description
aliases: ["h"], // Aliases
usage: " ", // Usage
guildOnly: false, // If Command In DMs return
admin: false, // Bot Admin only
async execute(message, args, client) {
let prefix = config.prefix
// const args = message.content.trim().split(/ +/g);
const cmd = args[0].slice(prefix.length).toLowerCase(); // case INsensitive, without prefix
if(cmd == 'example'){
if(args[0] == '1'){
console.log('1');
} else {
console.log('2');
}
}
}
}
Tge "example" command does not show, I just started using djs v13 and with all of my commands, as soon as I fix the errors, the command doesn't run properly, it will ask "You must mention the user" or "Give a reason" but won't do the ban or anything.
No errors, just is there something wrong with my code^?
i've deleted that but same
(node:4662) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'low' of undefined
at Object.run (/home/runner/Clash-Chest/commands/box opening/open.js:585:23)
at Client.<anonymous> (/home/runner/Clash-Chest/index.js:106:23)
at Client.emit (events.js:314:20)
at Client.EventEmitter.emit (domain.js:483:12)
at MessageCreateAction.handle (/home/runner/Clash-Chest/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/runner/Clash-Chest/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/runner/Clash-Chest/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/runner/Clash-Chest/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/runner/Clash-Chest/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/runner/Clash-Chest/node_modules/ws/lib/event-target.js:132:16)
(node:4662) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:4662) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
line 585 ```js
let blaror4 = card4.low;
the name is random but the error is the .low
show where you define card4
also, please use descriptive variables
tf is blaror4?
idk
...but isn't that code yours?
i'm moving to v13 rn help me
t/Client.js:544
throw new TypeError('CLIENT_MISSING_INTENTS');
^
TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.
what's this
we didn't even solve the previous error and you're already asking abt another one
let card4 = chh[comban4.toLowerCase()] || Object.values(chh)[comban4.toLowerCase()];
let comban4 = array4[Math.floor(Math.random() * array4.length)];
let array4 = [...array1, ...array2, ...array3, ...array5, ...array6];
let array1 = db.get(common_${message.author.id});
let array2 = db.get(rare_${message.author.id});
let array3 = db.get(epic_${message.author.id});
let array5 = db.get(leg_${message.author.id});
let array6 = db.get(champ_${message.author.id});
tf
let chh = {
archers: { name: "Archers", rarity: "Common", low: "archers" }
....
....
}
why is array4 the sum of all arrays?
why are them named like that?
why are you making 5 database requests?
aaaaaaaaaaaaaaaaaaaaaaaaa

wait i'll respond 1 by 1
all the previous arrays are the obtained things and to make it easier i summed all in one
just it popped out in my brain yeah, i'm idiot
those are arrays of the cards we've obtained by rarities
all of that is completely wrong
the problem is not low
the problem is what is before it
card.low === undefined will never work, because card is undefined
i've already deleted that
and trying to read .low of undefined, causes that error
so you're reading the error wrong and trying to fix it the wrong way
After bot verified how to transfer ownership to team
because you didnt fix it
i deleted all that
Sending the error would be perfect
the error says the problem is open.js line 585
now the error is like this
/home/runner/Clash-Chest/commands/box opening/open.js:582
let blaror0 = card0.low;
^
TypeError: Cannot read properties of undefined (reading 'low')
i changed node version, it changed for that?
yes they changed the description of the error to try to make people understand that the problem is always the thing before
let card =
chh[comban.toLowerCase()] ||
Object.values(chh)[comban.toLowerCase()];
let card0 =
chh[combanO.toLowerCase()] ||
Object.values(chh)[combanO.toLowerCase()];
let card2 =
chh[comban2.toLowerCase()] ||
Object.values(chh)[comban2.toLowerCase()];
let card3 =
chh[comban3.toLowerCase()] ||
Object.values(chh)[comban3.toLowerCase()];
let card4 =
chh[comban4.toLowerCase()] ||
Object.values(chh)[comban4.toLowerCase()];
let card5 =
chh[comban5.toLowerCase()] ||
Object.values(chh)[comban5.toLowerCase()];
contact discord support
let card0 = chh[combanO.toLowerCase()] || Object.values(chh)[combanO.toLowerCase()];
this is undefined
No reply from 2 week's
¯_(ツ)_/¯
you are likely trying to get an invalid value out of chh
console.log(chh, comban0)
chh is the thing that you said me 2 months ago
console.log it
let chh = {
archers: { name: "Archers", rarity: "Common", low: "archers" }
....
....
}
``` this
So i made an event handler correct
but for the messageCreate event, no commands are being picked up
code: ```onst prefix = ["rose "];
const client = require('../app');
client.on('messageCreate', async message => {
const args = message.content.slice(prefix.length).trim().split(/ +/);
if (!message.guild) return;
if (message.author.bot) return;
const cmd = args[1]
const command = client.commands.get(cmd)
if (command) {
command.execute(
client,
message,
args
);
} else {
message.channel.send("That isn't a command!")
}
})```
it's too large are you sure, tim?
dont worry about the top
console.log comban0
idk why the c isnt there
cmd = args[0]
also, your prefix is wrong
my prefix is separate
the length of ["rose "] is 1, not 5
message.content.slice(prefix.length) makes it become ose avatar not avatar
/home/runner/Clash-Chest/commands/box opening/open.js:587
let blaror0 = card0.low;
^
TypeError: Cannot read properties of undefined (reading 'low')
at Object.run (/home/runner/Clash-Chest/commands/box opening/open.js:587:23)
at Client.<anonymous> (/home/runner/Clash-Chest/index.js:106:23)
at Client.emit (node:events:390:28)
at MessageCreateAction.handle (/home/runner/Clash-Chest/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/runner/Clash-Chest/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/runner/Clash-Chest/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/runner/Clash-Chest/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/runner/Clash-Chest/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/runner/Clash-Chest/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (node:events:390:28)
exit status 1
combanO = Barbarians
barbarians in chh
console.log(chh.barbarians, chh[comban0.toLowerCase()])
ok
{ name: 'Barbarians', rarity: 'Common', low: 'barbs' } { name: 'Barbarians', rarity: 'Common', low: 'barbs' }
this time the error from card0 is in card
where is comban0 defined?
let combanO = array4[Math.floor(Math.random() * array4.length)];
yes
all from array4 or each from different array?
let array4 = [...array1, ...array2, ...array3, ...array5, ...array6];
all
and what are these arrays lol
array4 is the sum of obtained cards
let array1 = db.get(`common_${message.author.id}`);
let array2 = db.get(`rare_${message.author.id}`);
let array3 = db.get(`epic_${message.author.id}`);
let array5 = db.get(`leg_${message.author.id}`);
let array6 = db.get(`champ_${message.author.id}`);
somewhere in array4 you have a value that is invalid and does not exist in chh, and since you're defining the combans with Math.random, then everytime the error will be in a random comban
console.log those arrays and look for an invalid value
👍
thx it was "*Mega Knight" and in chh was without *
so i deleted it from my profile
and now works without any error, now i have to delete others legendarys or i'll check documentation to replace
👍
i'll update to discord.js v13 tomorrow because it's giving errors
Take your time to update it as it will probably need some time depending on the amount of your code
oh how I make this to give always a new card and not one you already have
like the random card is selected by this:
let cards = {
"card1": { name: "Card1", level: "21", ....},
"card2": { name: "Card2", level: "22", ....},
"card3": { name: "Card3", level: "23", ....}
}
let chsl = Object.values(cards);
chssa = chsl[Math.floor(Math.random() * chsl.length)];
and the new card to give will be chssa but if chssa is already owned, i'll make it like this:
if(chssa === true) {
let chs = Object.values(cards);
chssa = chs[Math.floor(Math.random() * chs.length)];
}
``` again and again but that in some time it doesn't work and the card is duplicated, so is there a possibility to remove the owned cards from `cards`? and leave it like this:
```js
let cards = {
"card1": { name: "Card1", level: "21", ....},
"card3": { name: "Card3", level: "23", ....}
}
``` Card2 was owned so it was removed from there and now when i randomly choose there is no possibility to duplicate
Anyone good with html and particle js?
state your question and wait for answers
asking if someone is good with html will yield no answer
I been working on a website and turns out the particles and the main context come seperate, the particle was generated with a code generator and yea, this is what it shows , I probably tried many alternative methods but couldn't merge
filter the array before getting a random item from it
and what exactly do you want to do?
you mean extend the particles background to cover the entire page?
Precisely but instead of extending I wanna put the content with the particles-
No need to extend
just move it up
I did
you can use margins or absolute positioning for example
updated to discord js v13
^
TypeError: Cannot read properties of undefined (reading 'roles')```
what is it now?
O
I'll probably try positioning
you got a message that has no guild, or your message is not actually a message
but im testing in a channel
hello, i am trying to set up a component collector that only runs when the user who ran the command clicks the button, however it is running no matter who clicks.
let f = i => i.user.id == msg.author.id;
let col = msg.channel.createMessageComponentCollector({ f, time: 300000 });
(discord.js)
nvm
heres my code
module.exports = {
name: 'play',
description: 'Plays music in a VC',
/**
*
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
execute: async (message, client, args) => {
if (!message.guild.roles.cache.find(role => role.name === "DJ")) {
message.guild.roles.create({
data:{
name: 'DJ',
color: 'RED',
}
});
};
if (!message.member.voice.channel) return message.channel.send(`**You need to be in a voice channel to play music!**`);
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(`**You need to be in the same voice channel to use this command!**`);
if (!args[2]) return message.channel.send(`**You need to specify a song to play or search for!**`);
client.player.play(message, args.slice(2).join(" "));
},
};```
show where the command is executed
there you run .execute()
const client = require('../app');
client.on('messageCreate', async message => {
const args = message.content.slice(prefix.length).trim().split(/ +/);
if (!message.guild) return;
if (message.author.bot) return;
const cmd = args[1]
const command = client.commands.get(cmd)
if (command) {
command.execute(
client,
message,
args
);
}
})```
you're missing the filter
filter: f
the options object needs the key names to be correct
ohh ok
one last thing
RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.
.setThumbnail(client.user.displayAvatarURL())
.setColor(colours.rose)
.addField('General', [
`**❯ Client:** ${client.user.tag} (${client.user.id})`,
`**❯ Servers:** ${(await client.shard.fetchClientValues("guilds.cache.size")).reduce((a, b) => b + a)} `,
`**❯ Users:** ${(await client.shard.fetchClientValues("guilds.cache")).reduce((a, b) => a + b.memberCount, 0)}`,
`**❯ Channels:** ${(await client.shard.fetchClientValues("channels.cache.size")).reduce((a, b) => b + a)}`,
`**❯ Creation Date:** ${utc(client.user.createdTimestamp).format('Do MMMM YYYY HH:mm:ss')}`,
`**❯ Node.js:** ${process.version}`,
`**❯ Bot Version:** ${version}`,
`**❯ Discord.js:** v${djsversion}`,
'\u200b'
])```
well thats where the error is
well make it a string
ended up with grub bootloader and a weird bug I discussed with some people in the forums, turns out it’s a known bug and the whole Saturday was just a time waste
After investigating clover i found out it’s trash, too
how
\n instead of different lines
At the end the OS now runs on the bootable SATA SSD and NVMEs are mounted as ZFS RAID1 acting as vm file system
.filter()
Not sure if I somehow loose performance in between OS (SATA SSD) and NVME drives but that’s all I got
What a gigantic waste of time
i doubt youll lose performance
At the end it’s running now as it should
this? obj.<Array>.filter(function
yes
ok
The VM file system is a RAID as well the DB file system, that’s important
And the vmfs with its NVMEs shouldn’t have speed issues running multiple VMs and IO operations parallel
but how do i filter it by true or false?
check if the user already has it
ok
not wanting to put you down, but you should probably learn the language before attempting a big project such as a bot
the last question and i'll go to learn js like kuuhaku said (i was learning but idk why i stopped)
and the question is how I check if the user already has it? there nothing to compare with like if(card === true) but here's nothing
how do you know what cards a user has?
i never used it because i never needed
oh nvm
with the db
so i sum all the owned cards and use this?: if(array4 === true)? it's weird tho
no
i dont know what your code looks like, but you have to get the cards the user already has, for example in an array, then check if the card already exists there
for example
exists = [1,2,3]
all = [1,2,3,4,5,6,7,8,9]
notExists = all.filter(item => !exists.includes(item))
newItem = notExists[Math.floor(Math.random() * notExists.length)]
of course since you're using objects, you have to check the content of the object
.filter(item => !exists.find(existing => item.name === existing.name))
basically its a double loop
for each item in the cards array, you need to check each item in the cards the user has, and see if it exists there
Hey can someone help me fix the appearance of the game category its bugged
pass code
this is the code for the help command
you didn't end the ` in information
Oh
you cant use ` on actual emojis
the other three are unicode characters
use the unicode version of the emoji
Then what do i do for the emoji?
\🎮
Oh
\:emoji:
Thanks @earnest phoenix but uh the line what do i do?
theres a black line
did i mess something up? @earnest phoenix
you have the ` after the new lines
instead of at the end of the text
so where?
in that place
is that replit .... 😩
the issue is not being replt, the issue is him not using multiline string
Yessir
let aString = `
this is
a valid
string
`
also @lyric mountain How do I make the Header a link in the text
second parameter in setTitle
title
url
I recommend checking out https://www.npmjs.com/package/dedent
Yeah @lyric mountain

thank god
Where do i put setTitle
In this
why not just reply instead of adding that footer lol
anywhere after new MessageEmbed()
Ok!
Thanks
@lyric mountain I did that but it shows the link and not the text with the link in it like if you click the text it opens a link how do i do that?
title
url
check how embeds are made
....
.setTitleurl?
this? ```js
let chh = chhi.filter(item => !chhi.find(existing => item.name === existing.name))
this filters the true or false? i want to get only the false ones
no
let filteredTotal = total.filter(... => existing.find(...))
you are filtering the total list, chh,
and you want to compare it to the existing cards of the user
so it has to be the array that contains what cards the user already has
not itself again
let chhi = chh.filter(item => array4.find(exists => item.name === exists.name))
```?
if array4 is the cards that the user has, yes
ok
array4 is not the card, it's the sum of all the card in a array ([card1, card2]) does that count?
it has to be all cards that the user has
Uh-Oh
(node:6593) UnhandledPromiseRejectionWarning: TypeError: chh.filter is not a function
if chh is an object, then you need Object.values(chh)
or Object.entries()
I need help setting up my node_modules file how do i set that up?
What
You normally never lay a finger on that folder unless you’re modifying a library
npm init -y
const config = require("../config.json");
const { Discord, MessageEmbed } = require("discord.js");
const moment = require('moment')
const db = require('quick.db')
module.exports = {
name: "ban", // Command Name
description: "List all of my commands/info about a specific command.", // Description
aliases: ["h"], // Aliases
usage: "<user>", // Usage
cooldown: 0, // Cooldown In Seconds
guildOnly: false, // If Command In DMs return
admin: false, // Bot Admin only
async execute(message, args, client) {
let prefix = config.prefix
if (!message.member.permissions.has("BAN_MEMBERS")) return message.channel.send("**You Dont Have The Permissions To Ban Users! - [BAN_MEMBERS]**");
if (!message.guild.me.permissions.has("BAN_MEMBERS")) return message.channel.send("**I Dont Have The Permissions To Ban Users! - [BAN_MEMBERS]**");
if (!args[0]) return message.channel.send("**Please Provide A User To Ban!**")
let banMember = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.guild.members.cache.find(r => r.user.username.toLowerCase() === args[0].toLocaleLowerCase()) || message.guild.members.cache.find(ro => ro.displayName.toLowerCase() === args[0].toLocaleLowerCase());
if (!banMember) return message.channel.send("**User Is Not In The Guild**");
if (banMember === message.member) return message.channel.send("**You Cannot Ban Yourself**")
var reason = args.slice(1).join(" ");
if (!banMember.bannable) return message.channel.send("**Cant Kick That User**")
try {
banMember.send(`**Hello, You Have Been Banned From ${message.guild.name} for - ${reason || "No Reason"}**`).then(() =>
message.guild.members.ban(banMember, { days: 7, reason: reason })).catch(() => null)
} catch {
message.guild.members.ban(banMember, { days: 7, reason: reason })
}
if (reason) {
var sembed = new MessageEmbed()
.setColor("GREEN")
.setDescription(`**${banMember.user.username}** has been banned for ${reason}`)
message.channel.send(sembed)
} else {
var sembed2 = new MessageEmbed()
.setColor("GREEN")
.setDescription(`**${banMember.user.username}** has been banned`)
message.channel.send(sembed2)
}}}```
It sends the ban message to the user, but does not ban the user from the guild.
Djs v3 be so buggin lol
Where are you banning them at
Oh I see
I am confused why you are doing it this way to be honest
Is that not the way everyone does it?
I mean
Probably some people
but this just seems eh to me
Could you "refine" or fix it to where it might be easier to understand?
If you can, again up to you Cause I am completely new to v13
Okay well
Are you sure it isn't banning them?
Positive 100%
Cause seems to me it is getting past that and probably having an issue with sending the embeds after
Well
I can say one thing, you are already going to have an issue anyway. Once the member is banned banMember is no longer the person you are trying to ban
wym?
Well
When you are going to ban someone you assign their stuff to banMember right?
So you can send them a message saying they are getting banned.
mhm
I want it to send a message, ban them, then send a message to the channel.
But it won't ban and then send a message to the channel.
But once they are banned banMember becomes null, since they no longer exist in the guild so using it will cause you issues. Which I think is what is happening here.
I can only go based off the error you provided.
But idk where exactly it is having issues sending a message.
It just says can not send a empty message, so I am confused.
Its not empty tho also
Lemme try to ban them at the end
And the reason why I asked are you sure they aren't banned, cause sometimes visual bugs can happen on discord and they can appear to still be in the guild.
Send a message
then ban
If you’re on djs v13 the syntax to send content or embeds has changed
You need to provide that as options
Idk
Should of asked this sooner, v12 or v13
I am on v13
Oh then
duh
You can no longer send embeds that way
o-o
OH YEAH
OML
{embeds:[]}
You have to give it options now
yep
Yeah got it now 🤣 ty
I am guessing the issue lies there
heh
Ayy works now
Your amazing
Only a string can be send without defining messages options





