9
9
10
10
# Third Party
11
11
import requests
12
+ from aadiscordbot import app_settings
12
13
from discord .colour import Color
13
14
from discord .embeds import Embed
14
15
from discord .ext import commands
@@ -52,7 +53,7 @@ def _build_market_price_embed(
52
53
market_system_id = market ["system_id" ]
53
54
url = "https://market.fuzzwork.co.uk/aggregates/"
54
55
url_params = {"system" : market_system_id , "types" : eve_type_id }
55
- market_data = requests .get (url = url , params = url_params , timeout = 2.50 )
56
+ market_data = requests .get (url = url , params = url_params , timeout = 5.00 )
56
57
57
58
embed .add_field (
58
59
name = market_system_name ,
@@ -120,8 +121,9 @@ def _build_market_price_embed(
120
121
inline = False ,
121
122
)
122
123
123
- @commands .command (pass_context = True )
124
- async def price (self , ctx ):
124
+ # @commands.command(pass_context=True)
125
+ @commands .slash_command (name = "price" , guild_ids = app_settings .get_all_servers ())
126
+ async def price (self , ctx , item_name : str ):
125
127
"""
126
128
Check an item price on all major market hubs
127
129
@@ -131,59 +133,113 @@ async def price(self, ctx):
131
133
:rtype:
132
134
"""
133
135
134
- markets = [
135
- {"name" : "Jita" , "system_id" : 30000142 },
136
- {"name" : "Amarr" , "system_id" : 30002187 },
137
- {"name" : "Rens" , "system_id" : 60004588 },
138
- {"name" : "Hek" , "system_id" : 60005686 },
139
- {"name" : "Dodixie" , "system_id" : 30002659 },
140
- ]
136
+ return await ctx .respond (
137
+ embed = self .price_check (
138
+ markets = [
139
+ {"name" : "Jita" , "system_id" : 30000142 },
140
+ {"name" : "Amarr" , "system_id" : 30002187 },
141
+ {"name" : "Rens" , "system_id" : 60004588 },
142
+ {"name" : "Hek" , "system_id" : 60005686 },
143
+ {"name" : "Dodixie" , "system_id" : 30002659 },
144
+ ],
145
+ item_name = item_name ,
146
+ ),
147
+ ephemeral = True ,
148
+ )
141
149
142
- await ctx .trigger_typing ()
150
+ @commands .slash_command (name = "jita" , guild_ids = app_settings .get_all_servers ())
151
+ async def jita (self , ctx , item_name : str ):
152
+ """
153
+ Check an item price on Jita market
143
154
144
- item_name = ctx .message .content [7 :]
155
+ :param ctx:
156
+ :type ctx:
157
+ :return:
158
+ :rtype:
159
+ """
145
160
146
- await self .price_check (ctx = ctx , markets = markets , item_name = item_name )
161
+ return await ctx .respond (
162
+ embed = self .price_check (
163
+ markets = [{"name" : "Jita" , "system_id" : 30000142 }], item_name = item_name
164
+ ),
165
+ ephemeral = True ,
166
+ )
147
167
148
- @commands .command ( pass_context = True )
149
- async def jita (self , ctx ):
168
+ @commands .slash_command ( name = "amarr" , guild_ids = app_settings . get_all_servers () )
169
+ async def amarr (self , ctx , item_name : str ):
150
170
"""
151
- Check an item price on Jita market
171
+ Check an item price on Amarr market
152
172
153
173
:param ctx:
154
174
:type ctx:
155
175
:return:
156
176
:rtype:
157
177
"""
158
178
159
- markets = [{"name" : "Jita" , "system_id" : 30000142 }]
179
+ return await ctx .respond (
180
+ embed = self .price_check (
181
+ markets = [{"name" : "Amarr" , "system_id" : 60008494 }], item_name = item_name
182
+ ),
183
+ ephemeral = True ,
184
+ )
160
185
161
- await ctx .trigger_typing ()
186
+ @commands .slash_command (name = "rens" , guild_ids = app_settings .get_all_servers ())
187
+ async def rens (self , ctx , item_name : str ):
188
+ """
189
+ Check an item price on Rens market
162
190
163
- item_name = ctx .message .content [6 :]
191
+ :param ctx:
192
+ :type ctx:
193
+ :return:
194
+ :rtype:
195
+ """
164
196
165
- await self .price_check (ctx = ctx , markets = markets , item_name = item_name )
197
+ return await ctx .respond (
198
+ embed = self .price_check (
199
+ markets = [{"name" : "Rens" , "system_id" : 60004588 }], item_name = item_name
200
+ ),
201
+ ephemeral = True ,
202
+ )
166
203
167
- @commands .command ( pass_context = True )
168
- async def amarr (self , ctx ):
204
+ @commands .slash_command ( name = "hek" , guild_ids = app_settings . get_all_servers () )
205
+ async def hek (self , ctx , item_name : str ):
169
206
"""
170
- Check an item price on Amarr market
207
+ Check an item price on Hek market
171
208
172
209
:param ctx:
173
210
:type ctx:
174
211
:return:
175
212
:rtype:
176
213
"""
177
214
178
- markets = [{"name" : "Amarr" , "system_id" : 60008494 }]
215
+ return await ctx .respond (
216
+ embed = self .price_check (
217
+ markets = [{"name" : "Hek" , "system_id" : 60005686 }], item_name = item_name
218
+ ),
219
+ ephemeral = True ,
220
+ )
179
221
180
- await ctx .trigger_typing ()
222
+ @commands .slash_command (name = "dodixie" , guild_ids = app_settings .get_all_servers ())
223
+ async def dodixie (self , ctx , item_name : str ):
224
+ """
225
+ Check an item price on Dodixie market
181
226
182
- item_name = ctx .message .content [7 :]
227
+ :param ctx:
228
+ :type ctx:
229
+ :return:
230
+ :rtype:
231
+ """
183
232
184
- await self .price_check (ctx = ctx , markets = markets , item_name = item_name )
233
+ return await ctx .respond (
234
+ embed = self .price_check (
235
+ markets = [{"name" : "Dodixie" , "system_id" : 30002659 }],
236
+ item_name = item_name ,
237
+ ),
238
+ ephemeral = True ,
239
+ )
185
240
186
- async def price_check (self , ctx , markets , item_name : str = None ) -> Coroutine :
241
+ @classmethod
242
+ def price_check (cls , markets , item_name : str = None ) -> Coroutine :
187
243
"""
188
244
Do the price checks and post to Discord
189
245
@@ -197,8 +253,6 @@ async def price_check(self, ctx, markets, item_name: str = None) -> Coroutine:
197
253
:rtype:
198
254
"""
199
255
200
- await ctx .trigger_typing ()
201
-
202
256
if item_name != "" :
203
257
try :
204
258
eve_type = (
@@ -229,7 +283,7 @@ async def price_check(self, ctx, markets, item_name: str = None) -> Coroutine:
229
283
)
230
284
231
285
for market in markets :
232
- self ._build_market_price_embed (
286
+ cls ._build_market_price_embed (
233
287
embed = embed ,
234
288
market = market ,
235
289
item_name = item_name ,
@@ -249,7 +303,7 @@ async def price_check(self, ctx, markets, item_name: str = None) -> Coroutine:
249
303
inline = False ,
250
304
)
251
305
252
- return await ctx . send ( embed = embed )
306
+ return embed
253
307
254
308
255
309
def setup (bot ) -> None :
0 commit comments