-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.py
More file actions
28 lines (23 loc) · 994 Bytes
/
main.py
File metadata and controls
28 lines (23 loc) · 994 Bytes
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
import json
import discord
from discord.ext import commands
from calcs import process_inputs
with open('secrets.json') as fin:
secrets = json.load(fin)
bot = commands.Bot(command_prefix='!', help_command=None)
@bot.command(name="whenrating")
async def whenrating(ctx, name, rating, variant="Rapid"):
error_bool, error_msg, prob_success, predicted_date = await process_inputs(name,rating,variant)
# Error that is so severe that no prediction is generated
if error_bool and prob_success is None:
await ctx.send(error_msg)
else:
msg = ""
# Warning, there's something concerning but we can still display a prediction
if error_bool:
msg += error_msg + '\n'
msg += f"{name}'s chance of reaching {rating} {variant.title()} within 2 years: **{prob_success}%**"
if prob_success > 5:
msg += f"\nExpected date: **{predicted_date}**."
await ctx.send(msg)
bot.run(secrets.get('discord-token'))