#Plugins not triggering

1 messages · Page 1 of 1 (latest)

untold emberBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

neat plaza
#

what is the issue?

#

if you are wondering why the trace isnt working you need to use container.logger instead of console

winter plank
#

Lets start at the beginnging. Your whole setup is not Sapphire compliant. Listed below are all issues I can see in the index.js file:

#
  • There is no plugins field in client options
  • You're importing commands and listeners but that's not compliant with loading commands in sapphire
  • There is no such thing as a tracePrefix and traceTimestamp on a Logger
  • There is no field console on logger (see screenshot)
  • You're using client.on / client.once instead of Listeners
  • You're starting a separate Express app, not necessarily bad but we very strongly advice using @sapphire/plugin-api instead so it properly integrates with Sapphire and DiscordJS
  • You're reading a sepatate Src/Controllers directory instead of creating a custom store, again not necessarily wrong but very ill advised.

Please review our guide for creating a Sapphire bot and/or generate a starter template with @sapphire/cli package.

untold emberBOT
winter plank
#

I wonder how whomever gave you this code wrote this. Even with it being JavaScript, vscode would still somewhat inform you the code is wrong (although not error on it like it would for TypeScript) but moreover I just find it baffling how someone could write code like this at all like where do these people get it from that this is code that is compliant with the framework they are using. You're not the first one where I see very very weird code that is uncompliant.

#

it's quite literally like writing a NodeJS program using Python, or writing an English sentence but using Japanese characters or such

gritty cradle
#

Maybe the python looking stuff was me cause im a python guy

#

You said "You're starting a separate Express app, not necessarily bad but we very strongly advice using @sapphire/plugin-api instead so it properly integrates with Sapphire and DiscordJS"
I am going to use this bot for a counter for DDoS Attacks, my company wants to expose a webhook server, would the plugin-api serve the same as a webhook server? doing some magic to get a webhook GET out through a DDoS attack but I was recommended Express

winter plank
#

Thx for the report. I'll fix that.

winter plank
#

Although if you want some kind of API for company purposes, why the discord bot code around it? Wouldn't it be better to make a standalone project? In fact, is NodeJS even the best language for this? Personally I'd earlier gravitate towards Java or C# because their landscapes are generally more stable.

gritty cradle
#

You would have to ask my boss for that, I’ve simply been tasked with finishing this up and working on kubernetes and other fun systems I have 0 clue about

#

I think the whole idea is to show our clients how many attacks we get and whatnot blah blah, basically pushing what we can into public eyes

winter plank
#

Alright I guess.

#

Sounds to me like your boss is riding the buzzword hype instead of hiring a proper architect but he do he

gritty cradle
#

My instructions are as follows
Build a discord bot
Build an attack counter
Make the attack counter change discord channel names when we receive data from an attacked server
Update some numbers elsewhere that we are yet to figure out
🤷 I’m up to suggestions if you think something would be more practical

gritty cradle
winter plank
#

Just curious but does your company even get DDoSd btw. It's not exactly an all that common thing in the grand scheme of things. Sure would be fucking hilarious if you do all this work and the counter sticks at 0.

gritty cradle
#

We get DDoSed daily, we host game servers

winter plank
#

Oh

#

Wait actual DDoS like clearly malicious ones, or just a lot of people trying to play your games?

#

I have no idea how game server hosting works tbh

gritty cradle
#

People try to take down servers to get the players from that down server into theirs, or maybe they’re banned from that server and hate that they broke a rule and got banned

winter plank
#

Urgh

#

Spiteful people

gritty cradle
#

Honestly you find the weirdest people DDOS’ing, sometimes we get hit with tbps sometimes it’s not even 10mbps

#

Cash and ego are the biggest factors in that scene, and we just want people to know they’ve been attacked and survived lol

gritty cradle
#

The count is just to inflate our ego and the clients I’d say, if we can’t get the counter to increase when an attack happens that means we’ve lost and the box has gone offline, if it goes up it means we’ve won and the server is still online

winter plank
#

Anyway looping back to original topic, I suppose your current plan is solid. Yeah there are other ways to do it but whether those are necessarily better I don't know.

gritty cradle
#

If you’re willing to list off some things I’ll take a look into it when I wake up in the morning, thank you for being helpful

winter plank
#

For example you could have a separate API (for the webhook) and discord bot and have them communicate via a message queue like rabbitmq. You'd deploy all three in a k8s pod since you said you're gonna have to use k8s. Now your API is free to use whatever it wants and separate from the constraints of discordjs/sapphire and whenever a request comes in that requires an update to a discord channel you post a message to a message topic that the bot is a consumer for which picks it up and consumes it for processing.

At this point your bot could even be an http only bot, free from the relative overhead of discordjs by which I mean gateway events, websocket, all the caching done etc because updating a channel is as easy as a single REST request along the lines of this CURL request

curl 'https://discord.com/api/v10/channels/channel_id/' \
--request PATCH \
--header 'Authorization: Bot <token>'

https://discord.com/developers/docs/resources/channel#modify-channel

Because of the ease of what k8s provides at this point you can also spawn multiple instances of both bot and API for horizontal scaling, something that you'll be very hard pressed to achieve with a discordjs based bot because of the gateway and websocket part of it. But with this setup it's as easy as configuring the scaling in k8s and let it handle the load balancing. K8s can automatically make sure that you have 1 outward going URL going to multiple inward pods so approaching the webhook and http only bot is still only 1 route each.

If you want to explore this, for the bot part you can use @skyra/http-framework which is what we use for @clever geyser and the other bots with similar style avatars here

gritty cradle
#

Thank you so much, I’ll see how I can better my stuff, you’ll see how it goes if I open another support ticket lol