File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
MethodSystem/Methods/DatabaseMethods Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ using SER . ArgumentSystem . Arguments ;
2+ using SER . ArgumentSystem . BaseArguments ;
3+ using SER . Helpers . Exceptions ;
4+ using SER . MethodSystem . BaseMethods ;
5+ using SER . MethodSystem . MethodDescriptors ;
6+
7+ namespace SER . MethodSystem . Methods . DatabaseMethods ;
8+
9+ public class GetFromDBMethod : ReturningMethod , ICanError
10+ {
11+ public override string Description => "Returns the value of a given key in the database." ;
12+
13+ public override Type [ ] ? ReturnTypes => null ;
14+
15+ public string [ ] ErrorReasons =>
16+ [
17+ "Provided key does not exist in the database."
18+ ] ;
19+
20+ public override Argument [ ] ExpectedArguments =>
21+ [
22+ new DatabaseArgument ( "database" ) ,
23+ new TextArgument ( "key" )
24+ ] ;
25+
26+ public override void Execute ( )
27+ {
28+ if ( Args . GetDatabase ( "database" ) . Get ( Args . GetText ( "key" ) ) . HasErrored ( out var err , out var value ) )
29+ {
30+ throw new ScriptRuntimeError ( err ) ;
31+ }
32+
33+ ReturnValue = value ;
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments