#development
1 messages · Page 1939 of 1
you need to use fixed milestones for that
I see
modulo would be for infinite repeatable ones
Could I use a mix?
sure
So at a certain point it just uses the modulo system once stuff runs out to give
ye
Do you think if I wanted to add more items to give it would be complicated to switch between the two?
if(10) else if(20) else if(50) else if(100) else if(level % 25)
no
Do you think using switch statements here would be easier ?
Yea
i was thinking that
so I could do something like
switch(currLevel){
case 10:
//give rewards for reaching 10
case 20:
//give rewards for reaching 20
default:
//do the if statement?
}
and if I wanna add more items I can just go in and add another case statement
sure
👍
o also should I raise the amount of xp earned each level?
or is it fine to keep it at 10-15
a small growth curve like this one is better suited for unchanging amounts of exp
Alrighty then
Guys
I need help
I am using Typescript
import keys from '../db_models/keys'
I get an error
Could not find a declaration file for module 'module-name'. '/path/to/module-name.js' implicitly has an 'any' type
import mongoose from 'mongoose'
const new_keys = new mongoose.Schema({
key:{
type: String
},
email: {
type: String,
required: false
}
});
export default mongoose.model('latest api', new_keys);
my keys.ts
Did it literally say module-name?
no
Forget that. I don't see any import of module-name anywhere in that file
this is the line I get error on
and I am so stupid I figured it out
I was using .js as the extension lmao
this is my first project in ts
Ah
but now I get this
There's no .js in here though
my file was named .js
const MessageModel = module.exports = mongoose.model('latest api', new_keys);
should I do ts export default mongoose.model('latest api', new_keys)
This should work
You don't use module.exports in TS
new to js because python is trash, so for example if i got ```js
const embed = new MessageEmbed().setTitle('ur mom')
how am i supposed to reply to a slash command with a embed
```js
interaction.reply({
//idk
})
thanku flaz ❤️
finally
+1
nah fuck python i remake world in js
Whatever happened to your old account?
Also, how do I use env with typscript
Import dotenv and use dotenv.config()
@limber flume rip
i was using olly's app
shouldn't have used 2fa in the first place
Nah you should use 2FA
don't have a password, never get locked out
Okay then take backups
i did have discord_backup_codes.txt but i reset my computer ages ago
online I am getting suggestions to use ```ts
require('dotenv').config();
Import it
I put it on google drive
import * as dotenv from "dotenv";
bigbrain
aren't you supposed to use the default import for cjs
dotenv.config();
They don't have a default import
i've contacted discord support they should remove 2fa from my account if they dont ill get mad
thanks :)
You're right
node version manager or never mind?
Can I do this- ```ts
process.env.something! as Number
rhanks
what is the difference between +string, parseInt(string, 10) and Number(string)
oh yeah sorry, i said it was all but it had html tags too 🤦♂️
aside from the fact parseInt doesn't give decimals
You just said the difference yourself
aughel's website uses an article instead of a body tag
Also TS gets mad if you use +string
And parseInt() allows you to provide a radix
Number is always decimal
parseFloat too
what's the difference b/w npm i module and npm i --save module
in older versions of npm there's a difference
iirc old npm installs it to global
--save means it always installs to your current node modules
im dumb i had the commandName different from what it should have been 
Hi guys
const rateLimit = require("express-rate-limit");
const limiter = rateLimit({
// ...
});
exports.getLimiter = () => limiter;
I am trying to convert this to typescript
and I keep getting stuck at the last line
exports.getLimiter = () => limiter;
If I do ```ts
export default {limiter}
it doesn't work
export default function() {
return limiter
}```
and if I try export default function, it gives error
Or an arrow function
yeah I get error here
What error?
it says - "Did you mean Function"
and when i change it to Function, I get an error
that expected "," or something
Can you show your current code?
name the function
Nah
I sm stupid it worked thanks
oh hey :)
Ts seems tougher than i anticipated
hi
const normal_min = rateLimit({
max: function(req, res) {
if(req.query.api_key === 'api_key_A')
return 1000;
}
if(req.query.api_key === 'api_key_B')
return 5000;
}
// fallback
return 1
})
I am getting errors here
what I dont understand is, how tf do functions work here in ts
is this not the correct way to do them or what
What errors doe

bruh
Your function only returns numbers so that should work

