1
1
using Cyberia . Api . Data ;
2
2
using Cyberia . Api . Utils ;
3
+ using Cyberia . Salamandra . Commands . Dofus . Quest ;
3
4
using Cyberia . Salamandra . Enums ;
4
5
using Cyberia . Salamandra . Services ;
5
6
@@ -31,23 +32,23 @@ public SearchCommandModule(ICultureService cultureService, DofusDatacenter dofus
31
32
_embedBuilderService = embedBuilderService ;
32
33
}
33
34
34
- [ Command ( "effect " ) , Description ( "Search where the effect is used" ) ]
35
+ [ Command ( "criterion " ) , Description ( "Search where the criterion is used" ) ]
35
36
[ SlashCommandTypes ( DiscordApplicationCommandType . SlashCommand ) ]
36
- public async Task EffectExecuteAsync ( SlashCommandContext ctx ,
37
- [ Parameter ( "where" ) , Description ( "Where to look for the effect " ) ]
38
- SearchLocation location ,
39
- [ Parameter ( "id" ) , Description ( "Effect id" ) ]
40
- [ MinMaxValue ( - 1 , 9999 ) ]
41
- int effectId )
37
+ public async Task CriterionExecuteAsync ( SlashCommandContext ctx ,
38
+ [ Parameter ( "where" ) , Description ( "Where to look for the criterion " ) ]
39
+ SearchCriterionLocation location ,
40
+ [ Parameter ( "id" ) , Description ( "Criterion id" ) ]
41
+ [ MinMaxLength ( 2 , 2 ) ]
42
+ string criterionId )
42
43
{
43
44
var culture = await _cultureService . GetCultureAsync ( ctx . Interaction ) ;
44
45
45
46
StringBuilder descriptionBuilder = new ( ) ;
46
47
47
48
switch ( location )
48
49
{
49
- case SearchLocation . Item :
50
- foreach ( var itemData in _dofusDatacenter . ItemsRepository . GetItemsDataWithEffectId ( effectId ) )
50
+ case SearchCriterionLocation . Item :
51
+ foreach ( var itemData in _dofusDatacenter . ItemsRepository . GetItemsDataWithCriterionId ( criterionId ) )
51
52
{
52
53
descriptionBuilder . Append ( "- " ) ;
53
54
descriptionBuilder . Append ( itemData . Name . ToString ( culture ) ) ;
@@ -56,8 +57,8 @@ public async Task EffectExecuteAsync(SlashCommandContext ctx,
56
57
descriptionBuilder . Append ( ")\n " ) ;
57
58
}
58
59
break ;
59
- case SearchLocation . Spell :
60
- foreach ( var spellData in _dofusDatacenter . SpellsRepository . GetSpellsDataWithEffectId ( effectId ) )
60
+ case SearchCriterionLocation . Spell :
61
+ foreach ( var spellData in _dofusDatacenter . SpellsRepository . GetSpellsDataWithCriterionId ( criterionId ) )
61
62
{
62
63
descriptionBuilder . Append ( "- " ) ;
63
64
descriptionBuilder . Append ( spellData . Name . ToString ( culture ) ) ;
@@ -67,34 +68,34 @@ public async Task EffectExecuteAsync(SlashCommandContext ctx,
67
68
}
68
69
break ;
69
70
default :
70
- await ctx . RespondAsync ( $ "Unknown { Formatter . Bold ( location . ToString ( ) ) } ") ;
71
+ await ctx . RespondAsync ( $ "Unknown { Formatter . Bold ( location . ToStringFast ( ) ) } ") ;
71
72
return ;
72
73
}
73
74
74
75
var embed = _embedBuilderService . CreateEmbedBuilder ( EmbedCategory . Tools , "Tools" , culture )
75
- . WithTitle ( $ "Search effect { effectId } in { location } ")
76
+ . WithTitle ( $ "Search criterion { criterionId } in { location } ")
76
77
. WithDescription ( descriptionBuilder . ToString ( ) . WithMaxLength ( Constant . MaxEmbedDescriptionSize ) ) ;
77
78
78
79
await ctx . RespondAsync ( embed ) ;
79
80
}
80
81
81
- [ Command ( "criterion " ) , Description ( "Search where the criterion is used" ) ]
82
+ [ Command ( "effect " ) , Description ( "Search where the effect is used" ) ]
82
83
[ SlashCommandTypes ( DiscordApplicationCommandType . SlashCommand ) ]
83
- public async Task CriterionExecuteAsync ( SlashCommandContext ctx ,
84
- [ Parameter ( "where" ) , Description ( "Where to look for the criterion " ) ]
85
- SearchLocation location ,
86
- [ Parameter ( "id" ) , Description ( "Criterion id" ) ]
87
- [ MinMaxLength ( 2 , 2 ) ]
88
- string criterionId )
84
+ public async Task EffectExecuteAsync ( SlashCommandContext ctx ,
85
+ [ Parameter ( "where" ) , Description ( "Where to look for the effect " ) ]
86
+ SearchEffectLocation location ,
87
+ [ Parameter ( "id" ) , Description ( "Effect id" ) ]
88
+ [ MinMaxValue ( - 1 , 999_999 ) ]
89
+ int effectId )
89
90
{
90
91
var culture = await _cultureService . GetCultureAsync ( ctx . Interaction ) ;
91
92
92
93
StringBuilder descriptionBuilder = new ( ) ;
93
94
94
95
switch ( location )
95
96
{
96
- case SearchLocation . Item :
97
- foreach ( var itemData in _dofusDatacenter . ItemsRepository . GetItemsDataWithCriterionId ( criterionId ) )
97
+ case SearchEffectLocation . Item :
98
+ foreach ( var itemData in _dofusDatacenter . ItemsRepository . GetItemsDataWithEffectId ( effectId ) )
98
99
{
99
100
descriptionBuilder . Append ( "- " ) ;
100
101
descriptionBuilder . Append ( itemData . Name . ToString ( culture ) ) ;
@@ -103,8 +104,8 @@ public async Task CriterionExecuteAsync(SlashCommandContext ctx,
103
104
descriptionBuilder . Append ( ")\n " ) ;
104
105
}
105
106
break ;
106
- case SearchLocation . Spell :
107
- foreach ( var spellData in _dofusDatacenter . SpellsRepository . GetSpellsDataWithCriterionId ( criterionId ) )
107
+ case SearchEffectLocation . Spell :
108
+ foreach ( var spellData in _dofusDatacenter . SpellsRepository . GetSpellsDataWithEffectId ( effectId ) )
108
109
{
109
110
descriptionBuilder . Append ( "- " ) ;
110
111
descriptionBuilder . Append ( spellData . Name . ToString ( culture ) ) ;
@@ -114,12 +115,12 @@ public async Task CriterionExecuteAsync(SlashCommandContext ctx,
114
115
}
115
116
break ;
116
117
default :
117
- await ctx . RespondAsync ( $ "Unknown { Formatter . Bold ( location . ToString ( ) ) } ") ;
118
+ await ctx . RespondAsync ( $ "Unknown { Formatter . Bold ( location . ToStringFast ( ) ) } ") ;
118
119
return ;
119
120
}
120
121
121
122
var embed = _embedBuilderService . CreateEmbedBuilder ( EmbedCategory . Tools , "Tools" , culture )
122
- . WithTitle ( $ "Search criterion { criterionId } in { location } ")
123
+ . WithTitle ( $ "Search effect { effectId } in { location } ")
123
124
. WithDescription ( descriptionBuilder . ToString ( ) . WithMaxLength ( Constant . MaxEmbedDescriptionSize ) ) ;
124
125
125
126
await ctx . RespondAsync ( embed ) ;
@@ -129,7 +130,7 @@ public async Task CriterionExecuteAsync(SlashCommandContext ctx,
129
130
[ SlashCommandTypes ( DiscordApplicationCommandType . SlashCommand ) ]
130
131
public async Task ItemSpriteExecuteAsync ( SlashCommandContext ctx ,
131
132
[ Parameter ( "item_type_id" ) , Description ( "Item type ID" ) ]
132
- [ MinMaxValue ( 0 , 999 ) ]
133
+ [ MinMaxValue ( 0 , 999_999 ) ]
133
134
int itemTypeId ,
134
135
[ Parameter ( "gfx_id" ) , Description ( "Gfx ID" ) ]
135
136
[ MinMaxValue ( - 1 , 999_999 ) ]
@@ -157,4 +158,26 @@ public async Task ItemSpriteExecuteAsync(SlashCommandContext ctx,
157
158
158
159
await ctx . RespondAsync ( embed ) ;
159
160
}
161
+
162
+ [ Command ( "quest" ) , Description ( "Search the quest where the quest step ID is used" ) ]
163
+ [ SlashCommandTypes ( DiscordApplicationCommandType . SlashCommand ) ]
164
+ public async Task QuestExecuteAsync ( SlashCommandContext ctx ,
165
+ [ Parameter ( "id" ) , Description ( "Quest step ID" ) ]
166
+ [ MinMaxValue ( 0 , 999_999 ) ]
167
+ int questStepId )
168
+ {
169
+ var culture = await _cultureService . GetCultureAsync ( ctx . Interaction ) ;
170
+
171
+ var questData = _dofusDatacenter . QuestsRepository . GetQuestDataByQuestStepId ( questStepId , out var questStepIndex ) ;
172
+ if ( questData is null )
173
+ {
174
+ await ctx . RespondAsync ( $ "There is no quest with step ID { Formatter . Bold ( questStepId . ToString ( ) ) } .") ;
175
+ return ;
176
+ }
177
+
178
+ var response = await new QuestMessageBuilder ( _embedBuilderService , questData , questStepIndex , null , culture )
179
+ . BuildAsync < DiscordInteractionResponseBuilder > ( ) ;
180
+
181
+ await ctx . RespondAsync ( response ) ;
182
+ }
160
183
}
0 commit comments