Bejasc
Explore posts from serversSIASapphire - Imagine a framework
•Created by Bejasc on 11/2/2024 in #sapphire-support
Precondition not running
I've taken this from a working template project of mine, but I can't for the life of me figure out where this message is coming from.. it works in the template project, and checking the docs I can't see what I'm missing... I'm missing something stupid right? It's sitting in a
preconditions
folder, just the same
The log message is not my own.
2024-11-02 22:59:01 - [WARN] preconditionUnavailable - The precondition "OwnerOnly" is not available.
5 replies
SIASapphire - Imagine a framework
•Created by Bejasc on 7/25/2024 in #sapphire-support
Event before precondition OR access the command via MessageCommandDenied
Hi all,
I have extended my Command Options to include a property
shouldDeleteOnPost
- which should delete the message once it has been posted.
I'd like to do this in the most universal way possible - I thought using MessageCommandRun
would have fired before any of the preconditions, but it seems it does not.
When a precondition returns this.error, the code within MessageCommandRun
does not fire. It fires if the precondition is passed, or does not exist.
I'm not sure if there is an event that will fire before the precondition is run - pass or fail ?
If there is, that's where I would put effectively something like the following
To get around this, I thought I would try doing effectively the same out of the MessageCommandAccepted
and MessageCommandDenied
events - which would have worked perfectly, until I realised that MessageCommandDenied
doesn't appear to have any context of what the command itself actually was.
How can I either...
- Run some event before a precondition, pass or fail (preferred)
- Access the command inside of MessageCommandDenied
(unlikely?)
Happy to hear other ideas of how I might achieve the goal of flagging some commands with shouldDeleteOnPost
and deleting them, regardless of precondition status.8 replies
SIASapphire - Imagine a framework
•Created by Bejasc on 7/18/2024 in #sapphire-support
Hide Slash/Context menu commands
I have a number of Slash and Context Menu commands that I would like to hide, unless the user holds certain permissions.
These permissions, I want to define by role (e.g, the 'Moderator' role).
The commands should only be visible for users who have that specific role.
I know that the commands can be maintained on a per guild status, in my instance, the bot only exists and only ever will exist in the context of a single guild - and the list of role IDs that need access are limited.
I know that changing the commands through the Integration tab in Discord - it is possible to effectively hide the commands from those who should not have access.
How can I do this at a code level, and by using a role?
7 replies
SIASapphire - Imagine a framework
•Created by Bejasc on 6/2/2024 in #sapphire-support
Decorator issue
Having a weird issue with the decorators..
I've just updated all of my dependencies to the absolute latest version, but the error is still persisting here. It seems to be quite random, but there are steps I can take every time to get the error.
Note that I've always had
"experimentalDecorators": true,
as part of my tsconfig - everything I've seen so far suggests adding that.
When I remove "experimentalDecorators": true,
, the same error appears across every file, not just the one file with the issue.
Notably, when I see the issue, I also have a bunch of other errors (pointing to the discord.js package inside nodemodules, something about ECMAScript 2015, and a whole bunch of errors across other files that aren't normally there.
Also, the project compiles fine, the decorator throwing the issue is working as expecred, but the whole project is going mental with errors that it's never reported before.
To reproduce this, I;
- Copy an existing file
- Rename the file/class name
Then, I see the error reported on the decorator,
Then, several other errors appear
14 replies
DIAdiscord.js - Imagine an app
•Created by Bejasc on 3/7/2024 in #djs-questions
member.setNickname or member.roles.add occasionally not working
Hi all,
What reasons are there for a nickname potentially not being applied, or a role potentially not being applied?
I have the following - which is fairly stock standard.
In some cases, the members nickname is not changed, or the alive role is not being added.
(The species role seems to be correctly applied in every case).
Usually, everything is applied correctly. I have not seen both the Alive role and the Nickname change not work.
Most often - the nickname does not update.
I'm confused - because it seems sporadic. It's not a caching issue - the users display name is not changed on any client, even after refresh. To make things more confusing, the audit log appears to note the change - but the change does not appear to be applied. Am not getting and kind of error logs, the member object is defined (And other operations like those roles are working without issue)
I'm confused - because it seems sporadic. It's not a caching issue - the users display name is not changed on any client, even after refresh. To make things more confusing, the audit log appears to note the change - but the change does not appear to be applied. Am not getting and kind of error logs, the member object is defined (And other operations like those roles are working without issue)
8 replies
SIASapphire - Imagine a framework
•Created by Bejasc on 2/3/2024 in #sapphire-support
Listener run() signature
Feel like I'm missing something obvious.. how do I find out the correct signature for a
run
method of any given listener - they're different for each event.
I'm sure there's an obvious way to get this, without trial and error and debugging to see what's available to it - where am I not looking?
12 replies
SIASapphire - Imagine a framework
•Created by Bejasc on 9/29/2023 in #discordjs-support
Authenticated Attachment URLs
Hi guys,
For many areas of my bot, embeds access images that are posted into an #assets channel either by me or by select others in my community.
The CDN links for these are stored in mongo and referenced again and again, as the embed is sent.
They are only used and accessed within the discord client itself.
Does anyone have any more insight, confirmation, or thoughts on what the long term feasibility of this is?
Reading the announcement and all I can find, I don't know what to expect for the links hosted in this way.
The client behavior is not changing and will refresh posted URLs to be automatically valid, so your app doesn't need to worry about refreshing URLs itself if the link was valid at the time of posting.
7 replies
SIASapphire - Imagine a framework
•Created by Bejasc on 8/14/2023 in #sapphire-support
string option, support for strings inside quotes?
Feel a bit silly making a thread out of this as it's a question rather than a support topic
I have read that using
args.pick("string")
will match the next singular word, or the phrase contained "within quotes"
.
I gather that options
and flags
are generally used for numerical or bool like inputs, but when reading the value of a flag, it does not behave the same way.
ie
^test "Hello World" --flag="This is a test"Is there any support for phrases at a flag level?
17 replies
SIASapphire - Imagine a framework
•Created by Bejasc on 8/12/2023 in #sapphire-support
contextMenuRun not firing
8 replies
SIASapphire - Imagine a framework
•Created by Bejasc on 7/1/2023 in #sapphire-support
Combine Precondition and object available on the Command
Not sure if I've put that the right way, but I'm sure that the example will make some sense.
I have this precondition that works.
I've used it to replace a bunch of code that I had in several commands that was similar to
The key to my question is on that last line above.... do something with the character object.
To do this when I need to, it means that I need to use
CharacterService.getCharacter
a second time - which if possible, I'd like to avoid.
Almost all of my commands have a context of the character
.
The reason I have it as a precondition is so that I can selectively apply it to the commands, as not all of them need the character.
But enough of them do, that if I can abstract that character up into the command itself, it'll be useful.
Can I do something at the precondition level, to assign something, so that in the command itself, I will have access to the character
?
Otherwise, is there some better way to do this, that is not a precondition?6 replies
SIASapphire - Imagine a framework
•Created by Bejasc on 6/25/2023 in #sapphire-support
Get the value that was attempted to be parsed in an Arg
Hiya folks,
I have the following code, where I determine if the arg is either of my custom type (working), or if it's a server member. If it is neither, I want to throw out an error that I can handle, but as part of handling that error, I'd like to know the value that was attempted to be parsed.
in this example,
value
(inside the Error
) doesn't exist, but I think it's pretty clear what I'm trying to do.
I know that I could make an arg type that returns either an Npc or a Guild Member, and use parameter
in the Args.error
similar to what I do here...
But I'd rather not have to make a brand new arg type for trying to do something like this.
Any pointers?17 replies
SIASapphire - Imagine a framework
•Created by Bejasc on 12/28/2022 in #sapphire-support
Use commands from src and also from custom package in node_modules (Programatically add commands?)
There's probably a better way to do this, but wrapping my head around how I want to approach it.
I'm working on a variety of smaller NPM packages that I intend to use across a bunch of different bots/projects.
One of these packages, I want to have a debug command - without having to specify what that command is/does inside of each project - I only want to specify it once at the package level, as all projects will use it the same.
For this package, it exports a class, that is instantiated immediately after the project connects to the client.
When this class is initialized, it takes in the
SapphireClient
- so I assume I can do something with this from here.
|-- node_modules
|-- |-- package
|-- |-- |-- Commands
|-- src
|-- | --Commands
If I have the client object - what's the best approach I should take, to be able to run commands from the package and commands from the src?11 replies
SIASapphire - Imagine a framework
•Created by Bejasc on 12/24/2022 in #sapphire-support
Custom Arg - ResultError Unwrap failed
This seemed to be working for me in a previous version of Sapphire - but I've only recently gotten back into the swing of things, so there's a good chance I've missed a change.
I have a prefix command that has a single arg. The custom arg works great, for returning a result where a result actually does exist (items from item system)
Where that item doesn't exist, it throws an error with the identifier "InputNotanItem".
When this was working - the first
.catch
only returned null
(which is also a valid response). I've added this catch to try and catch something earlier than my outer try/catch, in case there's some issue there.
I can see that the err
does include identifier
and parameter
, but I cannot read these values - I'm assuming it has something to do with this..
ResultError: UnwrapFailed
36 replies
SIASapphire - Imagine a framework
•Created by Bejasc on 12/14/2022 in #sapphire-support
Read property from custom Command Options
Hey folks,
I have a custom command options object, that contains a property called
shortDesc
.
I want to read a property from the options, inside the registerApplicationCommands
method, so that I can not have to provide this value (Get a random trivia question
) twice.
How do I read shortDesc
? this.shortDesc
didn't work the same as this.name
did - I assume because name
exists on the default CommandOptions
object, but it's having trouble parsing the Options here as IDrpgCommandOptions
?
26 replies