#development
1 messages · Page 2044 of 1
that's just a little bit outdated
in 13.1.0 this is the docs
but if it works for you, then use type:
k
i think the problem in ephemeral
all commands stoped worked but when i removed ephemeral it working right
this is the code
so yes, componentType is correct and type is incorrect
this is is how the type is checked ```js
if (this.componentType && interaction.componentType !== this.componentType) return null;
so if you dont use a correct componentType it will default to any type / all types
is there a way in html to escape user-inputted html without replacing any characters - in other words preventing the browser from rendering it as html and only as text
cant use javascript
not without replacing < > with their html entities afaik
u usually want to replace a few more
it used to be possible in html2 using <xmp> and <plaintext> tags
but those were removed in html5
& (ampersand) &
" (double quote) "
' (single quote) ' (for HTML401) or '
< (less than) <
> (greater than) >
course they did
what if i dont 😱
if not the browser will render it instead of showing it as code?!
quotes?

make sure to refuse the (re)delivery attempt only if a valid reason is givin
such as recipients postbox is full
or your ip is blacklisted
there are only a few reasons mail servers stop the resending
yeah
i dont know if emails actually have dedicated error codes like http
through smtp interfaces only option for errors i've been given is just a string
so if the inbox is full
skill issue get good get a good job get a family start a business get rich get rich man email get lots of bytes
seems accurate
{
"statusCode": 404,
"message": "Cannot GET /v1/images/dogs?",
"error": "Not Found"
}
So for some reason when I am making a form request to my api it adds a ? to the end causing this to occur
import {useState} from "react";
import {NativeSelect} from "@mantine/core";
function Index() {
const [location, setLocation] = useState('manga')
console.log(location)
return (
<>
<NativeSelect
value={location}
onChange={(event) => setLocation(event.currentTarget.value)}
data={['manga', 'dogs']}
/>
<form action={`http://localhost:3001/v1/images/${location}`}>
<input type={'file'} multiple accept={'image/gif, image/jpeg, image/png'} />
<input type={'submit'} />
</form>
</>
)
}
export default Index;
Random idea nothing to do with fixing the error sorry... But couldnt someone set the location as "../../../../" and make it return more important files?
nvm im stupid i think
usually webservers are scoped to only serve files within a specific folder so path traversal attacks don't work directly like that
but there are cases where that can be a vulnerability
yeah i just noticed aswell that the location is the action value and isnt from the input
also ? shouldn't be the thing causing an error there
mhmm
If it doesn't exist at the path I am telling it to put it, then it returns 404 Sorry I misread that, on my server I make sure that the location is one of the ones from the select menu
so i got 2 servers
so it doesn't matter
Pterodactyl
why
OS first
well i use Ubuntu 20.04 and then install Pterodactyl
I'd go with the standard os of every linux vps out there
unless you wanna use a windows server
hell no wtf
Ubuntu?
lighter one?
Ubuntu has the most support and i dont know if any host give the option for a lighter one
CentOS is a good option as well from what I remember
I haven't fucked with linux that much tho so not sure if I can't really comment
personally never tried it
Are you looking to make profit from this or is this just free services?
profit
Pterodactyl is a free open src webpanel that lets u install eggs that are used to host applications
working with one of my customers
I see
https://pterodactyl.io/ <- its fast to install, secure and really easy to scale if u want more nodes
Pterodactyl is an open-source game server management panel built with PHP 7, React, and Go. Designed with security in mind, Pterodactyl runs all game servers in isolated Docker containers while exposing a beautiful and intuitive UI to end users.
i plan on making easy to use templates for setting up discord bots
gta mod servers
and ofc web hosting
ello papi
you can probably find an egg for these apps somewhere or make your own
:p
discord bots are usually anything but scalable
are those all written on php
wym
most of the Discord libs out there are memory hogs. Good luck getting around that
How should I avoid this with my lib
👀
I am starting to wanna lean more towards performant then user friendly
recommend doing both
They are json. Here is one for discord JS https://github.com/ign-gg/Pterodactyl-Eggs/blob/master/bots/discord/discord.js/egg-discord-js-generic.json
You can't have best of both worlds imo
Trying to be user friendly can easily end up being less performant
and I don't wanna become another djs
oh really
that's pog
yup
its easy to setup a hosting service these days the only annoy bit is picking the right hosting and fighting ddos attacks
Do you have servers at home or are you using some companies cloud services?
i got my own servers
O sick
currently in US
electricity bill go brr
we'll be working that out
normally people dont own their own servers and host it off hosting providers like OVH
yeah not my thing
yeah its just cheaper but less secure 🙂
not necessarily
bet u can't scale with them as u would with your own
You'd be surprised with the amount of people who run hosting services actually run their own servers
by not making class based interfaces and offer no caching. The user will take care of it
if you aren't a complete idiot, you cannot go wrong with hosting bots on your on hardware
🤔
I was already thinking of not caching but wdym by class based interfaces
yes i would. the smaller hosting companies use other people's servers. However the bigger hosting companies use their own
Shit like the Message interface from Discord.js
oh I have classes that I convert the raw data into so the methods stick with it but other than that
nobody needs a class to represent a message if the properties are similarly named. The only things you should offer are the helpful utility functions as utils
the first step to having a performant lib is not using node in the first place
node objects are going to be heavy no matter what you do
Mmm true
I don't know anything other than node
😔
worth exploring other languages!
I remade lavalink (java) in node and the performance gains are huge
trying to go into a language with the goal of making a discord lib out of it seems scary
👀
c#, rust and kotlin are my top 3 as of 2022
java's overhead is nasty
this
You can take your Java knowledge into C# for the most part
not a fan of using JVM in the first place, but it gets the job done
TypeScript as well to some degree
I was learned C# a while back but never stuck with it
I've been working on a Unity game, so C# has been fun
My biggest issue with learning a language is what to do with it to learn shit
Like learning the basic types of a language is usually easy as majority of the langs I have used have a similar type structure
wait till you explore the entirety of .net, not just unity, such a beautiful ecosystem
.net 7 brings us native AOT compilation
look for projects other people have made and try make your own version of it in the language u wanna learn
Nah, majority of those projects are made by pros
ahead of time, eliminates the need to have an interpreter in the middle to translate to machine code
find a simple one
how bout no?
so like JIT but at compile time?
yup!
The main advantage of Native AOT is in startup time, memory usage, accessing to restricted platforms (no JIT allowed), and smaller size on disk. Applications start running the moment the operating system pages in them into memory. The data structures are optimized for running AOT generated code, not for compiling new code at runtime. This is similar to how languages like Go, Swift, and Rust compile.
Sounds insanely complicated
the technology behind it is, it's insane
but actually producing AOT binaries is super easy
just an extra argument in the .net CLI
any code/patterns that might need changing?
{
"statusCode": 404,
"message": "Cannot GET /v1/images/dogs?",
"error": "Not Found"
}
Still can't figure this shit out
react be doing smth weird with the form submitting
indeed i heard GO and Rust are great at not being super heavy
I used go a while back
form data is on post
it is ight
nope, that's the best part of it, the compiler automatically optimizes your code for AOT
GET can have a body, but it's non standard
why are you even using libs for something as simple as forms
OH RIGHT
I am blind
didn't realize I was doing a get request this entire time
😔
its ok
Well now it isn't even uploading the file to minio like it was before
got it working
:D
dev update: speedb is going to be refactored because quite frankly im embarrassed to put it on github let alone submit it for my school assignment
might also switch over to a faster json parsing library called rapidjson
any idea why this doesn't send?
thanks for cutting off useful information in your screenshot such as what channel actually is 😉
it was nothing, actually, I forgot to change channel to welcomeMessageChannel
also is that text good enough?
I don't really know what to type there
well, you cut off the screenshot
and id kick the bot if it introduced itself like that
^
you should just be concise and straight to the point
Yo! Thanks for adding the bot.\n\nBefore using it though, there is a few *optional* steps you have to do in order to fully set the bot up in your server.\nFirstly, run the -set command in order to set up admin, mod and muted roles. Also set up the, this time really optional logging and welcome channels.\nSecondly, if you need to you can also set up a fully customized prefix for your server, and incase you're lost, the default one will always be `-`, and if you ever forget it, just mention the bot and it will respond with the current configuration.\n\nWith that out of the way, I hope you enjoy the bot. CYA!
so what should I change then
also, one thing i wanted to note is that if you didn't get an error for the issue you were having, it's hinting that you aren't handling errors properly
I am, I have a logging system, the entire code I showed was in a try catch statement though
more importantly, what do you mean my concise and straight to the point?
I'm trying to explain in detail how to make the bot work properly
well, you shouldn't write a bot's introductiry message like it's a person to person conversation, meaning no adverbs like also etc.
write it professionally
what i, as an end user, would want is a simple thanks, tell me the prefix and where to get started with the bot
that's all
not a wall of text
so something like
Yo! Thanks for adding the bot\n\nTo get started run the -set command and set up the important stuff\nThat's all, bye.
better?
better but not professional
something along the lines of
thanks for inviting me
my prefix is x
you can view my commands with y
if your bot needs to be set up first, add an extra line telling me how to do it
only tell the user information they need to know
visible at a glance
i don't want to scan a paragraph to find out how to use something as simple as a bot
put yourself in the shoes of an end user and think like one, you'll instantly write a better experience for your users
great
id remove the And in to get started personally
gotcha
but it's very good as it is
aight that's great then
thanks for help
this isn't working...
.send is supposedly undefined?
maybe the channel could not be found
welcomeMessageChannel is undefiend then
you commented out the very condition that should stop that
also you should just do if (welcomeMessageChannel) instead of channel !== undefined
it may return null instead of undefined
that handles both cases
well I still need to find the channel? I'm inviting with admin perms and there is plenty of text channels so there clearly is something wrong
i think your channel type statement is wrong
in your case it would be GUILD_TEXT instead of text
I assume it's been changed?
well they change things every little release so probably
thats why i dont use djs anymore
I see, that's kind of confusing
I would use the c# lib since I'm better at it but it would take too long to learn another API
what do you use?
well uh nothing i dont exactly develop bots anymore
theres not really a good alternative
strife /s
it's not even lib devs to blame
it's discord themselves
the api is very inconsistent
a lot of people say the constant changes are not a "big deal" and it makes developers "work on their bots" but obviously they havent touched a large bot ever and realized how stressful and difficult it is to stay up to speed alongside over things such as bugs and features
the discord api is a programmer's representation of borderline personality disorder
and its not like you can stay on one version forever eventually the api version will be dropped by discord
this
and it doesnt take very long either
i think versions stay alive for like a year or 2 max
uhmmm /slash commands
discord is gonna remove text commands supposedly
if they get removed I stop making bots
well thats their mission
the final nail in the coffin to stop working with the api altogether (userbots included) were interactions and discord implementing changes that bot developers clearly don't approve of
at least for me
you can keep using text commands - that is if one of your bot features qualify for the message intent
I agree, discord even took a poll and then completely ignored the results
it's such an oxymoron
discord killing the major thing that's keeping their platform alive
lol
I'm not ever planning to use slash commands so they have to right
i dont get the whole "privacy" point of this, discord aint supposed to be a private platform and a self bot can easily scrape thousands of users and messages without an ich - and server owners should also be responsible for what channels the bots are allowed to view
never was privacy
yeah I don't get the point of this
na they do use that term a lot
too much
also you know guys it will only take discord one database data breach and its over
I'm hoping they finally start listening to what people have to say or seriously I think everyone will stop making bots at some point
nothing is encrypted or end to end
and tencent is already dipping their fingers into discord

