#development
1 messages ยท Page 2046 of 1
the entire story of ram is insane
you zap a piece of rock to make it store information
the entire thing about using a fuckin rock as storage is nuts
And billions of transistors in a tiny cpu
That are all capable of performing calculations trillions of times faster than any human could
I mean, human brain IS fast, we just make too many if checks do decide what to do
Lol
Too advanced of a neural network, gotta pump through all of the different nodes before getting the best output
Fun fact, doing a basic arithmetic operation in registers takes about as long as it takes light to travel across a laptop monitor
why do all my if checks lead to not doing anything productive
my doSomethingProductive() has too many conditions and ends up returning false if they dont all pass
boolean isEven(int n) {
if (!isEven(n)) return false;
else if (isEven(n)) return true;
return true;
}
if(dayOfWeek == "Monday") {
doAbsolutelyFuckingNothing();
} else {
doAbsolutelyFuckingNothing();
}
The rust community is genuinely great from what Iโve seen
Most loved language and most loving community
C++ support servers are like โno fuck you do this complex production level bullshit and I will NOT explain to you whyโ
my toaster can do more computations than that
c++ support servers suck
ego is the single handed downfall of every c++ developer
i never asked something for a development help in a support server, i always stick to googling
how did they know it's 60 bits if the human brain can't process bytes?
we're just short of being able to process a 64 bit integer in a second
32 bit ints we're fine though
a second is long tho
probably measured on how fast they make decisions
the human brain is a giga-bloated AI system
it can do a lot of things but its slow af
only if u don't use values higher than 0x7FFFFFFF
a second wont harm the user experience too much
latency sucks
idk, I don't remember
people experiencing near death experiences or dreams can recall things like faces and minute details that happened years and years ago
in childhood even
for some reason some shit just sticks and is easily recallable and sometimes its not
psychology makes me have a midlife crisis
also most of you probably already know but trauma experiences usually stick forever because its how mammals evolved to remember and avoid danger
for example i have trauma from trying to read C source code
that has prevented me from reading anymore ever again
I also remember my first english word
I was playing with hotwheels, word was "fast"
bruh
also nah bro the rust community ๐
bro just checked in on me
he asked "is it working for you?"
that never happens
im bout to cry
T_T
i used to have a trauma reading Rust's syntax, half a year later i did it again and fully learned rust
thats different ๐
also it was proved that brain flushes useless structures and optimizes data during sleep
which replays all the data again and again during it
thats the spirit
comparing the brain to a computer
does the brain have structs by any chance
how is memory stored
that's why you sometimes go to sleep and awakens fully understanding what u were doing
it must be inefficient because the brain must be storing an awful amount of dynamic data
not much static data
and why sleeping solve more bugs than SO
speaking of optimizing my database will soon have a query which optimizes the table
dangerous stuff
not as dangerous as the #dark-arts channel in the rust server
where people talk about unsafe code
imagine ur making self-optimizing queries when suddenly
UPDATE users SET name = "Alex" WHERE name = name
this is so cancer to look at
and yeah that sucks doesnt it
they do
they bully you for writing unsafe code
even tho in some cases its much better and easier than writing the "safe" alternative
ive noticed a massive flaw with rust which is why i wont replace c++ with it
for example i was wondering how would you read the contents of a file into a struct
people suggested using some library to do that
u can use reflection
it causes slowdowns and makes you use an external library tho
reflection is internal
when you can just write unsafe code to do it in one line
true
what is it
when i started Rust i added lots of unsafe blocks
because i came from a C background
anyone know how to do vue transitions
i hated working with strings, i would rather go on a char-by-char level 
<template>
<transition name="fade" mode="out-in">
<router-view />
</transition>
</template>
<style>
.fade-enter-active,
.fade-leave-active {
transition-duration: 0.3s;
transition-property: opacity;
transition-timing-function: ease;
}
.fade-enter,
.fade-leave-active {
opacity: 0
}
</style>```
dynamically allocated on the heap, copied from a char pointer, class initialization etc
especially since you wont be using the features a string offers anyways
oh and it pains me having to allocate a TEMPORARY BUFFER on the heap instead of the stack ๐ญ
for some reason my gcc allows it
but when passing the pointer to certain functions it segfaults
i know assembly it is 100% possible to allocate a dynamically sized buffer on the stack without problems
but it does get a little complicated when releasing the stack frame though
how can I make those next to each other in tailwind
like the text centered
fixed
is there an event when user get a timeout?
rust is so satisfying to write but also really complex for my small brain
Guild member update
you'd have to save the old member object and compare though
hey, i am trying to convert month to season in JS
let date = new Date();
let season;
let month = date.getMonth()+1;
if (3 <= month <= 5) {
season = 'Spring';
}
else if (6 <= month <= 8) {
season = 'Summer';
}
else if (9 <= month <= 11) {
season = 'Fall';
}
else {
season = 'Winter';
}
console.log(month);
console.log(season);
but the output is something else
6
Spring
it should be summer..
Are you certain that's exactly what you're doing
Oh wait
I'm blind
Yeah there's no such thing as if(3 <= month <= 5)
You'd have to write all of those like if(3 <= month && month <= 5)
I was wondering that. I didnt wana speak bec I didn't know if it existed or not.
"JS" 
thanks
I have personally never seen a language that syntax works in. Not a js specific thing, just so you know :p
i used it like that in python
python is a toy language can't change my mind
i always use the syntax that waffle showed even when im using python
Python is nice
ok python master
but i do use and & or 
That is logically impossible
I should make an esolang with terrible syntax but itโs fast as fuck just to troll
fast as shit
python is a toy language can't change my mind
The Texan boy is about right, gentlemen
you use php so ur opinion doesnt matter fake
You donโt wanna compare something crap like py with php

Soo shhh and listen to the older people
php is like nice but pain
py is pain sometimes
Ok boomer
client.on("ready", () => {
const channel = client.channels.get("961664136591335514");
if (!channel) return console.error("Channel dosent exist!");
channel.join().then(connection => {
console.log("I am join on voice channel.");
}).catch(e => {
console.error(e);
});
});
it's correct this code
?
py is life, py is love 
try pypy
it's like py but faster
good morning guys, im trying to do a simple command for a discord bot and i can't do it, idk why this is giving me this error, this is my first creation :c
It's saying that cant find the module but i identified it well
Instead change the require of index.js in /home/runner/Zylem-slashcommand/SlashCommands/Utility/cat.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/home/runner/Zylem-slashcommand/SlashCommands/Utility/cat.js:2:15)
at /home/runner/Zylem-slashcommand/Structures/slashCommand.js:16:34
at Array.forEach (<anonymous>)
at module.exports (/home/runner/Zylem-slashcommand/Structures/slashCommand.js:12:40)
at Object.<anonymous> (/home/runner/Zylem-slashcommand/index.js:50:37)
at /nix/store/13sxby28d6x7r98ggggp0gk5al4hdj9f-prybar-nodejs-0.0.0-7d40edb/prybar_assets/nodejs/module-context-hook.js:190:18
at Module.mod._compile (/nix/store/13sxby28d6x7r98ggggp0gk5al4hdj9f-prybar-nodejs-0.0.0-7d40edb/prybar_assets/nodejs/module-context-hook.js:137:14)
at Object.Module._extensions..js (/nix/store/13sxby28d6x7r98ggggp0gk5al4hdj9f-prybar-nodejs-0.0.0-7d40edb/prybar_assets/nodejs/module-context-hook.js:140:12)
at runModule (/nix/store/13sxby28d6x7r98ggggp0gk5al4hdj9f-prybar-nodejs-0.0.0-7d40edb/prybar_assets/nodejs/module-context-hook.js:197:5)
at Object.<anonymous> (/tmp/prybar-nodejs-935376718.js:200:5) {
code: 'ERR_REQUIRE_ESM'
}```
why this error happen
const { MessageEmbed, CommandInteraction, Client, MessageAttachment } = require("discord.js")
const fetch = require('node-fetch')
const apikey = "Not Yours"
module.exports = {
name: "cat",
description: "show some cat images",
/**
*
* @param {Client} client
* @param {CommandInteraction} interaction
*/
run: async (client, interaction) => {
const fetch = await fetch(`https://api.thecatapi.com/v1/images/search`, {
method: "GET",
headers: {"x-api-key": apikey}
})
const jsonresp = await response.json()
return await jsonresp[0].url;
const embed = new MessageEmbed()
.setColor("WHITE")
.setTitle("Meow ๐ฑ")
embed.setImage(await fetch() )
await interaction.reply({embeds: [embed]})
}
}```
this the code
node-fetch v3 recently stopped support for the require way of importing it in favor of ES Modules. You'll need to use ESM imports now
or downgrade your node-fetch to 2.6.1
kk
ReferenceError: response is not defined
at Object.run (/home/runner/Zylem-slashcommand/SlashCommands/Utility/cat.js:20:24)
._.
read your own error, you never defined response here
use cross-fetch
@earnest phoenix
I swear every power people get they'll use to do things in favour of their beliefs
anyone can guide me to a tutorial or something to how to have my bot do this?
it simplifiyes things for the users
Well, you're looking at slash commands
yea ik
i'm talking about that box where u put int() the number of messages u want to delete
i done the same trick with my bot but that box, it puzzled me to how to do it
You need to add that command option to the slash command, means you have to register that command with this option, either itโs optional or required
Since the command already exists you just have to edit the already registered slash command
Doing so by doing an API request
Then the option is permanently shown in your discord client
"attached" to this command
it's a integer interaction option
like
const number = interaction.options.getInteger("number_of_messages")
probot use it to make you specify the number of messages
when you specify the messages
there is a code
like
interaction.channel.bulkDelete(number)
Regarding the fact itโs a number I would assume the option is an integer and not a string
i forget that ๐
here is the full code
const { MessageEmbed, CommandInteraction, Client } = require("discord.js")
module.exports = {
name: "clear",
description: "clear number of message",
options: [
{
name: "number_of_messages",
description: "number of messages to delete",
type: "INTEGER",
required: true
}
],
/**
*
* @param {Client} client
* @param {CommandInteraction} interaction
*/
run: async (client, interaction) => {
let integer = interaction.options.getInteger(`number_of_messages`)
if(!interaction.member.permissions.has(`MANAGE_CHANNELS`))return interaction.reply({content: `You don't have \`managechannels\` permissions :x:`, ephemeral: true});
if(integer > 100) return interaction.reply({content: `**:x: | You can't delete more than 100 message**`, ephemeral: true})
await interaction.channel.bulkDelete(integer)
await interaction.reply({content: `SuccesFully Deleted \`${integer}\` :white_check_mark:`, ephemeral: true})
}
}
i keep getting this error here DiscordAPIError: Invalid Form Body 45.options[0].type: This field is required 45.options[1].type: This field is required 45.options[2].type: This field is required 45.options[3].type: This field is required with this code, can some1 help me?
add the type for your fields
Obviously itโs a subcommand which IS the type
I feel like heโs using an outdated djs version
js devs when they need to specify a data type: 
lmao
Noโฆ the issue is that stupid and useless builder tool
i tried, didnt work
So much fucking text and this ugly style instead of writing a simple object yourself
Log data please
so true
Your djs version might be outdated
addSubCommand() should already set the type to 1 aka. as SUB_COMMAND
Check if djs is stupid enough to require to define the sub command via the setType() method
TypeError: (intermediate value).setName(...).setDescription(...).addSubcommand(...).setType is not a function
Yeah as I assumed the method already sets the right type
Please log data
I wanna see the structure after calling the builder tool
the bot crashes upon launch
That doesnโt prevent you from logging it?!
If it does you might wanna catch and handle your errors then
Somewhere youโre calling the slash command data in your code
Log data before calling/executing it
If nothing works try getting rid of the builder bullshit
Define the slash command yourself (written as object)
do u mean this?
Wtf
Itโs indeed missing the type on the subcommand
Thatโs the reason you never use that trash builder tools
Use this structure and write the object yourself
{
name: "settings",
description: "โฆ",
options:
[
{
name: "subcmd1",
description: "โฆ",
type: 1
},
{
name: "subcmd2",
description: "โฆ",
type: 1
}
]
}
My goshโฆ
How can people write code on mobile
so something like this?
Correct
It needs to be the data
If you wanna keep your structure
Registering/updating the slash command
D:\programering\Coding\MyBots\discord.js\DJS v13\ark helper\src\events\ready.js:31
client.commands.set(command.data.name, command);
^
TypeError: Cannot read properties of undefined (reading 'name')
at Object.execute (D:\programering\Coding\MyBots\discord.js\DJS v13\ark helper\src\events\ready.js:31:50)```
data: { โฆ }
Keep your structure
Replace the SlashCommandBuilder() constructor with the object
yup got it by comparing the communicationDisabledUntil, thanks ^^
thank u
np
noob
wtf you're talking about
there's no "handler"
you either use the builder or write the object yourself as the API expects

stay mad php noob
@.@
I dont get it i have everything good , the code should work, the error is when i do the command -s ping on discord server, i would apreciate some help
you didn't install module commands
or actually, you're trying to use a module require instead of a file require
This is most definitely not the right way to do a command handler
Idk, probably
Can it run discord.py?
yes
it should work fine like normal ordinary python
it's basically python but JIT compiled instead of interpreted from byte-code
s
HAPPY LEZ WRATH MONTH
skull?
I want to draw png images on my canvas, but for some reason my canvas image is empty, this is what I have so far:
const puzzles = doPuzzle(4);
const question = puzzles[0];
const answer = puzzles[1];
const puzzleSvgs = puzzles[2].map(p => p.svg);
console.log(puzzles[2].map(p => p.data));
// from the svgs, using the canvas to draw the puzzles
const canvas = Canvas.createCanvas(1000, 500);
const context = canvas.getContext('2d');
// add the puzzles to the canvas
puzzleSvgs.forEach(async (svg, i) => {
await nodeHtmlToImage({
output: `./${i}image.png`,
html: svg
});
const puzzleImage = await readFile(`./${i}image.png`);
const puzzle = new Canvas.Image();
puzzle.src = Buffer.from(puzzleImage);
context.drawImage(puzzle, 20, 20 + (i * 200));
});
const attachment = new MessageAttachment(canvas.toBuffer('image/png'), 'puzzle.png');
interaction.reply({files: [attachment]});
Am I doing something wrong?
you cant use forEach with async
use a for loop
But it still works?
it clearly doesnt work if its empty
classic skit
TypeError: Cannot read property 'members' of undefined
at /home/runner/Bot-with-Advanced-Dashboard-6/dashboard/dashboard.js:640:25
at Layer.handle [as handle_request] (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/layer.js:95:5)
at next (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/route.js:137:13)
at checkAuth (/home/runner/Bot-with-Advanced-Dashboard-6/dashboard/dashboard.js:138:41)
at Layer.handle [as handle_request] (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/layer.js:95:5)
at next (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/layer.js:95:5)
at /home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/index.js:335:12)
at next (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/index.js:275:10)
at urlencodedParser (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/body-parser/lib/types/urlencoded.js:91:7)
at Layer.handle [as handle_request] (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/index.js:317:13)
at /home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/index.js:335:12)
at next (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/index.js:275:10)
at jsonParser (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/body-parser/lib/types/json.js:110:7)
at Layer.handle [as handle_request] (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/index.js:317:13)
at /home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/index.js:335:12)
at next (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/express/lib/router/index.js:275:10)
at SessionStrategy.strategy.pass (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/passport/lib/middleware/authenticate.js:343:9)
at /home/runner/Bot-with-Advanced-Dashboard-6/node_modules/passport/lib/strategies/session.js:69:12
at pass (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/passport/lib/authenticator.js:337:31)
at deserialized (/home/runner/Bot-with-Advanced-Dashboard-6/node_modules/passport/lib/authenticator.js:349:7)
at /home/runner/Bot-with-Advanced-Dashboard-6/dashboard/dashboard.js:76:45```
sending code in a sec
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
line causing error ```js
let user = server.members.cache.has(req.user.id);```
how can i fix this?
can you get heartbeat ping of a discord bot without editing an embed
also what?
HTTPError [AbortError]: The user aborted a request.
server is undefined
which means the client did not find that guild id in its cache
heartbeat ping is available in client.ws.ping
editing a message is for obtianing the rest latency
not the heartbeat ping
which means the client did not find that guild id in its cache
const server = client.guilds.cache.get('939926270240768000');
let user = server.members.cache.has(req.user.id);
``` either that id is wrong, or the client is not ready
ah I see
so any way to obtain latency without editing a message?
you need to make some type of operation to measure
can be sending a message or can be something else
discord only send member to the interaction handler if the command was invoked from a guild channel right? not DMs
hm
should I replace all the "targets" with smth like:
target : {
none(...) {
return [...]
}
// ...
}
what is that, discord.json?
lmfao
TypeError: Cannot read properties of undefined (reading 'id')
if (message.member.roles.cache.has(finalCheck.id || message.member.roles.cache.find(role => role.name === finalCheck)?.id || finalCheck))
return true;
else
return false;
this again?
finalCheck?.id
why does it matter? isn't it suppoed to switch to the next if ID is undefined
If finalCheck is undefined then a property id can not exist
There arenโt any properties of undefined or null
Therefore the error
I see
The optional chaining basically results in a check if finalCheck is null or undefined in the first place and if not it will continue with the property check
If one of the chain is null or undefined the condition is false
then how am I supposed to check that?
finalCheck.id is by mention, the second check is by name and the third is by plain ID
Exactly how bun wrote
won't that make the entire condition false like u said?
I can't
why not?
I suppose I could but the code wouldn't be as nice, let me walk you through my code
Also when using optional chaining you can get rid of your last condition
Another check if finalCheck isnโt null or undefined is not required
Itโs already covered
const modRole = message.settings.modRole; //<-- user setting, can be either ID, mention or name of the role
// then I have a bunch of code changing the whatever user selected to the role variable
let finalCheck;
// then in the end this is the variable
// And I use this piece of code to check if the user has the role and based on that I state whether it should be true or false
if (message.member.roles.cache.has(finalCheck.id || message.member.roles.cache.find(role => role.name === finalCheck)?.id || finalCheck))
return true;
else
return false;
also I have it in a if statement, because I want to expand on this later
Now add optional chaining for your first condition and remove the third one entirely
wdym?
if finalCheck is undefined, then all other conditions will also fail by default
so why not just add a if(!finalCheck) return false before that if even starts?
not to mention that if could be structured better, but it doesnt really metter
In Chakra-UI, how can I append a function in native JavaScript? For example:
fetch(config.api_server + "/search", requestOptions).then(async res => {
let json = await res.json();
json.map((item, index) => {
console.log(item);
document.appendChild(<Feature title={item.title} link={item.id} path={item.path} views={item.views} likes={item.likes} cover={item.cover} />);
})
}).catch(err => {
console.error(err);
});
function Feature({ title, link, views, likes, cover }) {
return (
...
);
}
The request is called whenever the Search button is clicked. So basically:
<Button h='1.75rem' size='sm' onClick={(() => {
...
})} />
I mean you can add an extra line or keep his structure
return (finalCheck?.id && (message.member.roles.cache.has(finalCheck.id || message.member.roles.cache.find(role => role.name === finalCheck)?.id)) ? true : false;
Might be missing a )
Idk on mobile
if it's finalCheck by itself that means it's just the ID
chakra-ui is a UI framework
not related to your issue at all
Yeah I just realized that. Whoops
Also why are you using React AND the document API like this??
That's not a good idea
at all
are you asking how to do that in react?
I'm attempting to code in Express since I'm not used to React yet lmao. Originally I would just use jQuery to append data, but since React isn't like that it's a bit confusing for me
function Component() {
const [features, setFeatures] = useState([]);
// when you want to add a feature...
setFeatures([...features, new_feature]);
// To show all features...
{features}
}
Sorta. Right now I'm using useState.
const [data, setData] = useState(null);
const search = async() => {
...
});
<Button onClick={
async() => {
let json = await search();
setData(json);
}
}>
Ah I see. Thank you that makes things a lot easier haha.
This also works
if not it's even cleaner
function Component() {
const [data, setData] = useState([]);
// when you want to add data...
setFeatures([...data, new_data]);
// To show all features...
{data.map(feature => <Feature>...</Feature>)}
}
๐ I'll mess around with that. Thanks
anyone know how to animate svg sprites as svg? and not on canvas
in html or where?
svg can be animated via css
some versions of svg also include built in animate tags
yeah in html, mm alr thanks
project idea: .gitignore viewer (like regexr for regex, break down and explains what you've written)
I'm fuckin tired of gitignoring the wrong files and just noticing when it's too late
Iโm tired of accidentally forgetting to gitignore some files like auto genned Intellij garbage
I'm actually surprised nobody made a visual gitignore builder yet
like, with explanations of what each line is doing
make one
I would, if I wasn't busy with language migration (job) and bot rewrite (personal)
do it
in this line if (cmd && blacklistedGuildArray.includes(message.guild.id) && message.channel.type !== "DM") it says that the ID is undefined while trying to execute the command in DMs
any idea how to avoid that?
/*
?
Check for the channel type and assure it's not a DM channel before accessing the <Message>.guild property
so swapping the checks around would work fine?
Yes
oh
@earnest phoenix do you have any idea why setActivity dissapears after some time?
and if possible how to keep it alive?
It's usually either caused by the users' Discord clients not retrieving the activity information properly, or Discord removing the activities by some factors or time I suppose
You can try setting the activity again on an interval to prevent it from disappearing
having an interval wouldn't be too great on performance
That's not true, and it depends on the task
well I wrote some code to set random activities so at least I'll put the interval to use
const logger = require("../modules/logger.js");
const { getSettings } = require("../modules/functions.js");
const activities = [
"hating {{showServers}}/100 servers.",
"hating you.",
"hating the {{prefix}}help command.",
];
module.exports = async client => {
setInterval(() => {
const updateStatus = activities[Math.floor(Math.random() * (activities.length - 1) + 1)];
client.user.setActivity(updateStatus.replace("{{showServers}}", client.guilds.cache.size).replace("{{prefix}}", "-"), { type: "COMPETING" });
}, 10000);
};
will that affect the performance?
I wouldn't recommend setting the activity every 10 seconds
then how long?
5 minutes or so?
About every 2 minutes is an acceptable interval for bots I believe
But I think 5 minutes is a good balance
does setting the activity interval to 10 seconds cause bot performance to be down graded?
im just wondering
might get ratelimited
API abuse, discord doesnโt like you spamming activity change requests
I think the limit is 5 changes per 30 or 20 seconds, but itโs not a good idea to change it that much anyways. Unnecessary
so 300000?
What?
like 30000 for the interval
The least I would ever change it is once every 45 seconds
topgg's general recommendation is 120 seconds
so what would i set it?
120 seconds
i have itโs set to 10000
12000?
(Assuming 10000 is in milliseconds)
Take 120, and multiply it by a thousand. Thatโs your seconds in milliseconds
120000
There you go


EDIT: cloudflare ๐
chhanging the firewalls
ok
I'm super confused. When I set up my React server and use nginx to open the port (https://anify.club is my website), the config is for some reason set to localhost:3060. Locally it's set to https://api.anify.club, but on the main website it's set to localhost. I have no clue why and it's extremely infuriating because for the past hour I've been trying to fix cors, because for some random reason it isn't working (I keep getting the cors blocked error even though I have cors enabled, but apparently it's a CloudFlare issue??). Is this an issue with React, or an issue with browser cookies?
collector.on("collect", (collect) => {
let(i.user.id === interaction.user.id)
if(i.user.id != interaction.user.id){
interaction.reply({content: `:x: | **This Menu in not for you**`, ephemeral: true})
}```
will this code work or nope ?
I don't know will it?
is notepad ++ for programming ?
How to use a custom emoji in a command response?
steps
1- Make a new server and add your bot in the server
2- upload the emojis you want
3- do \[the emoji]
4- it will apper like the emoji name and an id
5- copy it
6- go to your bot code
client.on("message", msg => {
if(msg.content === "ping"){
msg.reply(`[paste the emoji text here] pong !!! `)
}
})
alright
np
a: is been used for animated emojis only
so.. it is possible to do something when a user is getting a timeout, but how can i get the reason for the timeout?
nvm solved by fetching the audit log
why does this error message shows sometimes?
o
what are you hosting the bot on
yeah but what are you hosting the bot on
it wait like an hour or two then the error disappears and everythings back to normal
replit
so is your issue fixed
yea but it still returns
still returns the error?
i need to understand the issue in order to prevent that error from occuring
since repl it uses shared IP addresses, someone else or maybe you flooded the Discord API (or thatโs what I think what happened)
if you want to host your bot, maybe donโt use replโฆ
do you recomend me an alternate solution?
you can probably get a cheap VPS somewhere
kill 1 is only a temporary solution, so yes as I said I recommend you donโt use repl for Discord bots
i see thank you, that was really helpfull
i was excited when i got replit to be my bots free server host but i'll consider moving to vps
there are some decent free ones out there if you need a temporary one but I'd suggest actually buying one like stated above
replit isn't a good idea for it
Replit is container-based so doing kill 1 is basically killing your current container and moving your repl to a new container with a new ip, hence the method works
eventEmitter
eventEmitter2
in nodejs
I would like to bind all events of them to
eventEmitter3
is there a method for it?
Wasn't there a joke about the comical amount of eventemitters available on npm?
refresh data
can you help me how do i do this
go to your bot page and press refresh data
ok
it's done thank you very much


