-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
72 lines (50 loc) · 2.41 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import discord
from discord.ext import commands
from validators import is_valid_alpha2_code
from dispatchers import steam_offers_dispatcher
from config import DISCORD_BOT_TOKEN, COMMAND_PREFIX
from messages import bot_messages
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix=COMMAND_PREFIX, intents=intents)
@bot.command(name='specials', help="Sends you Steam Specials offers in a specific region or country.")
async def send_steam_specials(ctx, alpha2_code='US'):
if is_valid_alpha2_code(string=alpha2_code):
try:
embed_msg = steam_offers_dispatcher(action_type='SEND_SPECIALS', payload={
'alpha2_code': alpha2_code})
await ctx.reply(embed=embed_msg)
except:
await ctx.reply(bot_messages['errors']['fetch_data_error'])
else:
await ctx.reply(bot_messages['errors']['invalid_alpha-2_code'])
@bot.command(name='top', help="Sends you Steam Top Sellers in a specific region or country.")
async def send_steam_top_sellers(ctx, alpha2_code='US'):
if is_valid_alpha2_code(string=alpha2_code):
try:
embed_msg = steam_offers_dispatcher(action_type='SEND_TOP_SELLERS', payload={
'alpha2_code': alpha2_code})
await ctx.reply(embed=embed_msg)
except:
await ctx.reply(bot_messages['errors']['fetch_data_error'])
else:
await ctx.reply(bot_messages['errors']['invalid_alpha-2_code'])
@bot.command(name='details', help='Sends you info about an app data on Steam.')
async def send_app_details(ctx, app_id, alpha2_code='US'):
if is_valid_alpha2_code(string=alpha2_code):
try:
embed_msg = steam_offers_dispatcher(action_type='SEND_APP_DETAILS', payload={
'app_id': app_id, 'alpha2_code': alpha2_code})
await ctx.reply(embed=embed_msg)
except:
await ctx.reply(bot_messages['errors']['fetch_data_error'])
else:
await ctx.reply(bot_messages['errors']['invalid_alpha-2_code'])
@bot.command(name='about', help='Sends you helpful information about the bot and its available commands.')
async def send_about_message(ctx):
try:
embed_msg = discord.Embed(title=' ', description=bot_messages['about'])
await ctx.reply(embed=embed_msg)
except:
await ctx.reply(bot_messages['errors']['fetch_data_error'])
bot.run(token=DISCORD_BOT_TOKEN)