their goal is to make their platform friendlier to people who aren't tech savvy at the cost of the sanity of api consumers, privacy is just a term they use as a coy to not receive as much backlash
it's just smart marketing
only a matter of time until the chinese have their hands on every single message and activity data of every user
probably already the case
this
love talking about it since it's a gray area, you don't know whether if it's true or not and it's impossible to find out without a leak
im excited for a discord data leak
all corporations value your data a lot, pander to you that they're keeping it safe and not selling it to anyone
if someone dont do it i'll do it myself 💀
but people who've seen how these corporations work know this is not true
i havent for myself, just speculating based on how much legal trouble FAANG went through
all it might take is a single motivation 4chan post
i dont know why but it doesn't bother me that my data is stored and sold, it bothers me that corporations lie about it
I've just accepted it at this point
I just care to not make sure my very personal info is in that mix
humanity is really gonna kill itself before any natural disaster does
this tbh
even if you try to dig into this topic on the surface web you'll barely find anything
google and microsoft censor this
should just accept it too
After reading that I feel I put a disclaimer in my site, telling anybody I take all their data I can get and sell it to anybody I want
No more secrets 
Hello so i need help with checking if a user is actually user ?
i tried using typeof User === user but is not working how i thought it would work
You are type checking with a class. You gotta use instanceof and not typeof
ObjectName instanceof ClassName // returns boolean
oh that makes more sense thank u sir
give me some money from my data
Isnt this been there for over 3 months now?
cuz i remember seeing it like this for that long
What was the last css change discord did that didn't look bad?
exdee
How can I send these webhooks to a discord webhook https://docs.top.gg/resources/webhooks/ ?
So I have googled what vite is and I know it is some kind of web dev tool but still not entirely sure what it is
either write a webserver to convert top.gg request data into discord webhook request or use some third party service (like vote notif bots)
I have a slight dilemma. Essentially, I have a "storage" server which is https://my_site.com/content/some_url_here.png. I can then use my Express server to fetch images and whatnot via links like that. I also have an external script that requires an image URL (ex. https://example.com/info.png) which I then pass in my website to do something. Essentially:
let data = await imgReverser("https://my_site.com/content/info.png"); // External script that reverses an image.
console.log(data);
However, since I use CloudFlare, fetching that image is blocked for some reason. I can't send requests to https://my_site.com/content/info.png, therefore if I execute that external script, nothing happens. Is there a way to bypass CloudFlare to access images from my web server?
you have to configure your cloudflare to not block it
vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import WindiCSS from 'vite-plugin-windicss'
import Pages from 'vite-plugin-pages'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
WindiCSS(),
Pages({
dirs: 'src/pages',
exclude: ['**/components/*.tsx']
})
]
})
main.tsx
import React, { Suspense } from 'react'
import ReactDOM from 'react-dom/client'
import './index.css'
import {BrowserRouter, Route, Routes, useRoutes} from "react-router-dom";
import Home from "./pages/Home";
import {MantineProvider} from "@mantine/core";
import 'virtual:windi.css'
import Navbar from "./components/navbar";
import routes from '~react-pages';
const App = () => {
return (
<Suspense fallback={<p>Loading...</p>}>
{useRoutes(routes)}
</Suspense>
)
}
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<MantineProvider
theme={{
colorScheme: 'dark'
}}
withGlobalStyles
>
<Navbar />
<BrowserRouter>
<App />
</BrowserRouter>
</MantineProvider>
</React.StrictMode>
)
navbar.tsx
import {Link} from "react-router-dom";
export default function Navbar() {
return (
<>
<header>
<nav className={'flex flex-col'}>
<h1>Everything API</h1>
<ul>
<li><Link to={'#'}>About</Link></li>
</ul>
</nav>
</header>
</>
)
}
So I was giving vite a shot and it seems like I am fucking up horribly. I am trying to introduce routing and I tried the vite-plugin-pages vite plugin to help mitigate the entry of using react-router-dom (as using it on its own seems ot just fuck up) but I am still experiencing issues.
LMAO
I have a problem with my bot. There people to help me!!!
Maybe
My help command doesn’t work
My language bot is JavaScript
My code is
Can they help me?
In your startup, you define the bot/client. In those options, you need to give a array of client intents
Numeric WebSocket intents. All available properties:
GUILDS
GUILD_MEMBERS
GUILD_BANS
GUILD_EMOJIS_AND_STICKERS
GUILD_INTEGRATIONS
GUILD_WEBHOOKS
GUILD_INVITES
GUILD_VOICE_STATES
GUILD_PRESENCES
GUILD_MESSAGES
GUILD_MESSAGE_REACTIONS
GUILD_MESSAGE_TYPING
DIRECT_MESSAGES
DIRECT_MESSAGE_REACTIONS
DIRECT_MESSAGE_TYPING
GUILD_SCHEDULED_EVENTS
https://discord.js.org/#/docs/discord.js/stable/typedef/ClientOptions
What does this error mean? ```node:_http_outgoing:651
throw new ERR_HTTP_HEADERS_SENT('remove');
^
Error [ERR_HTTP_HEADERS_SENT]: Cannot remove headers after they are sent to the client
at new NodeError (node:internal/errors:371:5)
at ServerResponse.removeHeader (node:_http_outgoing:651:11)
at write (C:\Users\Luckie\node_modules\finalhandler\index.js:282:9)
at AsyncResource.runInAsyncScope (node:async_hooks:199:9)
at listener (C:\Users\Luckie\node_modules\on-finished\index.js:170:15)
at onFinish (C:\Users\Luckie\node_modules\on-finished\index.js:101:5)
at callback (C:\Users\Luckie\node_modules\ee-first\index.js:55:10)
at IncomingMessage.onevent (C:\Users\Luckie\node_modules\ee-first\index.js:93:5)
at IncomingMessage.emit (node:events:406:35)
at endReadableNT (node:internal/streams/readable:1343:12) {
code: 'ERR_HTTP_HEADERS_SENT'
}And how could I possibly fix it? I assume it's this part of code. js
app.get("/verify", (req, res, next) => {
console.log("verify")
if(req.session.backURL){
req.session.backURL = req.session.backURL
} else if(req.headers.referer){
const parsed = url.parse(req.headers.referer);
if(parsed.hostname == app.locals.domain) {
req.session.backURL = parsed.path
}
} else {
req.session.backURL = "/"
}
next();
res.redirect("/callback");
})```
i think you are a bit confused on middleware
calling next basically means you are happy with the request and ready to move it onto another one
in this case you should remove the next
because you dont need it to process anything beyond this point
alright thanks
is there some kind of guide to understand the passport npm module and how to use it or some examples, i just dont understand it
There are some example code snippet in the readme, or more full examples linked here https://github.com/jaredhanson/passport#examples
thank you
hello, how to change bot developer?, actually i'm de DrackRPG bot developer but the before developer deleted his account and he has access from bot in topp.gg.
ty for your feedback and help
You will need to prove ownership of the bot, then have ownership transferred
Ok ty, how am i prove ownership?
You will need to change the bot in some way whilst live
Contact a moderator for more information/instruction 
ok, with anywhere moderator?
Any moderator can help you with owner transfer, yes. Feel free to dm me if needed
ty so much
there is something in node process for 'avaible memory'? I would like to create a graph with process.memoryUsage() but I need the max avaible, or I put it by hand, but I would prefer a method
i dont know if this is the correct channel to ask questions but my discord bot is starting to get people's attention and i need some help and advice about what should i do with my bot before it can be verified. if you have some to tell me, feel free to dm me!
does anyone know how to send a canvas buffer as attachment/image in channel?
using eris not discord.js
Seems to be included in the docs.
https://abal.moe/Eris/docs/0.16.1/Client#method-createMessage
Eris, a NodeJS Discord library
(Bottom two parameters in createmessage)
os.totalmem() gets you the ram in bytes the system has
but be aware measuring memory usage with nodejs is very messy
theres like 5 different metrics for measuring memory with nodejs
and when you stop using a piece of memory it may still show up as being used because node is garbage collected and will only clear that memory once it is running low
i think the only easy and reliable way of seeing how much memory is in use is by asking the os for it
Hello
good bye
how do I make it fetch the message by somebody's ID?
I know after takes in only message Ids
that's only available on user accounts
on user accounts? so we can make self bots again?
I thought they were against tos
they are against tos
it's not because something exists that it is allowed
TypeError: image/gif is not a legal HTTP header name
y

