#development
1 messages · Page 1940 of 1
the function connecttochannel runs fine since one it doen't through any errors and two its almost a complete coppy of the player example on the docs
the only trouble is im trying to use it to fix my original thing from v12 and its not going to well
i am getting error like "the user aborted a request" how can i fix this
Djs?
That error is thrown when a request takes too long to be handled.
Such as uploading images on a slow connection(such as home networks, or maybe even replit, or super budget vps providers). Or just slow networks in general.
It can happen randomly sometimes due to discord too, but is pretty uncommon.
If you're getting this error commonly I would suggest try another hosting provider temporarily if possible.
Yes
i am using d.js v13
And i am using vps
I've been getting this error for 3 days
I think it has to do with hosting because i live in Turkey and my vps in the Turkey
Like 150 ms
Is it happening on specific things? Or just on random things every time?
Might help to get a vps closer to discord servers, which are in the US iirc.
You could also increase your timeout duration, but thats not a good method imo
i have 6,000 guilds and happens when too many people use the bot at the same time
Yeah likely vps issues then.
Try a better VPS
What are the specs of the VPS and where do you get it from?
And what is your budget?
how do i add my html document to an email and also make it work, not like this smh
vps has i9 9900K 4 cpu and 2 gb ram but in the Istanbul / Turkey so bot has a to much ping
what budget do you have
The amount I paid comes to 4 dollars, so 50 TL, but for me it's like 50 dollars 😄
I can't buy a vps from abroad because Turkey economy like a monopoly lmao
so $4 a month basically?
anyone has experience with html?
ew shiba inu
If im being honest I didn't know you could use html in emails
try dogecoin
try eth ;)
how else does the replit newsletter work
trick question
I dont use replit
nerd
does client.on("clickButton", async i => { }) is still working on djs v13? i've trying to use that code but not working (i want to make button still working when bot restarted)
didnt know clickButton was an event
why will you do that
you should check for the event from inside the command itself
global event listeners are terrible
saying from experience in fucking up my react code
oh ok
is it just me or is clickButton not even an event
it's probably interactionCreate
I see
yea
with the type set to button's code
it is
mhm
it's probably 913
???
that's the neat part, you don't
you probably have to do it through code
how
gmail changes your <> and / to < > and (escape character for /)
so it isn't actually html
try nodemailer
You need something like Sendgrid or Sendinblue