export function a() {}
export function b() {}```
Or ts export default { a: function A() {}, b: function B() {}, }
you mean esm?
no that would require you to destructure the default import
const isMega = (key: string) => {
}
export default {
isMega,
}
can this work as well
its not
How did you import it?
import {
isMega,
} from "../checkers/plan";
Then you need to do this
can I use it with export const fun = (a,b) =>
If you use this you have to import it without destructuring it
Sure
I have this array of objects, and let's put the array in a variable named as res.
[{ following: [], }, { following: [ '528256079101034506' ], }, { following: [ '528256079101034506' ] }, { following: [ '528256079101034506' ] }, { following: [ '528256079165983231' ] }]
How can I get the count of following that is equal to 528256079101034506? I found this hard since you need a lot of mapping but I got lost.
Since this is an array, you can also use a forloop
I'm using .map(), but am I supposed to be using a for loop inside a for loop?
let count;
for(i=0;i<res.length;i++){
// Check if following is whatever you want
// If it is
// Then add 1 to the count
count++
}
this might not be the best way
and I am no amazing at programming
but I would use this as it looks easier
Uhm.. we're back to square 1.
I can do this: .map((x, i) => ...).
what exactly do you want to do?
How can I get the count of following that is equal to 528256079101034506? I found this hard since you need a lot of mapping but I got lost.
Mapping? Sounds like you just need array.find()?
Hm.. I seem to have did this.
let count = 0;
for (let i = 0; i < res.length; i++) {
count += res[i].following.length
console.log(count)
};
.. but that doesn't seem efficient. 
A single for loop is the best you can do, and also that's not right
you aren't checking if the following array has the id
Yup, I realised. Do you think this would be efficient?
let count = [];
for (let i = 0; i < res.length; i++) {
count.push(...(res[i].following))
};
count = count.filter(x => x === "528256079101034506");
console.log(count) // count.length = 2;
A single for loop would be better
That is what I did?
let count = 0;
for (const entry of res) {
if (entry.following.includes(id)) count++;
}
In your code you create 2 extra arrays
Ah, we used a for of loop, I forgot about that.
wtf, now my preview just works without any meta data
My case would be efficient if I am trying to find what the IDs are?
you can also use reduce
res.reduce((acc, val) => acc + +val.following.includes(id), 0);
Not really, you are creating two unnecessary arrays
Oh, I see. 
Sweet.
reduce might be the fastest
Is it a mistake or does the + before the val resemble something?
the acc is the current count and the val is what u wanna add to it
the acc starts at 0 because of the second argument in the reduce function
lol
So the two +s are normal, right?
yes
let count = 0;
const promise = new Promise((resolve) => {
Social.find({
lb: 'all',
}).exec(async (error, res) => {
if (error) console.log(error);
for (const entry of res) {
if (entry.following.includes(user.id)) count++;
// console.log(count);
};
});
resolve(null);
});
await promise;
console.log(count); // 0
Why does this return "0"?
The console.log(count) inside the for-of loop returns 0, 1, 2..
Resolve the promise inside the callback
If you put it outside it will resolve immediately
it still didnt work. i used that code, but it didnt work like it did by you. https://cdn.luckiecrab.nl/crab
no preview
tho it is exactly the same
does somebody know how i can fix that?
I need help again with ts
I am using node-fetch
const data = await response.json()
const raw_response = data[0]["cnt"]
this is how I get the response
but I get an error: Object is of type 'unknown'.ts(2571)
I tried declaring data as json
await response.json<ObjectThatDescribesHowTheDataLooks>()
ObjectThatDescribesHowTheDataLooks
I dont know what Object Describes how the data looks
maybe you have to pass the generics to the fetch method haven't used node-fetch in a while
const data = await response.json()as Array<any>;
const raw_response = data[0]["cnt"]
If you know how the data looks then create an interface which describes it.
interface ApiData {
...
}
await response.json<ApiData>()
what about this
That's just avoiding type safety. Though in this context I guess it's not the worst if you can't be bothered to type the endpoint
in ApiData, do I need to just copy paste the format of json?
no https://www.typescriptlang.org/docs/handbook/interfaces.html interfaces describe the shape of objects.
How to write an interface with TypeScript
god this is confusing
Javascript / JSON object:
name: "Google",
age: 101
typescript interface:
name: string,
age: number
I think I will use promise
that is easier
in promise it doesnt ask for all this
How can you use the premium function in another file?
module.exports = bot => {
async function premium(userID) {
console.log("Hello");
};
I did it like this, but is this an efficient way?
I know this is not the best solution, but you can attach it to your bot or client variable
for eg, just do client.something = premium
then call it from anywhere using client.something()
I don't think I'm trying to achieve that.
async function premium(userID) {
If you make this a global function using what I am saying, you can just use it using bot.premium or whatever name you decide
I would've done something like:
module.exports = {
premium: async function(userID) {
console.log("Hello");
};
``` But I needed to use `bot`.
you can make bot a parameter for the function
It would give this error, then.
Oh I see, I didn't understand what you were trying to do earlier lol sorry
module.exports.premium = function(bot, userId) {
bot.doSomething(userId);
}
what's the function for?
also require(...).premium(...)
I'm exporting multiple functions, like 8 - 12, but I want to use bot, although, I didn't know how to use bot when trying to export the multiple functions.
I added this code to my index.js file so I would be able to import bot into my file, but now I can't seem to export the functions.
`http://api.brainshop.ai/get?bid=${FREE_AI_BID}&key=${FREE_AI_KEY}&uid=${id}&msg=${msg}`
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/navdeepsharma/Desktop/Remaking-RSA/node_modules/nod
Why am I getting an error here
we cannot use $ in typscript?
but I am not even using require
see the line I am getting error at
man I feel like you're just overcomplicating everything. Just create a utils file, export all the functions from there and import then where you need them.
module.exports.fn1 = ...
module.exports.fn2 = ...
const { fn1, fn2 } = require("./utils");
module.exports.premium = function(bot, userId) {
...
}
.. and I keep repeating module.exports for each function?
const { premium } = require("./utils");
...
premium(client, "123");
you can also do
module.exports = {
fn1: () => ...
}
same thing
That is LEGIT what I did, but where can I use bot? (older version of code)
PUT IT AS AN ARGUMENT TO THE FUNCTION WHICH NEEDS IT
maybe
So when I call the function, I legit need to input bot, right?
(bot, ...)
I'm so sorry this took me long to understand.
Do you know what functions really are or are you using them blindly 
I know what they are, but when it comes to exporting them, I have questions.
Bruh, I'm back to square one.
You see how I did it?
Now show the code which imports the functions
A function needs bot and a function doesn't need bot.
and which calls them
im so done
then it won't be exported?
Im done
I am freaking done
his condition will always return true since this 'Promise<boolean>' is always defined.
30 if (isNormal(key) && !isPremium(key)) return 2500;
~~~~~~~~~~~~~
export const isNormal = async (key: string) => {
const info = await keys.findOne({
key: key,
});
if (!info) return false;
else return true;
};
you don't await it
IT DOES RETURN FALSE IF I WANT IT TO
so it's always truthy
shei
even if you don't return a promise the function wraps all return values inside one because it's async
thanks
bruh
why
`http://api.brainshop.ai/get?bid=${FREE_AI_BID}&key=${FREE_AI_KEY}&uid=${id}&msg=${msg}`
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/navdeepsharma/Desktop/Remaking-RSA/node_modules/nod````
const response = await fetch(
`http://api.brainshop.ai/get?bid=${FREE_AI_BID}&key=${FREE_AI_KEY}&uid=${id}&msg=${msg}`
);
const data = (await response.json()) as any;
const raw_response = data[0]["cnt"];
this is all I am doing
what version of fetch are u using
version 3+ of node-fetch requires ESM imports
not really because typescript compiles them to require
sudo npm i -g pm2
try restarting your console
ye
close then reopen it
then that is stupid
anyway I can stop it from doing that
I'd just use an older version of node-fetch or completely switch to another library
I switched to got
axios ^
no
is there a good service where you can host a discord bot 24/7 ?
i love axios lmao
vps
https://www.npmjs.com/package/got is what I use now
ok
bruh
ima try vps
now I get that I need to use require
javascript imports are a huge mess
yes
mongoose.connect(
"",
{
useNewUrlParser: true,
useUnifiedTopology: true,
}
npx pm2
try running this
ok
what else can I say except
use brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
then brew install pm2
if it is there
actually nevermind
just checkout https://stackoverflow.com/a/41317809/15149272
why sudio -i
Oh, but arent you the admin
since you have root access
sudo npm i @discordjs/opus should work
might ask for your password though ^
can someone help?
dont use sudo for npm modules
why sudo
oh tim slready answered
sudo means super user do
and accessing your root dirs
which you dont wanna do
and node is located on the home dir which is without running as super user
just explaining if you dont know
godzilla had a stroke trying to read that and fucking died
he wasn't sending djs source code
its hard to type on an ipad
sell it and buy a hipad
based tim
👍
yea
remember 10 years ago
when iphone was taking over the market
with it came a shit ton of fake iphones
"hiphone"
and people would buy that thinking it was the same thing
because nobody knew dafuq was an iphone exactly
just that it was something new and fancy
I was 4 or 3 years old at the time but hahah
indeed
its been 14 years already dayum
whic date though
like month
oh so i was a couple months old
@quartz kindle yess monospace for the font on your website
Monospace is really poggers
lel
you just want to code, or do you want to actually host and run inside your phone?
you could use repl
oh good question
there are probably many code editor apps you can use
I think its mainly on android but yea.
but to actually run the code you will likely need additional setup
I mean phones have terminals
what most people do is run the code somewhere else, like a hosting service, a vps, an app container like heroku or repl.it
We dont spoon feed here
do you have any coding experience?
Replit is probably the best option from what it sounds like you’re looking for
which programing language did you use?
alright, so you should be fine with repl.it
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
Find TypeScript starter projects: from Angular to React or Node.js and CLIs.
repl.it is a website that hosts small apps and runs them for you, like a tiny server. they have an online code editor which you can use from your phone, no need to download anything
^^^
just a website
No if you already have knowledge of js then do you
I thought you were just starting coding so i sent you some docs
what did you use to code your bot before? discord.js?
yes, but what did the videos show
did they use discord.js?
ok, but what did they install inside repl.it
discord.js?
lol
they surely start with "install this"
what did they say to install?
lel
well, then just go watch them again
repl.it can be used from your phone, so pretty much everything they show there will still work
unless they are using an outdated version
if you use repl.it you dont need anything else
you just code directly inside replit
But I would say first know more basics of the language your using then automatically going out on the lib, but already starting out coding on mobile is better than people who use botghost
if you want to learn javascript, search for some videos about javascript
javascript as a language does not care what you use, its the same everywhere
there is no difference in mobile or pc
Yes
What?
You cant code without knowing how to code
Well you need coding skill and knowledge
No
discord bots are like a specialization. you need to learn programming first, then you can chose what you want to specialize in
this
for example, you want to be a javascript programmer, with a specialization in discord bots
so first step would be to learn javascript
and be very good at it
then move to discord,js
you dont need any other app
open the repl.it website in your phone, create a project, and start coding
yes
if you want to learn javascript, look for videos that teach javascript, or check websites like codecademy or udemy that have programming courses
yes
i dont understand what you're so confused about
You need to learn javascript or any lang to make a bot
are you looking for something like an interactive tutorial videogame thing that teaches you js?
mans brain went 🧠🧠💀
I dont quite understand the problem
hello could someone help me with a question?
How do I get the bot to send an emoji or image in the message?
why are you usiing string
and if i want to put a server emoji how do i?
you should use boolean
ik
this is like enabling the owoify right?

why not true and false mate
I mean thats not the problem but just weird
did you check the db if it actually changes on command?
put this inside an else
because you have an if above
server emojis = custom emoji
you dont need the guild id
only the emoji id
all emojis are globally unique
how do i get this id?
that is not a custom emoji
only custom emojis have ids
for default emojis you use the unicode character directly in your code
for example
message.channel.send("🛠️")
how do I get it to respond with emojis that haven't been added to the server?
your bot needs to have the permission to use external emojis
and needs to be in the server where the emoji comes from
Are slash commands cached,since I have many guild only commands.I want to retrive them and loop through to get some infos(like guild)
For djs users, you can access all guild commands on the #Guild.commands.cache prop.
When the cache has not been limited....
how can i get data with webhook on java
use php instead

anyone here use a discord bot maker from steam?
what
no its outdated
yeah but you can still buy it and make a bot
by outdated he meant that it's not really recommended if you want to make a working bot
if ive downloaded the normal d.js node package can i also download the voise version too?
or do i have to delete the existing d.js package
i mean it never worked to begin with
voice is an addon
ah
yeah but on teh docs it says when you are setting up a bot you can iether install on or the other though
its just a short cut for installing djs + addons
ah fair enough
nope it is bugged
you can still do some basic stuff
im pretty sure all that thing does it ctrl+v code into a file depending on what you want it to do
it does work i have it working right now
oh god
its not that bad it dosnt take alot of skill its alot eaiser than coding it
it automaticly codes it for you
i supose but then i've heard that the backend of that app is a mess so idk
idk like i like it but it dosnt have too many options so far i made kick ban warn check warns, youtube url VC music, rock paper scissors game, and other simple commands
for me its simple to use for someone who dosnt understand in coding. if i wanted to code it i would have to just to to that bots directory and the code is there
damn the yt player still works?
yeah
i have to update stuff on a monthly basis to keep my one working
what do you mean by that?
cuz yt is stinky and they break stuff to encourage you to watch it on the yt website
i did pay 10 bucks for it
any idea of single file, you can keep sync across many folders . Does gist support cli and is there the sub option(git inside git not possible without submodule).
well youtube is tricky beacuse some links are blocked for stuff like that so not all the links work and thats just youtube not the bot beacuse mee6 is the same way with some links
yeah thats what i mean youtube does that cuz if you watch a vid not through their platforms you bypass adds
for instance i tried converting a youtube to mp4 from a free youtube movie with ads and it will not work
yeah
but if a movie was uploaded on youtube but not by youtube by a ramdom channel it will then work
idk how it works exactly but all i know is there link is blocked
mmm thats odd
same with some copyright shit
yeah if its blocked in your country it wont work
im in the usa tho
or if you happen to live in the EU(or UK) you cant even watch age restricted videos
cuz papa govounment needs to make sure we arent naughty
lol damn yeah america dosnt care for that anymore lol
i know that s the way it should be
yeah
what ever happend to free choice over here i will never know
are you in the uk?
sadly
indeed
i was born in the US though and have a citezenship too so I will probably move back there when i have the money
i can go and live in a ranch in the midle of nowhere
thats off grid (exept for internet ofcource)
yes but dont they use discord.js internally? 2017 is like djs v11
i mean considdering that yt still works on it
i would expect it hase to have been updated
also it really annoys me how error has 5 letters unlike all my other console logs
reeee
also i think ima have to update my vc player code for v13
sigh
How do I fix this error? I just wanted to update my Bot to discord.js V13, but if I want to start it, this show up.
RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number: undefined.
pls provide your index.js or the client definition (new Client ..)
oh boi your gonna have to change quite a bit to update from v12 to v13
but that error means that you havent set any intents
Hi
What does discord use for websockets?
Yeah I know 😭
Tanks!
you mean on the server side?
surely not
there is no way of knowing without them posting about it in one of their blogs
but im assuming either python, since most of their docs show python examples, or a lower level lang like rust or cpp because performance
Well it would be python for docs as it's simple to understand any concept with it
in d.js v12 you have const client = new Discord.Client() but in v13 its changed to something like ```js
const {Client, Intents} = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, MESSAGE.CONTENT] });
Why use stuff like that
?
the only thing thats different is intents being a required option
everything else is personal preference
const client = new discord.Client({ intents: [new discord.Intents('32766')] });
eh yeah i forgot about the bitfield thing but i prefer to have the words
I understand it easier
apparently its not anymore
thats literally what discordjs/voice is
an addon
I got it, Thanks
nice
why use stuff like that
const client = new Discord.Client({ intents: 32766 });
ah yeah forgot i said i thought that i originaly though d.js voice was the same as d.js but with voice suport my bad
also you guys know the verbose logging that you can enable? is there a way to just extract some of the info from it?
cuz i would like to know the heart beat latency but i dont want it to spam my console
How do I get my Port for
serverApp.listen('your port');?
the port you want the server to listen on
http is 8080 minecraft is 25565 depends on what you are doing
what the topgg api thing ?
const getDiamonds = await
client.db.get("main", `diamonds_${u}`).then(d=>d ? d.value : 0);
client.db.set("main", "diamonds_" + u, Number(getDiamonds)+15)
})()
})
serverApp.listen('ur port');
bruh
i mean idk what to do with that cuz i dont use the api so eh
do you have to set up a dev account or somthing inortder to use the api ?
cuz if you do it might say there
but idk
Oh it was a topgg webhook 
I thought the question was just about webhooks in general not topgg. My fault.
webhooks are a way for programs to communicate to each other
using standard http
for example, top.gg webhooks send messages to your code when someone votes, those messages contain these parameters. https://docs.top.gg/resources/webhooks/#schema
(who voted, what bot/server the vote was for, if it was a test vote or an upvote, if the weekend multiplier was applied, and some query information)
just curious what do yall use for data storage for ur bots
i use sqlite
mongo
what does ur bot do
alot of things ;-;
im just trying to consider pro and cons of switching to mongo or some other db
cant name all of them
Well depends for what, i mainly use mongodb, and store it using quickmongo
like leveling
😎
cause i feel for most things i can use sqlite
I dont make multipurpose bots but mongo could do thst
but leveling im not sure if sqlite is the best thing
Sqtile is also amazing
ill go see how to use sqtile and maybe switch over to it
tbh sqlite is pretty simple
is just sql
w local db files
nah not gonna switch over to it cuz i know how to use mongo better and its more like easy to use then sqtile but ill test sqtile
preferred coding languages? 🥸
clojure
Tim told me my database was awesome yesterday
= inside if statement?
I recommend installing eslint so it can catch these kinds of things for you
have you console.logged row?
oh no
don't store guild ids as numbers
I mean your guildid is wrong
yes it is
it's truncated, look at the last two zeros
javascript can't represent numbers that large
you need to use strings or a bigint but that depends on the driver implementation
Discord sends all IDs as strings
In your SQL database you'll probably save it as text
looks right
aw
im rewriting my bot code to make it cleaner but i really dont know why my bot isnt even reacting to messages 💀
like in the on message event
any idea where the error could be (like what region of startup)
cause i can send sses as needed
but the bot runs the on_ready event
but doesnt recieve a on message event
do u have the message content intent activated?
i thought that wasnt till 2022
do you use discord.js ?
no
but im looking at the discord dev portal
but yea it doesnt work even with it enabled
yes
show your code
nvm i had a task created that had no sleep period
whats your current code?
Weird question but can bots create webhooks? Didn't see anything on the docs about it so I assume not?
Still hope then
Dope
Just gotta figure out how then
Does anyone do code golf?
solve this using less characters
https://raw.githubusercontent.com/mame/quine-relay/master/QR.rb
gets rid of bottom rows boom
I'll delete a random character ez
🧠
This is a Ruby program that generates Rust program that generates Scala program that generates ...(through 128 languages in total)... REXX program that generates the original Ruby code again.
Damn you must have a lot of time on youir hand
i could never make this
copy and paste
Arduino ide
intellij
I feel like I've seen that in aur before
vs
ah yea
you're code is still that? because this is very wrong
Has someone solved the bottles of beer one
@earnest phoenix I would love to help with your problem or try but I'm really tired and don't wanna sleep.
im trying to make a new bot and i have my script all typed out and no errors but in the console it gives me this error. Anyone know why?
You need nodejs v16 or newer
if i want to schedule an aws lambda event to run in the future should i use sqs?
maybe there's a way to use cloudwatch
sqs doesn't like waiting
cloudwatch does reoccurring events. i just want to schedule unique events to run in the future
why hasn't amazon made a feature to schedule lambda executions in the future?
this guy is doing a hack, but it lags ~48hours
https://medium.com/monstar-lab-bangladesh-engineering/how-i-solved-dynamic-task-scheduling-using-aws-dynamodb-ttl-stream-and-lambda-c0da5ebd6597
why is it so hard to schedule a lambda
I'm getting error like this user aborted a request, how can I fix this? i am using d.js v13
Its an issue with either Discord's Rest or network fidelity on your end
or your process is locked and the abort controller triggers
now i am getting internal server error
Then it's Discord
IDK why this does not work```
const keepAlive = require("./server.js")
//discord.js for using the bot for discord
const Discord = require('discord.js');
//discord client
const client = new Discord.Client();
//keep alive
keepAlive()
client.once('ready', async () => {
const rules = new Discord.MessageEmbed()
rules.setTitle('Rules')
rules.setColor('#FF0000')
rules.addFields(
{ name: '1. Treat EVERYONE with respect and Kindness.', value: 'Don't ruin someone elses day when you are having a bad day or not.', inline: false },
{ name: '2. No politics.', value: 'This includes talking about the prez and laws.', inline: false },
{ name: '3. NO NSFW content!!!', value: 'This includes Nudity, Gross things, Blood and Dead animals.', inline: false },
{ name: '4. 100% NO racism or discrimination allowed. This includes jokes/memes.', value: 'Don't make fun or joke about Gay people, People of color, People with disability, etc.', inline: false },
{ name: '5. DO NOT spam and keep CAPS to a minimum.', value: 'Spaming is useless and bad. CAPS is annoying.', inline: false },
{ name: '6. FOLLOW server RULES when chatting in DMs with other server members.', value: 'Unless they are your friends and they are okay with you not following these rules.', inline: false },
{ name: '7. The rules for this server may change at ANY TIME and it's YOUR responsibility to look at the changes and follow them.', value: '', inline: false },
{ name: '8. ONLY speak in ENGLISH!!! as we only know English and we don't know what you say.', value: 'You can talk about a languge. Just dont speak it.', inline: false },
{ name: '9. No Scamming.', value: 'No BAD/sus links.', inline: false },
{ name: '10. No begging.', value: 'We don't like it a lot.', inline: false },
{ name: '11. No advertising.', value: 'This means no discord invites.', inline: false },```
{ name: '12. Use the correct channel.', value: 'Unless it\'s relevant to the current conversation.', inline: false },
{ name: '13. Keep swearing to a minimum', value: 'DON\'T say the N or B word.', inline: false },
{ name: '14. Follow Discord TOS and Guidelines.', value: '(https://discord.com/terms | https://discord.com/guidelines)', inline: false },
{ name: '15. DON\'T ping someone for no reason!!!', value: 'No mass pinging.', inline: false },
{ name: '16. Use some common sense.', value: 'That\'s common sense.', inline: false },
{ name: 'Warning ⚠️: we look at all deleted messages so be careful about what you say/do. OR ELSE.', value: 'From staff: wahahahahahahahahahaha.', inline: false },
{ name: 'You will not be banned for using betterdiscord.', value: 'Not like Z1\'s server', inline: false },
)
rules.setTimestamp()
rules.setFooter('Thank you - STAFF');
client.channels.cache.get('843188262700056606').send(rules)
const updatedrulesmessage = new Discord.MessageEmbed()
updatedrulesmessage.setTitle('Rules have been updated!!! Please go and review them!!!')
updatedrulesmessage.setColor('#FF0000')
updatedrulesmessage.setTimestamp()
client.channels.cache.get('842129930410000425').send(updatedrulesmessage + "[#843188262700056606](/guild/264445053596991498/channel/843188262700056606/)")
client.channels.cache.get('846199943172980736').send(updatedrulesmessage + "[#843188262700056606](/guild/264445053596991498/channel/843188262700056606/)")
});
client.login(process.env.TOKEN)```
i GET ```(node:1077) UnhandledPromiseRejectionWarning: RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values may not be empty.```
rule 7 value is empty
dont worry everyone. i figured it out. step functions
is that using one of those fancy fangled 'serverless' type functions?
all this just to schedule the lambda
Whatever happened to thread.sleep()
whatever happened to goto
we got functions
whatever happened to asm
function f() {
console.log("Goto!");
}
f(); // switched! wwoo!!!!!!!
Imagine in a near future machines learning human code
neuralink
well I still want a job
i want ai to do all jobs for me
GitHub is just Microsoft's late-game embrace, extend, extinguish.
and i get to do whatever i want all the time
the ai own themselves
there will be google ai bots running around helping people and giving them ads
why did i read that as gentoo
is it true or "true"
Ye, '0' is true
0 is true?
Cuz non empty string
oh
0 isn't, '0' is
i thought you wanted 0 to be true
'0' is a non-empty string, with is always true
0 is a numeric value, which is always false
parseInt("0") is false
how to add custom emoji in drop down menus discord py?
jesus man
just do like
if (!row.owo) return
youre doing if row.owo == true
this would be cleaner
hold on
if (args[0]) return
if (!row.owo) return
embed.setDescption... rest
no need to put it all in a if statement

Hey guys I need a little bit help
const canvasMethod = async (req: Request, res: Response, next: NextFunction) => {
let img1 = req.query.img1 || req.query.img;
let img2 = req.query.img2;
let img3 = req.query.img3;
let txt = req.query.txt;
let method = req.path.method
This is my code for canvasMethod function
in a file called canvas.ts
I get this error
But in my file called routes.ts
I am doing this: ```ts
router.get("/canvas/:method", controller6.canvasMethod, normal_min, normal_day);
This assures that the path method exists
What does req.path return?
haven't tried yet
Because it thinks req.path is a string, not an object
That's a string
The value would've been undefined then
what do you mean.
you mean the :method param?
yes
data: { message: 'Bots cannot use this endpoint', code: 20001 }
bots can do dms
what is it talking about
https://discord.com/api/v9/users/@me/channels
nm, i messed up
help webhook send 1 vote
https://cdn.discordapp.com/attachments/714045415707770900/920561591605399572/unknown.png
What webserver are u running
Looks like aiohttp
aiohttp
yep

it fake
Ik
:\
What does that emoji imply kek
OhINep
Rq question as I don’t find anything online. Does babeljs add type check on compiled code for params?
It isn’t too hard for the compiler to add it tho tbh
just add some error logging code if the param doesn’t match the type when compiling it.
Well. Thanks for a answer anyways
why does this not work? it return undefined
axios({
url: `/users/655881699304931368`,
method: 'GET',
baseURL: 'https://discord.com/api/',
headers: { 'Authorization': `Bot ${config.discordBotConfig().token}` },
responseType: 'json'
})
.then(function (res) {
return res;
})
Not often I see many qts I know. Just cool to see familiar names of people I think are cool and cute 
Nou

anyone? https://stackoverflow.com/questions/70349494/discord-twitter-others-preview-for-link-not-working
So I've been trying to make a preview for my website images, on cdn.luckiecrab.nl and I've asked few people and they tried to help me but it didn't work. So the current code I have in my <head&g...
Try making sure the image urls are https
<button> is not working for me
why doesnt this work? the interaction fails when I click on the button
nvm it's working
nice
TIL. That in Discord.js 13 message.reply now actually replys instead of Mention, message content
they are :/
ive added SSL for all of them
i have an array
const l = ["ooo", "lol", "hahaha", "ok"];
how can i get the string "lol" and remove it?
should i use filter or something
did you get an error? nvm
You can use the method .findIndex(“foo”) and the use the splice method to remove that index
@spark flint all image links are https, the whole subdomain uses https, can you help me?
I'm geniunely confused as to why it doesn't work
no-one knows :((((
Are u sure all those images exist?
And thats supposed to show when you send your website url on discord right?
@timber fractal do you have an anti vpn or something
i think i might know
i tried to access using a vpn, site blocked me
the discord scraper to get embed details might be getting blocked
yep
i tested with the code and it works for me
CDN for luckiecrab.nl
Its not that
Reading the docs atm
its the exact same code on their site
Yeah I thibk so
but when disabled it didn; work
oh
That’s the only thing that could possible interfere with that I think
yep
how tf do i remove that
what host do you use
You’ll need to resolve it with them
from them
alr
oh yeah i remember
when my friend left his vpn on
and tried visiting my site
it wouldnt let him
yeah
npm WARN tarball tarball data for prism-media@https://codeload.github.com/distubejs/prism-media/tar.gz/main (sha512-lkEYKsA09+XkKqQHHK96cpmzJE3rlIoMHYww0gfS4Vodz/ZS2p/4Bt09xAqRoHpUEihbO+KdaOFGOypBdBaz7Q==) seems to be corrupted. Trying again.
npm WARN tarball tarball data for prism-media@https://codeload.github.com/distubejs/prism-media/tar.gz/main (sha512-lkEYKsA09+XkKqQHHK96cpmzJE3rlIoMHYww0gfS4Vodz/ZS2p/4Bt09xAqRoHpUEihbO+KdaOFGOypBdBaz7Q==) seems to be corrupted. Trying again.
npm ERR! code EINTEGRITY
npm ERR! sha512-lkEYKsA09+XkKqQHHK96cpmzJE3rlIoMHYww0gfS4Vodz/ZS2p/4Bt09xAqRoHpUEihbO+KdaOFGOypBdBaz7Q== integrity checksum failed when using sha512: wanted sha512-lkEYKsA09+XkKqQHHK96cpmzJE3rlIoMHYww0gfS4Vodz/ZS2p/4Bt09xAqRoHpUEihbO+KdaOFGOypBdBaz7Q== but got sha512-nLwwM6M/qz+VZ0LNzfcKrEwojdgEH5lGZDPaBpXp75gNeTEQ95ysj1QHbCUWHTLoC+fPJJ5Io13pe4RtQBmyTw==. (9770 bytes)
???
.how
I... legit... told you
yes yes i didnt read my bad
The data fetched by npm from GitHub was corrupted. You could possibly try to install from a local dir and bundle that or npm cache clear --force and try again
["command_handler", "event_handler"].forEach(handler => {
^
TypeError: Cannot read properties of undefined (reading 'forEach')
at Object.<anonymous> (/app/index.ts:25:38)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
what the fuck, that error is literally impossible
It happens inside the foreach
the error just points where the function starts, which is pretty weird
show the entire function
["command_handler", "event_handler"].forEach(handler => {
require(`./handlers/${handler}`)(client, Discord);
});
the errors is probably in one of the functions you're calling, then
How would I use canvas arcs to create a “leveling circle”? I am having trouble with the math for circles. The leveling is shown on the circle, but not at the correct length. I messed around a bit on w3schools, but since the canvas is 3k x 2k (a mistake by me lol), the math seems to be a bit different. I got as much as:
ctx.arc(1926, 300, 125, 0, (amountToNextLevel ) * 10);
Assuming amountToNextLevel is experience / experienceForNextLevel
One example is the image attached. bwepis has 32288 experience, but at level 4, level 5 requires 64000 experience. This means he should be about halfway through the arc, but for some reason it shows he’s 3/4 of the way there. I have a few other examples as well if you want to see.
Are they all the same arc? Or is it diffrent for each one?
Wdym by the same arc?
Are they all 3/4th of a circle
The experience for each person changes, but requirements for the next level is the same
No
So, what it seems is going on is you are not calculating radians
(sorry just now sat at my computer and could look at the code)
not the cleanest way to do it, but can kind of point you in a rough direction.
(also added a closepath, just for visibility, obviously you don't want that)
i actually messed that up, silly me
wrong file name in your package.json?
nope
in the wrong folder?
nope
do you have anything in your code that logs every time?
or I guess what I am asking is if your project has anything that forces it to stay on.
I dont know
add a console log to the very beginning of index.js
It basically is using nodemailer
and csv-parser
first it parses csv and saves it into an array
then emails are sent
yeah, it probably is just closing itself when done
it works
its not even started
because I am logging a lot of things
in the things
the console log at the beginning of the file works though?
yep
then somethings wrong with your code, the file is indeed running and closing itself when it finishes executing.
should I debug using console log
or just standard debugging
https://www.w3schools.com/js/js_debugging.asp
wait
tf
ok so here's the thing
everything is working when I am testing through console.log
except one function
are you calling the function?
I assume you are, but always gotta check
figured the issue
so what I was doing was
function() {
function()
}
I am dumb
👀

ggty