I'm trying to fetch an API and determine whether the resulting image is a gif or not
so why even make an endpoint only exclusive to self bots 
seems pointless
content-type is the header name
image/gif is the value
content-type, no?
You realise the API is being used by a user account to post that
It's being used as intended for the discord client, not your selfbot
because discord is acessible through apps and browser
no user endpoint = cannot have user clients
any site with user features have an user endpoint
the only difference is that most don't have it documented and/or isn't supposed to be used by third-parties
baseUrl isn't found?
Wait what exactly are you trying to do here
trying to fetch people's banners
but since there is no endpoint of that I have to write it manually
But you caan literally get people's banners with djs
i tried using passport, but for some reason it keeps redirecting me to the failure page. What could be the mistake? js app.post('/login', passport.authenticate('local', { failureRedirect: '/login?code=err' }), async (req, res) => {
lies
there is no endpoint for that


You can get their banner hash and then reform the banner with the hash

Which is 10x easier
cause no matter what format gif or not it will display properly
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
read this it tells you how to form the banner url
Also it gives you a nice little note for gif
So just check if the hash you get back starts with a_ unless djs already does that for ya idk haven't used it since the banner stuff
import {Link} from "react-router-dom";
export default function Navbar() {
return (
<>
<header className={'h-10'}>
<nav className={'flex flex-row'}>
<h1>Everything API</h1>
<ul className={'flex flex-row'}>
<li><Link to={'/'}>Home</Link></li>
<li><Link to={'/about'}>About</Link></li>
</ul>
</nav>
</header>
</>
)
}
Any idea on how I can center this within the 2.5rem height ?
oh no, oh no, is this...the classic "how to center a div" issue????
well, jokes aside, you need to have a flex flex-column div too
row for horizontal, column for vertical
or use justify-content set to middle
center
Well I don't wanna center it in the page just in the middle of the div
I don't like how it hugs the top of the page
option 1: give the div a fixed height, then use vertical-align, or margin top with calc, or padding
option 2: make the div a flexbox, like kuuhaku said
padding worked
Now to figure out how to get the nav links to go to the end
I am ashamed at how poor my css is
even with a lib like tailwind I am managing not to get it to work
😔
inb4 “why does my regex not work”
I meant for him dingus
If you know so much css how do I make my ul go to the end

I don't remember middle being used in CSS
I might be mixing with react-native then
Probably
I swear there was an alignment property that used middle instead of center
it's a property for vertical-align
ah yeah, that's the one
flex-end
it aligns all children to the end of the flex layout
in a column everything goes to bottom, in a row everything goes to the right
it'd be a flexible relationship
well flex end doesn't seem to be working
I fucking hate css
why does the css of the parent not relate to the child
😔
set the background color to red or something noticeable
see if the container size is filling the available space
sometimes it's not a matter o alignment, it's just sizing issues
import {Link} from "react-router-dom";
import './navbar.css'
export default function Navbar() {
return (
<>
<header className={'h-15 text-xl text-white font-mono'}>
<div className={'flex flex-row pt-2'}>
<h1>Everything API</h1>
<nav className={'flex justify-end'}>
<ul className={'flex-row'}>
<li className={'px-10'} ><Link to={'/'}>Home</Link></li>
<li><Link to={'/about'}>About</Link></li>
</ul>
</nav>
</div>
</header>
</>
)
}
Okay but like, if nav has the flex class and ul has the flex-row class
shouldn't the flex also carry to the children?
or am I misunderstanding how css works
Misty I think you need to take a course on color theory
The boundaries of my eyes
waffle go back to what you were doing
before I show up to your house and break ur doors down
Cause I don't know the grid system well enough
nor can I be bothered to try and learn it
:D
And aren’t you using next.js already
It is incredibly simple
It’s just dividing the page into 12 rows
Ok
I will
Later
Throw it on GitHub and invite me to it, I’ll make it pretty :p
Fair warning I might use mantine though
Because mantine is a fucking godsend
Also I would recommend tabler-icons-react for little button icons
Our comprehensive guide to CSS flexbox layout. This complete guide explains everything about flexbox, focusing on all the different possible properties for the parent element (the flex container) and the child elements (the flex items). It also includes history, demos, patterns, and a browser support chart.
it's relatively quick
and the article provides nice visualisations
i used it when learning flexbox and grid systems
Didn't it use Flex for them
Huh
I was confused too when I saw it
But last time I checked it used flexboxes for them
Yup
Lmao true
Is there a reason I got an error about getaddrinfo failed?
The full error is Cannot connect to host top.gg:443 sll:default [getaddrinfo failed]
maybe
Is there something I can do to prevent this from happening?
Is your server perhaps losing connection occasionally/bad DNS server?
or perhaps a firewall blocking outgoing port 443 etc?
Im not sure, I just woke up to see that error
Its only happened once, so I don't think its the firewall blocking
Then likely either your server losing the connection or a dns server coincidentally being bad while the dns entry for top.gg isnt cached
Hm, alright, thank you
I'm having trouble creating an invite link for a scheduled event. Does anyone have an example of what it looks like?
does anyone know how to remove special characters from a string where the special characters are not at the start or end? Something like this:
"Apples, Oranges, Bananas"
and change it to:
"Apples Oranges Bananas"
basically, .strip but for the inside of a string
I don't know of a built-in function but I've made a manual function for it using .slice and .indexOf.
<text>.replace(",", "")
Here's the pastebin: https://pastebin.com/98ZZgXrT
I can't get it to await ctx.send any 3 random emojis or number 7, without having single quotes and commas. I tried what you suggested, but the IDE wasn't happy with your suggestion because it kept thinking there was a missing parenthesis when there wasn't one missing.
Lmk if you find a way to get it printing cleanly
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
why dont u just use numbers to represent each emote?
instead of using the emote itself for resutl checking
yo
how do I access the url?
I did response.data.url
didn't work
pretty sure it's because its in an object
but I'm not sure how to get into it
ping in replies 👍
halp
right..
how do I get into that array if it has no name.. like js something: [ fds: 2534 ]
Here's the updated code: https://pastebin.com/YrGvHn71
I'm still not getting clean output, but I am using the index values to result check now instead of the emotes. Still have commas and single-quotes delineating the emojis in my output
I also added some newlines to make reading the debugger code output easier
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I'm still quite unsure what .strip("[], ''") is supposed to do
That whole thing is a mess (no offense intended)
For instance A == B == C will never be true unless C is a boolean
That's because A == B will resolve to a boolean, invalidating the next check
it just peels off the square brackets and ' of this:
[':Uncommon_Currency:', ':Epic_Currency:', ':Common_Currency:']
But WHY are you doing that, that's the question
Also as I saw in the docs strip only works for leading and trailing characters
When I said "use numbers instead of emotes" I meant something like 112 where 1 and 2 represent slots
But EVEN if you wanted to use emotes, there's no reason to work with a stringified array instead of the actual array
yea... getting back into python after doing Data Structures & Algos in Java, so I'm a little off my game
Probably best to scrap the whole function and start fresh I take it?
Ye
Think with arrays, not with strings
Make symbols to represent each slot, like numbers or letters
Then compose a sequence of those numbers
Like
int[] result = new int[3];
for (int i = 0; i < 3; i++) {
result[i] = (int) Math.random(7);
}
// ... compare array combination
wait Math.random() can take a number as input? never knew that
I'm gonna assume that's a psuedocode explanation or something cus looking at the javadocs it doesn't take a param lol
yea, it's a psuedocode explanation in Java of something I'm trying to do in Python
collector.on("end", () => {
msg.edit({
content: "Action aborted!",
components: [],
embeds: [],
}).catch(() => { });
})
i want this action only if the nothing selected in collections
for button and menu
how can i?
It's working!
Starting from scratch was a great idea, and my code is cleaner
💀
.strip basically removes specified substring from both ends of studying if they're there
'owo'.strip('o') == 'o'
huehuehue
result = [__import__("math").randint(0, 7) for _ in range(0, 3)]
I'm stuck with this here, how do I fix it? using typescript
hii guys so i want to create simple user info where bot will display, user server joined date but... Instead of doing that with moment which is no longer supported & updated, Which would be good alternatives to create this with? I read that Luxon is good alternative, so i "read" some part of docs, and tried to do something like this:
.setDescription(`**User Tag**: ${user.tag}\n**User ID**: ${user.id}\n**Joined Server**: ${DateTime.utc()(member.joinedAt).toFormat('dd/mm/yyyy')}`)
but thing is staht this display current date
so rn i really have no idea how else i should make this
Why not use the new timestamp markdown formatting implemented into discord?
https://discord.com/developers/docs/reference#message-formatting-timestamp-styles
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
which you'd just need to pass the seconds to, so you could do this thing for example
I just sent this message <t:1653984420:R>
What is index
nvm I fixed it but now I fixed that but now there is another issue
Post that issue with the error then if you need help
Sometimes I really wonder why people over complicate the fuck out of things
Just use math.random my g
I want to loop over them 1 by 1
Why loop
Well first off, don’t change status every 5 seconds. You’re gonna get ratelimited
Testing or not 5s is still too short
yes I know
Secondly, increment a variable every x time, and when it reaches activities.length, set it to 0 again
Also misty why are you still awake
I'm doing that
the issue is
It loops over all of them then when it comes to 0 again it throws the error
Whatever you’re doing looks complicated
Why are you still awake?
Just ```ts
let x = 0
setInterval(() => {
if(x >= activities.length) x = 0
// do stuff with activities[x]
x++
}, interval)
I have no idea why you’re making this boolean argument timer stuff, that’s massively overcomplicating it
idk XD I was taking help from someone else
Probably doesn’t help that it’s 4am for me rn but still
2am almost for me 😔
thanks tho, I know its simple but the issue I fixed before completely blown my head and its completely blank now
Lol
so idk what i'm even doing
Taught this poor guy some quadratic algorithms earlier 😉
I was copy pasting the codes someone gave me
Yeah, lesson learned… don’t do that
its not that lol, I just need a break
If you don't understand it and something happens no idea how to debug it
I need sleep
But waffle made it so algorithms is all I can think of 
the one gave me that code is someone um what its called..
brother?
maybe
he knows coding very well
so i just blindly copy pasted XD
I am beginning to question that statement after seeing that timer function lol
That was a brainfuck and a half
Is he a js/ts dev?
yeah
sadge
Not the greatest of solutions to a simple problem…
I’ll give him the benefit of the doubt though
C++ is a brainfuck for me
yeah. I'll be fine if I take a break.
C++ isn’t too bad tbh
Standard library is bloated though imo
C++ is just used for scarily complex shit
Where’s my beautiful frontend
btw why x = 0 after the if statement?
So that x doesn’t increment to infinity
Sadly it is non existent
I would think that you would not want to go out of bounds here 
If it kept going past the length of activities you'd experience out of bound
Waffle taught me out of bounds all too well
am I not supposed to put { } brackets?
😔
Don't gotta
It's a one line statement
ah okay
I’m on mobile and didn’t feel like typing out brackets. You don’t need them for one statement, but I still prefer to put them anyways
If you're writing multiple lines it's highly recommend to
okay
Technically I think you can write it all on one line but separate your stuff with ;
Waffle can confirm this
Yes I believe so
You could write your entire bot on one line 
You could write anything on one line
If you do make waffle format it without a linter that'd be fun
Fun fact, python accepts semicolons optionally
So you could one line an entire python project
I don't want fun facts about python only C#
Fun fact, using C# improves your chances of finding a stable and healthy relationship by 100%
Ok fuck typescript
He’s beginning to believe
So so so so so much easier to write it in ts when you have 0 C# experience
Hey I have some C# experience
I know basic types
Except I found out tuples were a thing earlier but still
You’ll appreciate C# for both its simplicity and complexity, but if you’re like me you’ll dread having to learn 40 different design patterns to accomplish anything with it
Async await is a thing in C#
Nice
Tasks are the equivalent of Promises
Damn dude u saved me
2:01
Rewrite it in go
fun fact
c#'s async workflow coined the design you know today
async/await keywords etc
what does the coined mean
made a standard or something in that fashion
don't know the exact definition
dictionary.com says
adjective
(of a word, expression, etc.) invented or made up:
A coined word, such as Xerox, is one of the most easily protected categories of trademark.
can u force embeds to be wider?
nop
f
Feed them until they get overweight
There’s an annoying embed bug
Where timestamps (if “x seconds ago”) constantly get wider and narrower
sounds like a time precision error either on your viewing device or on whoever's end who created the embed
(necroposting cuz I was sleeping)
so you wanna get dirty eh?
result = (0..<3).collect { Math.random() * 7 as int }
🤣
Hello, im using discord.js 13.
Is it possible to "hide" certain slash commands from everyone except myself (one userId) for stuff like maintenance commands only used by the bot creator?
Currently the only method i can think of is deploying one set of commands globally for every guild, while having one set of adminCommands deployed only in my personal guild.
no there is not. the only other soultions i have thought of are
- have another bot that is private
- just check if the interaction.user is you. if not just return.
- what i use for my eval is a button in my support discord that only i can see, and i have a modal that runs when i click the button and then it evals whatever i input into the modal. (only using a modal so i can space out things and make it look neater)
you can't hide them, you can however add a permission check or make them guildonly for your dev guild
how is the embed edit in v13
Bro one verified bot is nuking servers
Report them to Discord, and if it is also on Top.gg, click the 3 dots on the top right of the bot page and report it 😄
Remove from top.gg
Kk wait let me do it
Yeah, if you want us to remove it from Top.gg you would need to report it 🙂
trying to get to "all_domains"
but <json object>.data returns undefined
tried two things so far
connection.onmessage = e => {
const msg = JSON.stringify(JSON.parse(e.data),null,2);
console.log(msg.data)
}```
and js connection.onmessage = e => { console.log(e.data.data) }
what
The JSON.stringify() method returns a string
good point
blame gogle
e.data returns a json object
{"data":{"cert_index":1056358569,"cert_link":"http://ct.googleapis.com/logs/argon2022/ct/v1/get-entries?start=1056358569&end=1056358569","leaf_cert":{"all_domains":["*.turingengenharia.com.br","turingengenharia.com.br"],"extensions":{"authorityInfoAccess":"CA Issuers - URI:http://r3.i.lencr.org/\nOCSP - URI:http://r3.o.lencr.org\n","authorityKeyIdentifier":"keyid:14:2E:B3:17:B7:58:56:CB:AE:50:09:40:E6:1F:AF:9D:8B:14:C2:C6\n","basicConstraints":"CA:FALSE","certificatePolicies":"Policy: 1.3.6.1.4.1.44947.1.1.1\n CPS: http://cps.letsencrypt.org","ctlPoisonByte":true,"extendedKeyUsage":"TLS Web server authentication, TLS Web client authentication","keyUsage":"Digital Signature, Key Encipherment","subjectAltName":"DNS:turingengenharia.com.br, DNS:*.turingengenharia.com.br","subjectKeyIdentifier":"C3:E8:7E:5C:B3:20:00:B1:D8:41:EA:BC:AA:FC:46:A9:56:25:14:C8"},"fingerprint":"6C:C0:0D:3A:C0:C3:C4:D0:E2:FD:E4:0E:A1:6F:6F:D8:A0:6B:29:30","issuer":{"C":"US","CN":"R3","L":null,"O":"Let's Encrypt","OU":null,"ST":null,"aggregated":"/C=US/CN=R3/O=Let's Encrypt","emailAddress":null},"not_after":1661799167,"not_before":1654023168,"serial_number":"49F96F2496D775CA2A90F4620A169DED8EF","signature_algorithm":"sha256, rsa","subject":{"C":null,"CN":"*.turingengenharia.com.br","L":null,"O":null,"OU":null,"ST":null,"aggregated":"/CN=*.turingengenharia.com.br","emailAddress":null}},"seen":1654026860.151305,"source":{"name":"Google 'Argon2022' log","url":"ct.googleapis.com/logs/argon2022/"},"update_type":"PrecertLogEntry"},"message_type":"certificate_update"}```
example data
I have this bit of code that reverses an image based on an array of URL's. However, since the process takes so long, using Promise.all is faster in the long run than awaiting. The issue with this is that if I were to append the image in the .then, the images will be appended out of order. Because of this, I have to use Promise.all. But this doesn't make sense if there's a lot of images, so is there a way to sort or append an image at a specific "index"? Or to append an image in order? My goal is to have something like this:
for (let i = 0; i < urls.length; i++) {
let url = urls[i];
console.log("Loading " + url);
imgReverser("/content/" + url).then(canvas => {
console.log("Saving " + url);
const uri = canvas.toDataURL('image/jpeg', 0.9);
sorted.push([uri, i]);
sorted.sort((a, b) => a[1] - b[1]);
for (let i = 0; i < sorted.length; i++) {
if (sorted[i][0] === uri) {
let newP = document.createElement('img');
newP.src = uri;
newP.classList.add('asdfasdf');
document.getElementById('chapter_container').append(newP, some_index);
}
}
});
}
Uh, I'm kinda confused, does e.data return that? Or is that the e parameter passed in?
e.data returns that
Try logging typeof e.data
const WebSocket = require('ws')
const connection = new WebSocket(`wss://certstream.calidog.io`)
connection.onopen = () => {
console.log("connected to certstream")
}
connection.onerror = error => {
console.log(`error: ${error}`)
}
connection.onmessage = e => {
console.log(e.data)
}```
ok
wait its a string
string
JSON.parse(e.data).data
You're welcome
Awesome
very
is manage roles on discord.js MANAGE_ROLES
yes
or is is MANGAGE_ROLE
Using the Promise.prototype.then() method will not wait until the execution is done in this context, so that's why it appears out of order, if you want it to appear in order you have to resolve the promise with async/await
Yeah I purposely used .then so that the imgReverser function would fire continuously (ex. loop, fire event and loop without waiting) instead of looping, waiting, then looping again. I'm just wondering if it's possible to order elements in the JS DOM using .append. For example, get the image, append it, then check if the class is index x. If x is greater than y, then switch the two arround.
My goal is to sorta optimize my script so that it reverses all images as fast as possible, then display the images without having to wait a long time. The imgReverser function can take up to 0.5 seconds per image, meaning an array of 50 links will take 25 seconds to load everything. Currently with the method I have I got that time down to about 5-6 seconds, but it's still way longer than it should be.
Hello hello people
im here today
because i need help with something
I want to update one, and only one, object in an array in my database. I've figured out the hard way that
await UserSave.findOneAndUpdate({ userID: interaction.user.id, guildID: interaction.guild.id }, { inventory: inventory } );
replaces the whole array with 'inventory'
so i wonder
if any of you know how to do this?
You can create an image element, append it to the parent element, and modify it's source once it has loaded, so it would all be in order
const chapterContainer =
document.getElementById('chapter_container');
for (const url of urls) {
console.log(`Loading ${url}`);
const image = document.createElement('img');
chapterContainer.append(image);
imgReverser(`/content/${url}`).then((canvas) => {
console.log(`Saving ${url}`);
image.src = canvas.toDataURL('image/jpeg', 0.9);
});
}
mongodb?
yes :)
So you want to update one of the objects in the inventory array?
yes
If so, by index or by conditions of whether the object contains a specific value or what?
So you want to update the object based on their id property?
yes
Schema.findOneAndUpdate('inventory.id': wtvhere, {
$set: {
'inventory.$.<property>': wtv here
}
}).then().catch()
bad indentation cuz on phone
😔
Then you can use array filters to do so (this example is based on the code you showed), the following example increments the count property of the object with the 4534 as it's id property in the inventory array by 5
await UserSave.findOneAndUpdate({
userID: interaction.user.id,
guildID: interaction.guild.id
}, {
$inc: {
'inventory.$[findId].count': 5
}
}, {
arrayFilters: [{ 'findId.id': '4534' }]
});
Nope, that's just the name of the array filter, set in the arrayFilters property
what does findOneAndUpdate do?
is that a thing exclusive to djs?
finds a document and update the data in it
finds a document and updates it
no its a method for mongoose
oh that's interesting
That method is available in both the official MongoDB driver and Mongoose
okay, but the 'id' of the item in the inventory varies
so
is it easier to learn than other DBs or harder?
its not 4535 every time
its quite easy
You can just set the ID in the arrayFilters property to the one you want to find based on input for example
u need to update a single object in array of objects of a document right?
yes
nice
anyone knows where I can get ideas for stuff I can add to a bot?
okay, but its for a command. people can type in whatever id they want
so
Also that method is just the updateOne() method but it returns the document that was also modified, use the returnDocument directive, can be set to before or after
idk what it is
sounds kinda confusing
That's exactly what I'm saying, for example:
const id = /* get user input from the command user */;
await UserSave.findOneAndUpdate({
userID: interaction.user.id,
guildID: interaction.guild.id
}, {
$inc: {
'inventory.$[findId].count': 5
}
}, {
arrayFilters: [{ 'findId.id': id }]
});
@earnest phoenix could you tell me the difference between <client>.ws.on and <client>.on
I'm trying to see how they work and if I can use anything like that to add a custom event, if that's possible
for example an event where someone gets muted or warned
i keep getting DiscordAPIError: Interaction has already been acknowledged.
what does that mean?
Both the client and it's websocket manager (<Client>.ws) extend the EventEmitter class from the node:events built-in module, the <Client>.on() method adds an event listener for the pre-defined event listeners, such as ready, messageCreate, interactionCreate, and so on, which emit the data they've taken from the Discord API and turned it into a class instance or a more easier-to-work with type of data, although you can add non-pre-defined event listeners, but they won't emit any data unless you do so using the <EventEmitter>.emit() method (<Client>.emit()), the <Client>.ws.on() adds an event listener to the websocket manager of the client, which doesn't really have pre-defined event listeners on the typings (these event listeners can all be listed in Discord's official API documentation), which receives raw Discord API data and is not meant to be used by the user, but rather by the client itself
that's great!! so if I <EventEmitter>.emit() a method I can capture it using <Client>.ws.on() as a normal event?
EventEmitter how would I define this though?
You're acknowledging the interaction multiple times, maybe show code
For example:
client.on('foo', (data) => {
console.log(data); // bar
});
client.emit('foo', 'bar');
okay so any variable I put as 'bar' will be emmited, but how about functions?
can I, for example emit an entire function and then do something with it using client.on?
You can emit anything
I don't think that error is caused by that execute() method you've got there, probably something with your command handler, although which version of discord.js are you using?
v13
client.emit('userMuted', getSomethingDoSomething(variable, variable2));
client.on('userMuted', (data) => {
//what would doing just
data
//by itself do anything? I presume it would return a promise so data() would work to execute the function?
//for example
let var1, var2;
data(var1, var2);
});
I don't think that would work though, how would it know what variable and variable2 is
The exact version, you can check by npm ls discord.js
or maybe just structure the function in the emit instead of calling it in the emit??
here is all the command handling: https://sourceb.in/yQnxyTcqhn
discord.js@13.4.0
You should update to the latest version
npm update --save
Although that error occurs because it tries to create an initial reply to the interaction after an error occurred while executing that command, as the interaction already received an initial response in that command
…
So you can do
await interaction.reply({
content: 'An error occured',
ephemeral: true
}).catch(() =>
interaction.followUp({
content: 'An error ocurred',
ephemeral: true
})
);
ok
That code won't emit anything because you're emitting the data before the event listener is even added, and anything you emit will be passed as arguments to the event listener, so you can do anything with it
Or https://nodejs.dev/learn/the-nodejs-event-emitter as it's more simple
You can use a regex for that
Oh my he finally found a legitimate use for regex
I find it ironic that the one thing you don’t think to use regex for is one of the few things that it should be used for… 
/(?:\d+\s*(?:[smhdwy]|mo))*/
Test it against that, if it doesn't match then it's invalid
thanks man ur awesome
am I stupid or what cause those if checks aren't working
I did 1y and it didn't show the message
Have you tried logging both of the timeToMute variable and ms('24h')?
I haven't had the chance to, but I'm sure the value is right.. it's not like a massive package with millions of downloads wouldn't work

I don’t think the point was the package not working, I think the point he was trying to make is it might not be what you’re expecting
Don’t roll along with the mindset of “just because it’s a library it has to work exactly like I expect it to”, you need to test things when you’re debugging
well I think I just wanted to avoid testing too much
Avoiding enough testing for debugging purposes will just lead to more confusion while blindly trying random things to try and fix the issue, and waste more time
That is a very bad idea
If you want to save more time, use a debugger
And this mainly ^
52 years
that's the value both return
I'm not asking for the human-readable value, I'm asking for the exact values they return, show it to us
if (member.roles.cache.has(roleToMute.id || member.roles.cache.find(role => role.name === roleToMute).id || roleToMute)) {
return message.channel.send("The member is already muted.");
} else {
const memberHierarchy = member.roles.highest.position;
const muterHierarchy = message.member.roles.highest.position;
if (muterHierarchy >= memberHierarchy) {
if (args[1]) {
const timeToMute = ms(args[1]);
const timeToMuteMax = ms("24h");
console.log(timeAgo(timeToMute) + timeAgo(timeToMuteMax));
// Lets also require us the regex we need to check if the time is valid.
const timeValueCheckReg = /(?:\d+\s*(?:[smhdwy]|mo))*/;
if (!timeValueCheckReg.test(timeToMute)) return message.channel.send("I couldn't mute because the timeout value provided is not a valid time value.");
if (timeToMute >= timeToMuteMax) return message.channel.send("You can't mute for longer than 24 Hours at a time.");
try {
setTimeout(() => {
member.roles.remove(roleToMute);
}, timeToMute);
return message.channel.send(`:thumbsup: **${member.user.tag}** was successfully muted by **${message.author.tag}** for **${timeAgo(timeToMute)}**.`);
} catch {}
} else {
member.roles.add(roleToMute);
}
} else {
return message.channel.send("Could not mute the mentioned user, because they're higher in power hierarchy than you.");
}
}
sure
30000 and 86400000
@earnest phoenix it does return the correct value it seems, but then what is causing the error
Error?
no errors
I used a try catch just in case I guess it would be better if I remove it for testing
what is causing the error
no errors
I'm dumbfounded by this interaction
man
by errors I meant my seconds -> readable time convertion function didn't work
@earnest phoenix your reg is bugging out
why do you bother with checking it
the library will return NaN if the number is invalid
if you're using https://npmjs.com/package/ms
I am. how do I check?
something like that?
for some reason when directly checking for NaN like that it sometimes bugs out and says its not nan even though it is
you should use isNaN(value)
Not sometimes, always and it's not a bug; that behavior is defined by IEEE
I feel like isNaN bugs out a little bit more for some reason for me
isNaN(float) <--- false
is that supposed to be the case?
why tho
very stupid considering you can check for undefined and null just fine
It's better to read this
https://stackoverflow.com/a/1573715/14895795
Yes
actually now i do wonder what happens if you try to square root a negative number
tf
since when does c++ have-
talk about the language being bloated
i'll try c then
nevermind c is worse
bro c is actually fucked
not touching that shit again
idk man honestly i dont want to know
how could i have an array (or dictionary) of items and load them in as choices in a slash command
let dictionary = {
"name": "description"
}
// this part would be inside of the slash command creation
choices: [
{
// add name and description here
}
like this
i want to be able to add and remove things from the dictionary through other code and have it update
That's probably a compiler-specific thing, Clang produces the same random address with the conflicting formatting flags
I can't send a twitter DM with twit, it returns js Unhandled rejection Error: Sorry, that page does not exist.
hoping someone here knows twit js lmao
thats the default twitter error
outdated lib
i use twit for other stuff, still works fine
let dictionary = {
"name": "description"
}
choices: [...Object.keys(dictionary).map(value=>{
return {name:value,value}
}]
T.post("direct_messages/new", {
user_id: "1167570399959420929", // USER_ID is parameter from directMsg object
text: reportMsg
});```
it was a string anyways
hm, not that familiar with the twitter api as much, try snooping around that repo's issues
quick browse over at the twitter api docs gave me this
but that's using events
here's the link to the doc regardless
Well at least the "code" overlay isn't a tree call or tracert
https://cdn.myprojects.lol/📆😞💸🍪🚰.mp4
got it working in the end
This... seems like a very abusable idea
Its locked for just select approved users
Everyone else only has the basic whois domain and ip buttons and the report buttons
Not the report to registrar and report to ASN buttons
hi
im using the npm dependency passport-local to authenticate users, but for some reason every time i use passport.authenticate it goes to the failureredirect page, and i cant find why. what could be the cause of this?
Hey guys, so when i want to DEBUG ma welcomer.js file, i got this error (client.on) is not a function.
here is my code: welcomer.js
const client = require('../index')
const Schema = require('../database-schema/welcomeSchema')
const { MessageEmbed, Discord } = require('discord.js')
const {welcomeMsg, RandomMsg} = require('../data/wlcmMsg')
client.on('guildMemberAdd', async (member) => {
Schema.findOne({ Guild: member.guild.id }, async (e, data) => {
if (!data) {
return console.log('No channel to send the message!')
}
const channel = member.guild.channels.cache.get(data.Channel)
let role = member.guild.roles.cache.get(data.Role)
const embed = new MessageEmbed()
.setTitle('Welcome!')
.setColor('#ff173e')
.setDescription(`${RandomMsg}`)
.setTimestamp()
channel.send({ embeds: [embed] })
/**
*
*
* Guild.rulesChannel
*
*/
member.role.add()
})
})
show the contents of ../index.js
here, my whole code: ```js
const { Client, Intents, Collection, Interaction, MessageEmbed, Guild } = require('discord.js')
const { CLIENT_ID, OWNER_ID, prefix } = require('./json/config.json')
const { Routes } = require('discord-api-types/v9')
const { REST } = require('@discordjs/rest')
const mongoose = require('mongoose')
const { GiveawaysManager } = require('discord-giveaways')
const { Schema } = mongoose
require('dotenv').config()
const { readdirSync } = require('fs')
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_BANS, Intents.FLAGS.GUILD_INVITES , Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.DIRECT_MESSAGE_REACTIONS ] })
require('./systems/giveawaysys.js')(client)
module.exports = client
client.on('ready', () => {
console.log('Apolo is alive!!')
mongoose.connect(process.env.MONGO_DB || '', {
keepAlive: true,
})
setInterval( () => {
client.user.setActivity(`Serving on ${client.guilds.cache.size} servers.`, { type: 'WATCHING' })
}, 60000)
})
const rest = new REST({
version: "9"
}).setToken(process.env.TOKEN)
client.commands = new Collection()
client.events = new Collection()
const commands = []
const commandFolders = readdirSync('./commands')
for (const folder of commandFolders) {
const commandFiles = readdirSync(`./commands/${folder}`).filter(files => files.endsWith('.js'))
for (const file of commandFiles) {
const command = require(`./commands/${folder}/${file}`)
commands.push(command.data.toJSON())
client.commands.set(command.data.name, command)
}
}
rest.put(Routes.applicationCommands(CLIENT_ID), { body: commands })
.then(() => console.log('Successfully registered application commands.'))
.catch(console.error)
client.on('interactionCreate', async (interaction, message) => {
if (!interaction.isCommand()) return
const command = client.commands.get(interaction.commandName)
if(!command) return
const WarningEmbed = new MessageEmbed()
.setTitle('Warning!!')
.setDescription(`You are not allowed to use this command here!!`)
.setColor('RED')
.setTimestamp()
if(!interaction.guild) return interaction.reply({embeds: [WarningEmbed]})
try {
await command.execute(interaction, client, message)
}
catch(err) {
console.log(err)
await interaction.reply({
content: 'Error has occured and Im not able to reply!',
ephemeral: true
})
}
})
client.login(process.env.TOKEN)
// client.dbLogin()
i exported client in index.js so i should be able to use it inside welcomer.js but still nothing
ok, debuged without errors now, but still need to find the reason why its not sending any messages
i did