is there a way to do conditional returns without an if statement or assigning the result of the function to a variable?
const a1 = () => {
if (a2() === 2) {
return a2();
}
return 1;
}
const a2 = () => {
return 2;
}```
something like this ```js
const b1 = () => {
b2() === 2 ? return b2() : undefined;
return 1;
}
const b2 = () => {
return 2;
}
or this ```js
const f1 = () => {
f2();
// do other stuff
return 1;
}
const f2 = () => {
// force invoking function to return 2
force return 2;
}
You could do return b2() === 2 ? b2() : 1
For ternary return expressions the return needs to be in front of the ternary expression
i only want it to return if the function wants it to return
Then no I donโt think you can
just return null from the second function and use ??
I think the idea is that if a function returns a certain value, he wants it to return in another function, but if it doesnโt return that value, he wants it to continue running the calling function
or if ur using java:
if (f2() instanceof Integer i) {
return i;
}
return 1;
But you canโt do this without an if statement as far as I know
If you want it on one line, you could do ```
if(b2() === 2) return b2();
// other stuff here```
javascript should have something built in for this
that is pretty much "built-in" no?
const a1 = () => {
const thing = a2();
if (thing === true) {
return "found thing";
}
// keep searching
return 1;
}```
there should be a shorthand for this
const a1 = () => {
const thing1 = thing1();
if (thingExists(thing1) === true) {
return thing1;
}
analytics.track("thing1 not found")
// keep searching
const thing2 = thing2();
if (thingExists(thing2) === true) {
return thing2;
}
analytics.track("thing2 not found")
}```
Again, no reason to be storing the function calls in variables there
Nor do you have to write the curly brackets if you donโt want to
And comparing to === true can just be shortened to if(thing)
but you need to invokje the function twice to make it a one liner
that's truthy logic
i avoid truthy logic
I know but Iโm assuming that youโre not returning an object in a function that returns a Boolean
not really
This is where macros are nice to have
intellij has a lot of nice macros built in
i tried breaking switch statements and failed
I did something like that once
put true inside switch () and conditionals in case
btw, u can technically use ```js
block: {
if (f2() == something) break block;
return aValue;
}
just
case thing1(): ...
try {
these_hands();
} catch() {
// hand caught
}
that works?
ye it should
i could use variables
how can you check if req.path includes stuff in an array?!?!1
if (req.path.includes(['/test','/something'])) {
it only checks for /test
Assuming req.path is a string, itโs .contains
Unless thatโs not what you were asking
(i think)
I have some doubt any one can help me
And includes only takes one argument yeah
Well, whatโs the type of req.path
Just ask your question, donโt ask to ask :p
process of bot verification
Nevermind then, I suppose itโs .includes()
I got confused with Java
it is called javascript after all lmao
Just seems odd to have it as .includes on something that isnโt an array tbh
@earnest phoenix donโt dm me about bot stuff, just ask in here please ๐
what they're probably looking for is if (req.path.startsWith("/somepath"))
Itโs official, my laptop still works and can run intellij ๐
my laptop only has 4gb ram and running visual studio code + a wsl instance + a c++ intellisense + compiling makes it cry
it takes like 5 seconds for it to lint something every time i write a line of code
This is a 2017 laptop and it still runs pretty good
16gb of ram because I upgraded it
Mine has one stick soldered in, but I have 4 sodimm slots and it was only using 1
In theory you could upgrade it quite a bit, but Iโve had no reason to do that since this is the first time in about 3 years or so that Iโve used this laptop
Itโll make a good dev machine for when Iโm not at home
Process of bot tick mark broh
Im new for these things @wheat mesa
sodium*
totally not running an old intel xeon processer with 52GB of ram
I donโt even know what youโre talking about
What does this even mean?
something to eat i think
๐
here my bot is verified broh how i need to get bull tick beside of my bot like process when it recahed 75+ @wheat mesa
those are buttons
Yeah when i kept emojis in buttons it's came like this : โถ๏ธ
because those are entirely different emotes
they probably uploaded them to a private server for use
Where can I get it any idea ?
google, then add them to your server
or any server u can add emtoes to, it doesnt matter
Yeah but I need transparent like this but I serached from google
then get a transparent one
Please can u help me with link like this
Is there like a NPM package I can use for messages like: <t:1654387200:f>
Formatting time?
Mhm.
welcome to the 2022 generation of javascript developers
I've done a few searches, but failed.
you 100% dont need a library to do it but i dont know how to do it either but someone else prob knows
Kk
literally, just go to google and type "<name> icon transparent"
The format timestamp.
<t:1654387200:f>
<t:1654387200:f>
yeah just plop that into your message in your bot and it will work
I know, but I want it to like for example.
that's just <t:unix_timestamp:f>
If a user starts a giveaway and they want it to end in 12 hours.
It will make a format for 12 hours forward.
use js's built in date API, or use moment
mk.
sounds like you need relative time
K
<t:1:R>
first time doing it haha
<t:timestamp:R> is what you need
<t:1654376744795:R>
is this epoch time
Then just use JavaScript Date to add whatever future time to the current time and convert that to unix
Alrighty, thanks to you all for the help :)
also this is kinda unrelated but does anyone know how to fix my stupid touchpad scrolling dogshit? It keeps scrolling almost as if I'm doing tab in discord
Math.floor(new Date().getTime() / 1000)
<t:1654376870:R>
K broh
tip you can just use Date.now() instead of new date get time
Ah yeah, forgot about that
Old habits still get me
stop it tim
Or just hardcode the current time and update it manually 
OMG! IT worked :D
let time = Date.now();
setInterval(() => {
time++
}, 1)
<t:1654377033:t> <t:1654377033:t>
<t:1654377033:T> <t:1654377033:T>
<t:1654377033:d> <t:1654377033:d>
<t:1654377033:D> <t:1654377033:D>
<t:1654377033:f> <t:1654377033:f>
<t:1654377033:R> <t:1654377033:R>
i will go to bed <t:1654380039:R> to wake up at 6am for first shift
holy shit my laptop is actually so dumb
it uses arrow keys to simulate scrolling with the touchpad
so it fucks up in discord
Yeah, it was time ago
So counting away from the time they set since it was in the past
or maybe it isn't I can't even tell, seems to work fine in intellij (just REALLY sensitive)
bruh
good to know to never buy elantech
lenovo laptop, elantech touchpad apparently
now I can actually scroll properly
I have no idea why anyone would ever want to use arrow keys to scroll
(when they're purposely using a touchpad already)
rust crates are being stinky and stupid rn
simple question, but can't seem to figure out a fast solution for this ```
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
I know the answer is 6857, but I don't know how to efficiently calculate that without blowing up my pc
I could just cheat and use a rust crate, but I want to solve it myself
Anyone have any ideas?
Nevermind, got it
my garbage rust code if anyone wants to look at it ```rs
pub fn largest_prime_factor() -> u64 {
*compute_primes(600851475143).unwrap().last().unwrap()
}
fn compute_primes(upper: i64) -> Option<Vec<u64>> {
if upper <= 1 {
return None;
}
let mut vec: Vec<u64> = vec![];
let mut copy = upper;
for a in 2..upper {
if copy % a == 0 {
vec.push(copy as u64);
copy /= a;
}
if copy == 1 {
return Some(vec);
}
}
Some(vec)
}
surprised that worked tbh
that top function though 
Steal its source code ez
Nah the source code for those prime factorization crates are extremely complex because math moment
looks shit
You look shit
I feel like shit after reading about what reflection in java is
I have a feeling I understand the basic concept of it but I already know I am completely wrong

Seems to me it is just invoking something you need at runtime by grabbing it from the class
Basically
Thereโs lots of stuff that falls under the roof of reflection
One of which is doing that, yes
I also read that it is also possible to invoke something that is possibly unknown?
As far as I know itโs basically accessing source code during runtime
Wdym by that
I have no fucking clue waffle it is just what I read
Unwrap abuse
Reflection basically destroys type safety
Since itโs all done at runtime
But it also allows you to do basically anything you want
So reflection is a good way to do a cmd handler for a JDA bot then?
You basically just grab the class and invoke the execute method set when you need it
You can look at the way kuuhaku does it for his bot
What he does is basically look for any types in a certain directory annotated with the @Command() annotation, and then puts them into a HashSet and loads them into his bot from what I remember
Thereโs some fancy stuff he does in there but thatโs the basic concept
He uses a library called Reflections 8 (I think thatโs what itโs called) that offers a lot more features than just what native Java offers
meanwhile in #rust-general
Mushroom soup is mid
lmao
The rust community has been very kind to me in recent days in regards to my stupid questions
Surprised at how patient they are
and bro I never woke up at 6am purposefully and its hell
I notice where he is using relfection tho
That uses some concepts you have learned about quite yet
Like wildcard generics (I think thatโs what itโs called)
lesgo existential types
i wish it existed in ts
you have to recompile better sqlite
just uninstall and reinstall it
this is more than likely because you transferred node_modules to your vps instead of leaving it out and running npm install on the vps
is there a node library that i can use to receive emails?
receive emails in what way?
like an smtp server? or just imap?
https://github.com/mscdex/node-imap
^Imap
https://simonjcarr.medium.com/create-an-smtp-server-with-nodejs-5688d8fd882e
^ smtp
just a heads up, email is an absolute pain. services like gmail, yahoo, hotmail, etc all have so many measures to prevent spam that it can be really hard to get a proper email server setup on your own server.
I personally suggest using third party email servers
you can get microsoft free
microsoft dev
Join the Microsoft 365 Developer Program to get resources to help you build solutions for the Microsoft 365 platform.
it absolutelly takes a lot of effort getting your ip whitelisted anywhere and fullfilling any sender and receiver framework
hi guys, so im trying to make mute command, an now, i have two commands (slash commands):
mute-role <= create new role for muted members
mute <= mute members
now, in mute-create i should, create role, place it above other roles(my bot role position is highest, so new created role should be right under bots role).
so this is the code i wrote: ```js
const { SlashCommandBuilder } = require('@discordjs/builders')
const { Permissions } = require('discord.js');
const mute = require('./mute');
module.exports = {
data: new SlashCommandBuilder()
.setName('mute-role')
.setDescription('Create role which will be assigned to muted user.')
.addStringOption(option =>
option
.setName('role')
.setDescription('role name')
.setRequired(true)
),
async execute(interaction, client, guild) {
const mutedRole = interaction.options.getString('role')
const HighestRole = guild.roles.highest
interaction.guild.roles.create({ name: `${mutedRole}`, permissions:
[
Permissions.FLAGS.VIEW_CHANNEL
],
color: '#fc6565',
});
mutedRole.setPosition(HighestRole.position - 1)
interaction.reply(`${mutedRole} has been Successfully created !!!`)
}
}
and this is error i getting:
TypeError: Cannot read properties of undefined (reading 'me')
at Object.execute (F:\discord_bot\Apolo\commands\moderation\createrole.js:20:39)
at Client.<anonymous> (F:\discord_bot\Apolo\index.js:87:23)
at Client.emit (node:events:527:28)
at InteractionCreateAction.handle (F:\discord_bot\Apolo\node_modules\discord.js\src\client\actions\InteractionCreate.js:83:12)
at Object.module.exports [as INTERACTION_CREATE] (F:\discord_bot\Apolo\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (F:\discord_bot\Apolo\node_modules\discord.js\src\client\websocket\WebSocketManager.js:351:31)
at WebSocketShard.onPacket (F:\discord_bot\Apolo\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
at WebSocketShard.onMessage (F:\discord_bot\Apolo\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
at WebSocket.onMessage (F:\discord_bot\Apolo\node_modules\ws\lib\event-target.js:199:18)
at WebSocket.emit (node:events:527:28)
if anyone know how i can fix this it would be great, also. in my mute file, i added: ```js
const mutedRole = require('./createrole')
```soo, with my logic, here i should be able to assign created role to selected user
anyone know what cloudscale means and if i should use it?!?!1
are you sure you saved the file and restarted the bot before getting this error?
yes
your error is specifically happening right here, it looks like you deleted .me after guild.
https://i.imgur.com/kAOvqW6.png
(line 20 character 39)
yea i tried to doi it without .me since when i add it, it gives error of undefined .me
.me isnt undefined, guild is
you're reading me
so effectively undefined.me is what the error says
I tried adding guild in listener paramter and at execute() parameter, but yea, still undefined .me
function parameters are ordered in javascript
https://i.imgur.com/GyrY8Ib.png
you're sending message(which is undefined it seems) into the guild variable.
and the guild variable into nothing
also, interaction create doesnt have a variable for message or guild.
https://discord.js.org/#/docs/discord.js/stable/class/Client?scrollTo=e-interactionCreate
so your guild variable is undefined anyway
we all do
and sounds like you need to import it the old fashioned way
how are you importing it?
im trying to make a .json file thats connected to my blacklist.js so it scans every blacklisted links/words and automatically deletes them when someone sents an invite link or the blacklisted word
const blacklist = require("blacklist.json")
do note, it might be desirable to have a per-server blacklist configuration
in which case you should be using a db
idk, gotta test
like does anyone have a code for me cause im newbie to coding
we wont give you code.
const discord = require("discord.js")
const client = new discord.Client();
client.on("message", m => {
if (m.content === "!ping") {
m.channel.send("Pong!")
}
});
client.login("ODQmMTAxNzMoNzIzMjAxMDQ1.GgARxC.OpiAO_gfNFaGlqTBwSGZi5yKuGsamovo91PBZj")
This old af, not updated
this, in fact will work fine on any version, just change message to messageCreate
yes
Im shit at HTML but wanna make cool description
and message will still work because its deprecated
adding intents is one line more
still better to change that
no
have fun getting hack :^)
Im hack you!!//1
throwback to the time i sent a log file to the discord.js server which contained a token amongst the thousands of lines of logs and then an hour later someone logged into the bot, changed every channel name to something to do with goombas, spam sent images of goombas in every channel and sent ninja and forgor
LOL
const Discord = require("discord.js");
const client = new Discord.Client({
intents: [Discord.Intents.FLAGS.GUILDS, Discord.Intents.FLAGS.GUILD_MEMBERS, Discord.Intents.FLAGS.GUILD_BANS, Discord.Intents.FLAGS.GUILD_MESSAGES, Discord.Intents.FLAGS.DIRECT_MESSAGES]
});
client.on("messageCreate", m => {
if (m.content === "!ping") {
m.channel.send("Pong!")
}
});
client.login('ODQmMTAxNzMoNzIzMjAxMDQ1.GgARxC.OpiAO_gfNFaGlqTBwSGZi5yKuGsamovo91PBZj')
you're actually right..
... x2
except they dont care bc the only option is to move to another library if you dont like the changes
Reply me pls
nice token
thanks
css
Idk how to change bg
one day i will send my discord account token in chat just to see what happens
discord automatically resets it
and dms u
not your account token
o
cap
wait account token
only way to reset is to change password
Imma send mine rn
or change username
or discrimnator
or anything
๐ฟ
Dont work
make a command to command your waifu
rip
make sure to use the style tag in the html
ik
make sm image manipulation cmds?
It doesnt work
<style> CSS_HERE </style>
use jimp or canvas
send code
I know but it still doesnt work
main
main?
๐
it doesnt work as body too
last time i saw someone use main in html was back when php was the node.js
url shortner cmd
๐
and remember to add the !important tag at the end
otherwise it won't update
if something else overrides it
Still nope
I do
our people will have to wait another 2 weeks because I hadn't put him online 24 hours. sad
dont think you should use body either
<style>
body {
background-color: black !important;
}
</style>
it will conflict with topgg
jesus christ that's not this hard
Its like that genius.
that's the entire point
yes
german flag fr ๐ด
It still dont work :/
man u gotta learn css fr ๐
Ima watch yt tutorial
bro clear everything
lazy
and paste the code I wrote
clear everything and just include his code
๐
Are you expecting everyone here to do everything for you while you procrastinate on learning CSS
until you want to style something complex and the css conflicts in unexpected ways
Its the same.
prolly not working because he enclosing the style tags in main tag
ig
idk
you must be doing something wrong otherwise it would've worked
just a guess
website took too long to send a response
!important time inb4
I told you to include !important tag
uh isnt the page background already black
Still nope
๐
๐ญ
Important tag didnt do it
Connection timed out
copy my code and try again
Ok
Nope
still have the bot dev role but we dont talk about that
No they have 0 clue what they are talkin bout
Dont work
It doesn't always have to be the website taking too long to respond
show what you did
check inspector and show code
Im phone
You didn't supply a required field
Wait it worked now
congrats
Ig preview broken
I ain't a mind reader
Make sure all your fields are filled with data
What data does the array contain
Never would of guessed that
something like this?
blacklist.includes(word => {
if (message.content.toLowerCase().includes(word)) message.delete() && message.author.send("Keep the use of Profanity out of our server!")
})```
๐ญ
why
just use blacklist.includes why forEach
Doesn't SlashCommandBuilder already create the JSON you need?
foreach performance ๐ ๐ ๐ ๐
^^^
It is just a class that helps with creating the proper stuff options are its own thing
Recommend any color or background? Current color too bright
Yeah but why the e: shit
The type of the data you want option to be
๐คทโโ๏ธ
#000
I don't fuck with djs anymore
Good boy Misty
This is Black
you said your color was too bright
pick a neutral color then
there is no perfect lib:(
Ima put image maybe

๐ซ