Or use roundmail client which supports it
diagnosis: provider issue
plain skill issue
xml encoding
quick question
if i wanna add stuff to a queue object
but the queue object is in the main bot file
but the place im adding stuff to the queue from is in another class in another file
can i just pass the queue object into the bot file and add items into it and itll update the original queue object
(python)
Anyone who could tell me what 2PG is?
?
you can't use node from the console
change the run command with the .replit file
I need some help for the regex again.
I have some md files and want to parse out everything in the custom tags <command />
Maybe you want a formal Markdown parser
A regex is naive
For example, <.+?> will gladly match all HTML tags, including those where it doesn't make sense in context (e.g. a comment)
But comments would've been matched anyway
found one
which is not good 😓 , adding more props in the tags does not match it anymore
my bot is still running while my codes off and it's using the old code from a while ago that i delted
What's the best way to refactor common logic used across different lambdas? Should i move the logic to a npm module or move the logic to different lambdas?
also what are some good private npm hosting options?
I reset the token
I did before but I change to the other tab instead and it worked
how to do that?
i cannot see any options on the developer portal to allow for anything metnioned there
this is slander
eeeyy sweet! tyvm mr big ❤️
lol
Centos is considered more stable and secure iirc, but likely doesn't matter for a bot
I'm currently using windows server 2012 r2 64 bit should i stay here
Ubuntu has no issues running for months though
if you like it and feel comfortable with it just stay with it, but generally linux is considered more stable
there is no problem in the 2012 R2 but my bot has 6,000 servers i wonder which one os will be more performant
os performance will likely be irrelevant
but i dare say linux would likely be more performant
I understand thanks
what's the best way to refactor common logic used across different lambdas Tim?
refactoring to npm or another lambda?
i'm thinking refactoring it into another lambda might be best
how can i set this up for global commands i just need to change the "MainGuild"
Linux was created with servers in mind
Differently to windows with focuses on end-user experience
Not that it's a good experience either
(node:696) UnhandledPromiseRejectionWarning: TypeError: args[0].toLowercase is not a function
``` ._.
You sure args[0] exists?
#920530847944278047 message
@trail orchid If you're struggling with centering stuff I think you might be missing fundamentals of how css + html build on top of each other. Have you looked at how the box model works? https://web.dev/learn/css/box-model/
ye
Console log it
Idk then
can you show the part of the code which you log, then use toLowerCase?
I mean all together, as args may not be defined the same way in two separate positions
i console args?
does your toLowercase look like this toLowerCase()?
ye
it wasn't in args[0] now that i check, it was in a args[1] so probably because i didn't provided a args[1] so i'll make it conditional so if there ain't any args[1], it won't set cards to args[1].toLowerCase()
i'll check when it loads
Trying to use embeds with slash commands ```console.log("NodeJS Version: " + process.version)
const express = require('express');
const app = express();
const port = 3001;
app.get('/', (req, res) => res.send('Hello World!'));
app.listen(port, () => console.log(Server is up));
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
const { MessageEmbed } = require('discord.js');
client.once('ready', () => {
console.log('Ready!');
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const { commandName } = interaction;
if (interaction.commandName === 'meme') {
const embed = new MessageEmbed().setTitle('testing');
await interaction.reply({ embeds: [ embed ] });
}
if (interaction.commandName === 'help') {
await interaction.reply({ content: 'coming to your discord soon', ephemeral: true });
}
});
client.login(process.env.TOKEN)```
but it does not work ``` throw new DiscordAPIError(data, res.status, request);
^
DiscordAPIError: Unknown interaction
Can't get this to work ...
a
I can ss @spark flint
sure
try settting http://localhost:3000/callback as your callback url in the dev panel
https://ben-is-a.communism.pro/UVaQ5ej0 mine for example
Nope still not working :/
does. anyone know?
u ok
not helpful
nvm
no it has ! infront
const roleID = '920868198717456384'
const inviteLink = '.gg/solodev'
client.on('presenceUpdate', (_oldPresence, newPresence) => {
const member = newPresence.member
if (member) {
if (!member.roles.cache.has(roleID)) {
const customStatus = newPresence.activites
.find(activity => activity.type === 'CUSTOM_STATUS')
?.state
if (customStatus) {
if (customStatus.includes(inviteLink)) {
member.roles.add(roleID)
.catch(console.error)
}
}```
How come this doesn't work?
A friend asked for help and idek this one 🤣 haven't used presenceUpdate in a while.
does he have presence intent enabled
put where?
even in the new Discord.Client?
const { Client, Intents, Collection, MessageEmbed, G } = require('discord.js');
const discord = require('discord.js');
const client = new Client({
partials: ['MESSAGE', 'CHANNEL', 'REACTION' ],
allowedMentions: { parse: ["users", "roles"] },
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
// Intents.FLAGS.GUILD_MEMBERS,
//Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
// Intents.FLAGS.GUILD_WEBHOOKS,
// Intents.FLAGS.GUILD_INVITES,
Intents.FLAGS.GUILD_PRESENCES,
],
});```
Yes, it has everything on.
Would they need the GUILD_MEMBERS intent enabled tho?
Since it is looking for members w/a status?
Just a thought I had.
Just need some clarification so you can only fetch webhooks by their ID and token? You can't by their name?
enable everything
I just use the top usable one in a channel.
All intents is kinda bad 💀
Interesting
for testing
if it works then its a issue with your intents
I'm making it so it looks for a specific webhook and if it's not there then have it make that webhook. But I don't want the user to provide anything token wise as I want it to be dynamic
Ahh, makes sense.
Well
Tbh, you could just use a command to create one.
Fetch that and use it as such..?
Kinda ruins the dynamic part though sadly
It would yeah. :/
wait for some reason that fixed it maybe code didn't update idk
What is the issue?
im sad
k
just be happy
Easy solution
Just fetch all webhooks in the channel and sort by name
Should definitely work with no issues 💀
why post that here
You good bro? 🤨
no
I can tell
client.on('presenceUpdate', (_oldPresence, newPresence) => {
const member = newPresence.member
if (member) {
// Ignore members who already have the role
if (!member.roles.cache.has(roleID)) {
const customStatus = newPresence.activites.cache.get(activity => activity.type === 'CUSTOM_STATUS')
if (customStatus) {
if (customStatus.includes(inviteLink)) {
member.roles.add(roleID)
.catch(console.error)
}
}
}
}
})
Error::
TypeError: Cannot read properties of undefined (reading 'cache')
should I do .find??
even then its still undefined.
well 1
you are using get wrong anyway
🤣 knew that
if its undefined then its undefined
then why do it
Can I see the full error
bro u cant index a undefined value
how do i check if server has application.commands enabled for the client 
Just have the invite link make the commands
it is just one of the scopes

Make sure the presence intent is enabled both in bot and dev panel
yeah but what do i do with the hundreds of servers that dont have application.command
Well
Tell them to reinvite the bot ig
im tryna make a message like "reinvite cuz no slash commands"
When I did my bot and added slash it pushed to the servers it was already in so idk
only if application.commands is disabled
I guess just have the message send no matter what
And remove it after some time
Or use a db on when it rejoins the server to log something and if it's not in the db then send the message
waste of database space even though it doesn't matter
^
Not like the amount it takes up will be anywhere near worrisome
it just doesn't make sense
How I explained it or it itself?
The idea in itself
im pretty sure discord will remove the application.commands thing in april
since its gonna be the default for all bots
No no

Honestly
Just dont worry about it
those who actually care will join your support server
and just tell em there
ez
So am I doing something wrong here?
client.guild.channels.cache.find('920873655515377688').send({ content: `<@${member.id}> Added \`.gg/solodev\` to their status. ` })
I tried .get and stuff but nope.
whats the error
Client.channels
Not client.guilds.channels
Then get should work
If you use find you'll need to pass a function not just an id
client.channels.cache.get('920873655515377688')
client.channels.cache.get('920873655515377688')
again that is completely wrong
you are mixing up get and find
Worked, tyty
get requires an ID find you can do that wonky shit with
Imma go
on those two rq
yes please do
Will do lol
wyd bruh
means exactly what it says
yo big issue so im trying to fetch a webhook by its name like this
let find = await interaction.channel.fetchWebhooks().then(hook => hook.find("webhook"))
if(find) {
console.log("found")
}
and i get this random error
TypeError: e is not a function
at Map.find (C:\Users\dezja\Desktop\Goot\node_modules\@discordjs\collection\dist\index.js:1:1708)
at C:\Users\dezja\Desktop\Goot\slashCommands\invite.js:28:83
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.execute (C:\Users\dezja\Desktop\Goot\slashCommands\invite.js:28:23)
at async module.exports (C:\Users\dezja\Desktop\Goot\events\interactionCreate.js:12:3)
anyone undertand it?
e is nowhere in this file btw
Okay another one
if (activities && (activities.state.includes('.gg/solodev') || activities.state.includes('discord.gg/solodev'))) {
try "state?.includes"
repl issue i guess
line 28 of invite.js
It's just saying the same thing over n over.
I'll try to fork it ig
hmm weird
logging "hook" provides the entire webhook info
oh wait
nvm
hook.name wouldnt work duh
Nope, it's just saying
TypeError: Cannot read properties of null (reading 'includes')``` the whole time `o-o`
its null
whenever it says of null it means whatever before is null
client.on('presenceUpdate', (_oldPresence, newPresence) => {
const member = newPresence.member
const activities = member.presence.activities[0]
if (activities && (activities.state.includes('') || activities.state?.includes(' '))) {
client.channels.cache.get('920885277042556968').send({ content: `<@${member.id}> Added \`.gg/\` to their status. ` })
make sure you log stuff to see if it is undefined/null
It's my status.
well thats cool and all but it could be an issue with the event not giving relevant data
.find expects a function, not a string
it is
Nvm worked.
guess i could map it idfk
too tired for this
logging the name isnt important i just want fetching to work
anyone care to explain this error because its beyond annoying 💀
then why would d.js say to do this smh
i asked someone
should have explained that
if i cant use find then how tf am i supposed to do this
i mean, if you use the functions correctly it will work
i just use them how im told 🤷♂️
whoever told you that was wrong lol
not suprised
main reason i dont go to that server for help kekw
guess it worked
nice
there was a time, a few yeas ago, where discord.js's find used to accept a string like that
thanks as usual Tim
but that was removed a long time ago
i see
now i can get this feature to work
because collection.find() is based on array.find(), and array.find() always required a function
discord.js was the one being weird when they accepted non-normal stuff
so it was a good thing to remove it
sure
for(const a of minerals) {
for(const b of a) {
const item = user.items.find((r) => r.name === b.name)
if(!item){
const i = new Items()
i.name = b.name;
i.value = b.value;
await i.save()
user.items = [...user.items, i]
await user.save()
} else {
item.amount += a.length
await item.save()
}
}
}
:)
2D array looping
I fucked up badly
Bot is still thinking
hmm
idk what minerals is, but ideally you'd want to loop over everything, to whatever operations need to be done, but dont save anything
wait until the loop ends, then save everything at the end
[
[
{ name: 'Cookie', value: 25 },
{ name: 'Cookie', value: 25 },
{ name: 'Cookie', value: 25 },
{ name: 'Cookie', value: 25 },
{ name: 'Cookie', value: 25 },
{ name: 'Cookie', value: 25 },
{ name: 'Cookie', value: 25 },
{ name: 'Cookie', value: 25 },
{ name: 'Cookie', value: 25 }
],
[
{ name: 'Peppermint', value: 65 },
{ name: 'Peppermint', value: 65 },
{ name: 'Peppermint', value: 65 },
{ name: 'Peppermint', value: 65 }
],
[
{ name: 'Truffles', value: 90 },
{ name: 'Truffles', value: 90 },
{ name: 'Truffles', value: 90 },
{ name: 'Truffles', value: 90 },
{ name: 'Truffles', value: 90 },
{ name: 'Truffles', value: 90 },
{ name: 'Truffles', value: 90 }
],
[
{ name: 'Gingerbread', value: 40 },
{ name: 'Gingerbread', value: 40 },
{ name: 'Gingerbread', value: 40 },
{ name: 'Gingerbread', value: 40 },
{ name: 'Gingerbread', value: 40 }
]
]
why are there so many duplicates?
user.items = [...user.items, i]
whatever happened to using.push:(
You can mine more than just 1 of each
Wdym
{ name: 'Gingerbread', value: 40, count: 5 }
.....................................
Ya know what
I didn't think about that ima be honest with ya
But idk how to exactly do that
private async mine(): Promise<ICandyInfo[]> {
const candy: ICandyInfo[] = []
for(let i = 0; i < 25; i++){
const c = candies[Math.floor(Math.random() * candies.length)]
candy.push(c)
}
return candy;
}
This is how i currently mine things
candies being a array in a json file with candy
[
{ name: 'Cookie', value: 25, count: 9 }
{ name: 'Peppermint', value: 65, count: 4 }
{ name: 'Truffles', value: 90, count: 7 }
{ name: 'Gingerbread', value: 40, count: 5 }
]```
uh
That isn't very helpful
I get what you mean or at least I thought I did
am I misunderstanding your intentions?
what is this mining supposed to do?
mining is supposed to return you with a list of stuff you've mined
which you obv wont just mine 1 of everything
you'll get multiple of a resource
const mined = {}
for(...) {
const name = // get a random name somehow
if(!mined[name]) { mined[name] = 0; }
mined[name]++;
}
return minded;
the above will return something like this ```js
{
"Cookie": 3,
"Truffles": 6,
...
}
🤔
Not sure I follow how this can be used practically
Or are you saying
private async sortMinerals(data: ICandyInfo[]): Promise<ICandyInfo[][]> {
const sortingObj: Record<string, ICandyInfo[]> = {}
for(const stack of data) {
const { name } = stack
if(name in sortingObj) sortingObj[name].push(stack);
else sortingObj[name] = [stack]
}
const sortedMinerals = []
for(const stacks of Object.values(sortingObj))
sortedMinerals.push(stacks.sort((a,b) => b.value - a.value))
return sortedMinerals
}
Could I implement the count thing here somehow?
This method just returns a 2D array with the duplicates into their own arrays
But if I can implement counting them instead of sorting them int otheir own arrays I dont need to make a 2D array
Well
I wanna do what you suggested instead
I wanna instead of making them into a 2D array just implement that count thing
then its easy
instead of creating a new array then push stuff to it, you create an object with a count property, and increase the count
if(name in sortingObj) sortingObj[name].count++;
else sortingObj[name] = { count: 0 }
for example
My only worry is
{
"Truffles": { value: 10, count: 5 },
...
}
I don't know how exactly after doing this, how ima save the items to the db
the whole point of the 2D array was so I can loop through and save the items like that
Serialization is an option
I have a hard time explaining my thoughts sadly
you should never need to individually save one thing at a time, thats very bad
😩
you should always do everyting at once, then only save at the end
yea
so say I do have it like this:
{ name: 'Cookie', value: 25, count: 9 }
{ name: 'Peppermint', value: 65, count: 4 }
{ name: 'Truffles', value: 90, count: 7 }
{ name: 'Gingerbread', value: 40, count: 5 }
How would i then go in and save each of those items like that.
for example, get a list of mined stuff with their counts, get the user's current list, update all the counts, then save the updated list at the end
Cause I would have to create the Cookie, Peppermint, Truffles and Gingerbread items for the user
Serial it
what db are you using?
postgres + typeorm
export class Items extends BaseEntity {
@PrimaryColumn()
id!: string;
@Column({ name: 'name', type: 'text' })
name!: string;
@Column({ name: 'type', type: 'text' })
type!: string;
@Column({ name: 'amount', type: 'bigint', default: 1 })
amount!: number;
@Column({ name: 'value', type: 'bigint' })
value!: number;
@ManyToOne(() => User, user => user.items)
user!: User
@Column({ name: 'description', type: 'varchar', length: 150, nullable: true })
description?: string;
}
If it is important here is how my table is setup for items
That's very jpa
jpa?
idk how typeorm works
but assuming each Item is stored in its own column
then yes, each item would need to be saved separately
unless typeorm offers some kind of batch function
It generated the sql operation dynamically
You can bind foreign tables directly to lists and alikes
Basically whatever structure he set in the class
It'll try to replicate the class into the database
mmm I think I am doing smth wrong
In this case, he'll have
id STRING NOT NULL PRIMARY KEY
name TEXT
type TEXT
amount BIGINT DEFAULT 1
value BIGINT
description VARCHAR(150)
baseentity_id STRING NOT NULL
.
. Whatever fields user has
.
welp i g2g sleep, good luck
Also I forgor how a foreing key is declared
I dont even remember in raw sql lol
My first issue is adding in the count
I am doing it wrong but I don't know what part of it is wrong
Just update the item count directly
hey i have one query
when we use oauth to login with discord, most of the time we get a promt to click on authorize.
but i have seen somewhere that after clicking on login with discord, it just redirects to oauth link and redirects back to the site without any prompts. and i have been logged in
how to make that?
UPDATE items
SET amount = amount + :amount
WHERE name = :name
What does 1PG or 2PG mean?
Guys i m using topggpy and on my bot's beta instance get_user_vote() isn't working. no error or nothing, the function just isn't doing anything. Anyone can hepl?
anyone?
in what context??? Where are you seeing 1PG and 2PG
1PG-Bot and 2PG-bot and something like that.
Parental Guidance
Poetic God
Hi?
is there a way i could use a inside a
mf
how tf do i do this
`
inside a
`
in javascript
\`
thanks
how do I log the vote received for the server using webhooks?
Using either a bot or https://webhook-topgg.com
Or you can code your own solution
@big.bun#6969
explain how this works.
someone
Pretty sure it’s something to do with cookies and the fact that the user has authorized oauth before
Otherwise I don’t think you can “make” oauth automatically accept
Hey guys!! so i am trying to make a dashboard for my discord bot in NextJS. I am using next auth for the authorization but i am having trouble getting all the informations like: guilds member has joined in, etc. Can anyone help me with it?
this is my pages/api/auth/[...nextauth].js:
import NextAuth from "next-auth";
import DiscordProvider from "next-auth/providers/discord";
export default NextAuth({
providers: [
DiscordProvider({
clientId: process.env.DISCORD_CLIENT_ID,
clientSecret: process.env.DISCORD_CLIENT_SECRET,
authorization: {
params: {
scope: "identify guilds email",
},
},
}),
],
secret: process.env.JWT_SECRET,
pages: {
signIn: "/login",
},
});
What
huh
-upto ig
huh
Thanks! it worked but how do I reward the voted ppl with a role?
You could do that with a Vote Tracker bot
The webhook just sends a post request to a discord webhook and sends to a channel
yes
the bot would use the webhook instead, so it knows what server was voted for and which user voted, and from there, giving the applicable user a role
...
the reason that site got recommended is because it does what you asked for originally.
Its only purpose is to send a message, for those who want that.
ok
Thanks guys
@spark flint hey dude btw can i use a bot to do this
the auto role stuff
On join?
That would work
wow
doesn't @pliant gorge have a way to assign roles to users on vote
idk if it works
oh
: )
i see
cool
as with everything on the site it's probably broken
so i made a bot that pings mc servers to see if they are online or not, and if its on it renames a channel and the same if its off however im using an array and the last of the values is always one off for example i have to put an extra value in it to that they synk up does anyone know why this happens?
is anybody having issues with their bots not loading imgur pics? happens from multiple machines
i had to add another value "e" to make all of the values synk up
anyone can help me please 🙏
what does console.log(list[2][0]) do
it logs "e"
however when it is used here so rename the channels it always skips "e"
Are you incrementing i before renaming the channel?
Can you show that snippet of code
can you show the entire list variable without e
setInterval(() => {
let server = list[0][i];
if(!server) {
i = 0;
server = list[0];
}
let channel = bot.channels.cache.get(list[1][i]);
if(!channel)return console.log("bruh")
util.status(list[0][i], { port: 25565 }).then(data => {
if (channel.name === `${list[2][i]}-🟢`) {
return
}
else {
channel.edit({ name: `${list[2][i]}-🟢` })
}
}).catch((error) => {
if (channel.name === `${list[2][i+1]}-🔴`) {
}
else {
channel.edit({ name: `${list[2][i+1]}-🔴` })
}
})
i++
}, 10000);
thats the entire thing
Channels aren’t guaranteed to be cached
i have i+1 in the botom half cuz when a server goes ofline it renames it the wrong name
Your channel probably isn’t cached
skill issue
Fetch it instead
No, it wouldn’t give an error because you have the if(!channel) return right after
but then it should log "bruh"
Try logging the channel
I’m on mobile so it formatted weird, wasn’t sure if the console log was on the same line or not
Why is my context menu not detected? (I sent the commands including this one to discord, but I don't have the context menu available, I don't see it)
also i think i added the fetch thing wrong cuz now its saying channel.edit isnt a function do i have to add bot.channels.fetch and then bot.channels.cache.get? or am i being dumb
You have to await fetching it
It’s a promise
now it just says
SyntaxError: await is only valid in async functions and the top level bodies of modules
Because your setInterval isn’t async
hi, because my bot page don't shows the bot logo?
Make the function inside your setInterval async
wait you can async a set interval?
Yes
The function yes
fair enounge
The interval itself I dont think so
The function it takes as a parameter
wait what do you mean
Put an async before these 2 parentheses
It’s an arrow function, you just need to make it async
ah fair enough
setInterval takes a function as a parameter, and then a number of ms between loops
mm it works now but still names the channels starting with the second value and not "e"
Like, what are you using to fetch the channel
You have to fetch channels by their id
You can’t fetch them by name
yeah thats what im doing
let channel = await bot.channels.fetch(list[1][i]);
and that row in the array is the ids
Try logging channel, see what it logs
it logs the right one
Uh
Are you sure you’re using the right ID then?
Is that the channel that it’s skipping over?
yup correct id, literally everything works fine exept without the "e" it gets named to the next value over with is 9b9t instead of 7b7t
and im compleatly baffeld by it
does your bot have permissions to edit that channel ¯_(ツ)_/¯
yeah it edits the channel just to the wrong name
Oh wait
Perhaps you need to await editing the channel
It might be going through the rest of your code
possibly
Before finishing the edit
cuz when the server is offline it renames the channel to what it should be
mmm i cant async it cuz it just gives me that error again
?
SyntaxError: await is only valid in async functions and the top level bodies of modules
if someone can help me for my pb pls ?
let channel = await bot.channels.fetch(list[1][i]);
if(!channel)return console.log("bruh")
util.status(list[0][i], { port: 25565 }).then(data => {
if (channel.name === `${list[2][i]}-🟢`) {
return
}
else {
await channel.edit({ name: `${list[2][i]}-🟢` })
}
}).catch((error) => {
if (channel.name === `${list[2][i+1]}-🔴`) {
return
}
else {
channel.edit({ name: `${list[2][i+1]}-🔴` })
}
})
``` this is it and this is all inside the set interval thing that i just changed to async
mmmm
Although I’m not entirely sure why you’re using .then there
Since data is unused
async/await is much cleaner
So that you don’t have 30 nested async functions
data is used since i console log the player count i just removed that so i didnt upload a huge paragraph
More recent additions to the JavaScript language are async functions and the await keyword, added in ECMAScript 2017. These features basically act as syntactic sugar on top of promises, making asynchronous code easier to write and to read afterwards. They make async code look more like old-school synchronous code, so they're well worth learning....
cuz this is what data is used for
i unstalled unity ide and opened my script with it but vs still doesnt help me to codes
yeha i ddi
If you want to have access to data you can just do let data = await howeverYouGotDataBefore()
yeah but then thats just extra code though
...no?
Nested .then statements get really messy
For example if you wanted to await something inside your .then you’d have to change your .then function parameter to be async
Or you’d have to nest .then
i guess
But it’s up to you
Backing up to the original problem though; did you await the channel edits?
yeah it didnt change anything
but then lemme test somthing
cuz it only renames the channel if its not the same as the mc server name and the status
nope it just renamed the channel to 7b instead of just "e" since thats the first value
¯_(ツ)_/¯
I’d help more but it’s difficult on mobile
And I’ve got an exam in about an hour I need to study for
I wish you luck though
fair enough
i mean this is just a crapy project if slaped together with minimal knowledge of nodejs so idk
also why are you helping me go do your studying
i aprisiate the help but grades are more important than my random crap
also doog luck with your exams though
doog luck!
oh dog he misspelled
discordjs builders supported context menu ?
i have search to the discordjs/builders and i see context menu type etc...
ye but doesn"t work
i don't see the App menu
i fixed it (yay)
so what it was is the fact that the feching the channel happens (almost) instantly so it gets the right channel however pinging the server takes a while but since the input was instant it gets the right ip to ping, however because its delayed "i" never actually = 0 cuz when i logged it it only starts with 1 after its pinged the server but before it starts with 0 so that means that the last bit of code is always out of sync with the rest of it meaning that i had to put the "e" there
anyway cheers for the help
Collection(2) [Map] {
'921094146633109515' => <ref *1> Message {
channelId: '920705538881372214',
guildId: '920705538881372211',
deleted: false,
id: '921094146633109515',
createdTimestamp: 1639676357659,
type: 'CONTEXT_MENU_COMMAND',
system: false,
content: '❓ Vous avez **1 minute** pour indiquer la raison du bannissement de ce membre.',
author: ClientUser {
id: '920705378977730600',
bot: true,
system: false,
flags: [UserFlags],
username: 'M・Moon',
discriminator: '5935',
avatar: 'af4f502e1ebf71825495ebde68052db7',
banner: undefined,
accentColor: undefined,
verified: true,
mfaEnabled: false
},
pinned: false,
tts: false,
nonce: '921094141700472832',
embeds: [],
components: [],
attachments: Collection(0) [Map] {},
stickers: Collection(0) [Map] {},
editedTimestamp: null,
reactions: ReactionManager { message: [Circular *1] },
mentions: MessageMentions {
everyone: false,
users: Collection(0) [Map] {},
roles: Collection(0) [Map] {},
_members: null,
_channels: null,
crosspostedChannels: Collection(0) [Map] {},
repliedUser: null
},
webhookId: '920705378977730600',
groupActivityApplication: null,
applicationId: '920705378977730600',
activity: null,
flags: MessageFlags { bitfield: 0 },
reference: null,
interaction: {
id: '921094144812785755',
type: 'APPLICATION_COMMAND',
commandName: 'Bannir',
user: [User]
}
},
'921094153503395851' => <ref *2> Message {
channelId: '920705538881372214',
guildId: '920705538881372211',
deleted: false,
id: '921094153503395851',
createdTimestamp: 1639676359297,
type: 'DEFAULT',
system: false,
content: 'qdezefqze',
author: User {
id: '605371484046884865',
bot: false,
system: false,
flags: [UserFlags],
username: 'VinxVinx',
discriminator: '0001',
applicationId: null,
activity: null,
flags: MessageFlags { bitfield: 0 },
reference: null,
interaction: null
}
}```
how can i get only content: 'qdezefqze', please ?
in '921094153503395851' => <ref *2> Message {
bruh what did you log
<collection>[key].content
Or just by a loop, filter, map etc.
Whatever you prefer
A message
The collection is “just” a map
expects critics
running into a issue. im trying to check for a webhook in a channel and if it can't find it then it makes the webhook however the "if not found then make" part for whatever reason isn't working and sending is being weird.
it logs "undefined" as the name as well
let isweb = message.channel.fetchWebhooks().then(hook => hook.find(webj => webj.name === cusbot.botname))
if(!isweb) {
await message.channel.createWebhook(cusbot.botname, {
avatar: cusbot.botavatar,
reason: "Required for Goot's custom bot feature"
})
}
let webhook = message.channel.fetchWebhooks().then(hook => hook.find(webj => webj.name === cusbot.botname))
console.log(webhook.name)
the fetch is only called twice because doing "isweb.send" wouldn't work but "webhook.send" doesn't work either 💀
let isweb = message.channel.fetchWebhooks().then(hook => hook.find(webj => webj.name === cusbot.botname))
this might be wrong, but im double checking
tim said to try this but ye it may be wrong
the .then is needed but yeah should have used await kekw
nope
then is never needed anymore
it just makes your code nested
and harder to read
async/await is much much much cleaner
without the .then it wouldnt fetch the webhook by its name
let isweb = message.channel.fetchWebhooks().then(hook => hook.find(webj => webj.name === cusbot.botname));
// change to this
const hooks = await message.channel.fetchWebhooks()
const hook = hooks.find(webj => webj.name === cusbot.botname)
Hmm
Could work
const hooks = await message.channel.fetchWebhooks()
const hook = hooks.find(webj => webj.name === cusbot.botname)
if (!hook) {
await message.channel.createWebhook(cusbot.botname, {
avatar: cusbot.botavatar,
reason: "Required for Goot's custom bot feature"
})
}
hook.send("hi")
should work fine?
Why line 11 my bot send me an error Cannot read proprety length of undefined but the table is exists, and the query line 7 it's worked...
so my bot have acces for all tables
madness is happening there
what ?
without seeing the left side of the code it looks crazy
but i see it now
i was just confused by it beign cutoff
line 10 changes what result is
ok
if you need the result from line 6 and line 11 then you need to give them different names
i will try
D:\Commandes\mmoon\src\events\messageCreate.js:11
if(!result1[0].length) {
^
TypeError: Cannot read property 'length' of undefined
same err @proven lantern
but the table exists 
i dont see any results in there
yes my bot will check
if(!result[0].length) is for that
verify if record exist
so it's not getting anything
Looks like he doesn't access the table
idk what contract is, but maybe it returns undefined when there are no records
Yet all the other tables that I have, he gets there but this one he does not want ...
dont you need to put a record in there first
I have always done this method to check if there is a value in the table with the conditions I gave in the SQL request, it never caused any problems
I just tried to make a request in the table to enter some information and it succeeds, but to retrieve the whole, no @proven lantern
(with my bot)
can you try moving that query into a unit test and playing around with it until it works?
I found the problem, I replaced the ? in the request by the user ID and it works!
thx for your help bro 😉
message.guild.member(user).ban('Reached 20 points. | Autoban');
Discord API Error: Invalid form body
Anyone know why?
.ban doesn't take a string.
It takes an object: https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=ban
Ah, haven't used this in a while I guess it changed.
Last time I worked on a project was v11
If you end up migrating to v13, note that .member(...) has been removed.
what idle do yall js programmers code in, im switching over as i realized discord.py was discontinued 😔
vsc is common
check out nextcord
A maintained fork of Danny's discord.py. Contribute to nextcord/nextcord development by creating an account on GitHub.
pycord is good and supports webhooks
unlike nextcord
is it any gud
yea, but interchangeably
does next cord work the same way as discord py
it's a fork so I would assume so
same with pycord
yea
idk if it has built-in tho
could always check out discord-interactions for that tho
@spark flint u left yesterday 
left what
Nope
oh
o.o
is the url localhost:3000
no
So I got a question, could I just use a loop to loop through the given list of stuff they mined and then use Object.assign to append the count prop?
or is there a better way to do this
I have a code organization question. All my bot commands are in there own separate lambda applications. There is some common code that should be shared between the lambdas that is currently duplicated across the different projects. I'm planning to refactor those common functions into either one layer or many small layers. Layers are basically a way to create modules for lambda applications. My question is should i make a layer for each function or should i create one layer and put all the common functions in there?
your node.js version is outdated
are those layers shipped to each lambda as well?
or are they accessed over the web?
i think layers are exactly like lambdas, but they can be bound to the lambda and then imported via require('opt/LAYER_NAME')
i just downloaded it tho
well if they are invoked over the web, then that will introduce a latency in all your commands
do you need to use await when you call them?
some of the functions will need to be awaited, but if i include a layer i need to "await" the layer being imported and spun up
how did you download it? youre using version 14, the latest version is 17
so the layer is async imported, then stays in memory?
i'm not 100% sure what is happening under the hood
probably a good thing to know to make the decision
if it stays in memory then thats good, if every single function call makes a request, then thats bad
its easy to test
write some sync code, put it in the layer, then try using it
and measure the time it takes to execute
i think layers do the same cold start thing, but stay warm for 5 minutes after
if i put all the common code into one layer then the cold start will be longer, but there will be less cold starts
still, measuring is the only way to make sure
i feel like the default way to think with lambdas is to split everything up into as many small pieces as possible
but i'll play with it
and i'm reading through some more docs now
When you invoke your function using one of the sam local commands, the layers package of your function is downloaded and cached on your local host.```
oh nm
that's sam local
Include layers in your serverless application, and learn how layers are downloaded and cached on your local host when running and debugging your serverless application locally.
from the node js site
17? i downloaded like 16.4 something
have you tried deleting node_modules and doing another npm install?
yes
same error
are you doing npm install and npm start from the same terminal?
@absrage
o thx
is it breaking tos if for example
u have a command that takes an input and simply outputs it
you can use 16 no problem, discord.js is compatible with 16
but your error was showing you had 14
did you manage to install 16 or 17?
o i havent gotten around to it rn but
ill do dat in a sec
like if someone uses my command like ~say <something against tos> and then the bot repeats is that allowed
i believe you could get in trouble for that if people report you
its a tricky thing, its not illegal but potentially dangerous
i see
usually you can get away with it if you write a tos for your own bot and have it clearly state that the output of the say command is not your responsibility
- Write a tos
- Make it clear, who, what and when that command is executed and make sure you keep those logs
- Let the user know you log them and bingo
You have pretty much everything discord needs
each lambda is limited to 5 layers so i can't make the layers too small
but layers can include other layers so i could still make them small and then have parent layers that includes all the sub layers needed
I am having css issues.
So I am trying to get this into the middle of the screen right.
I already have it centered and everything
.container {
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
.welcome {
position: absolute;
top: 50%;
}
and here is my css
import './home.css'
function Home() {
return (
<>
<div className="container">
<div className="welcome">
<h1>Hello my name is Aaron Dye</h1>
</div>
</div>
</>
)
}
export default Home
and react/html
Unless I am remembering wrong this should work no?
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}```
is home nested in another component?
np, if home is nested inside another component that is already 100vh then you should move the justify-content: center; to the parent component
how to check a channel permissions?
like i want to check if in a channel the SEND_MESSAGES is true or false or null
does embeds setImage support webp?
how can i add fallbacks? if webp doesnt load
is it possible?
Convert to png
i saw the beta version of the fast alt switching thing; anyone know when it will come out fully?
Anyone know of an npmjs module that allows you to save a timer if a bot goes off?
@mention for answer please, thx 🙂
Is this to many?
You don't need a module for that, a database is just fine
Also you do know that the value for n.7 is empty right
Because it's a POST request
You're supposed to provide a data to send a new message
Ah wait
Yeah
You're using fetch
It should be body and you have to stringify the object
how about no
@zinc fable
When there are no mods online 
Actually big brain moment
@rustic nova
@earnest phoenix let's not advertise
…

-b @earnest phoenix
holden for life#2268 was successfully ban
Ty
what

I think you should delete this @rustic nova
Yup yup
I get called that so much
is there a way to fully hide slash commands or can i just deny permission to run it?
no way yet to hide them
i'm successfully disabling dev commands but they still show up
yeah that's what i thought 
if it's a guild command just don't register it
yeah
that's whack though
wish there was a way to fully hide them if users can't access them 
because of that im making devcommands as guildcommands, so that at least all the other guilds dont have them
What's the chakra equivalent of element:hover::before?
tried _hover_before but that did not work
":hover::before" is the answer
yeah i know
i'm aware of guild and global commands
i was looking to hide commands globally for everyone but devs for example
which hopefully will become a feature
Yeah hopefully
i appreciate you for responding though! 
I need to start looking into using slash commands, they confusing me 
they look intimidating, but they are super helpful
feel free to reach out with any questions
Oh that’s why
yeah me too lol
same lol
i know but idk how to set link
markdown
Like slower than the playback of the video?
Iirc youtube caps download speeds for videos to their playback(touch above for buffering) speed.
As there's not a lot of reason for more for a video streaming service
no idea then


Why are you concatenating a string to a class?
it worked now that i moved the channel metion to own message
You’re sending an embed object to them. You need to specify that it’s an embed
Yeah
Also u can chain builder configs instead of repeating the variable each time
Or simply write the embed object yourself which results in less code…
Judging by the length of his variable namrs tho...
let thisavariablethatssupposedtobeusedformath = 5

who can help me for #topgg-api ?
most times I use an interaction in my bot it returns an error, any idea why? (the interaction works)
Hello. Can someone help make me feature?
I have this user and his flags is 393472:







