-
Notifications
You must be signed in to change notification settings - Fork 0
/
Conversions.py
91 lines (75 loc) · 2.78 KB
/
Conversions.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import discord
from discord.ext import commands
class Conversions(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.hybrid_command(
description= "Converts C to F."
)
async def tempc2f(self, ctx, temp: float):
await ctx.send(f"Temperature in F is {9 * temp/5 + 32}")
@commands.hybrid_command(
description= "Converts F to C."
)
async def tempf2c(self, ctx, temp : float):
await ctx.send(f"Temperature in C is {(temp-32)/9 * 5}")
@commands.hybrid_command(
description= "Converts kilogram to pounds."
)
async def wtkgtolb(self, ctx, mass : float):
await ctx.send(f"{mass * 2.205} lb")
@commands.hybrid_command(
description= "Converts kilogram to pounds."
)
async def wtlbtokg(self, ctx, mass : float):
await ctx.send(f"{mass / 2.205} kg")
@commands.hybrid_command(
description="Converts inches into centimeters."
)
async def lenintocm(self, ctx, length : float):
await ctx.send(f"{length * 2.5} cm")
@commands.hybrid_command(
description="Converts centimeters into inches."
)
async def lencmtoin(self, ctx, length : float):
await ctx.send(f"{length / 2.5} in")
@commands.hybrid_command(
description="Converts feet into cm."
)
async def lenintocm(self, ctx, length : float):
await ctx.send(f"{length * 2.5} cm")
@commands.hybrid_command(
description="Converts metres into yards."
)
async def lenmtoy(self, ctx, length : float):
await ctx.send(f"{length*1.094} yards")
@commands.hybrid_command(
description="Converts yards into metres."
)
async def lenytom(self, ctx, length : float):
await ctx.send(f"{length / 1.094} m")
@commands.hybrid_command(
description="Converts miles into kilometers."
)
async def lenmiltokm(self, ctx, length : float):
await ctx.send(f"{1.609 * length} km")
@commands.hybrid_command(
description= "Converts kilometers into miles."
)
async def lenkmtomil(self, ctx, length : float):
await ctx.send(f"{length / 1.609} mil")
@commands.hybrid_command(
description="Converts gallons into liters"
)
async def volgalltolit(self, ctx, volume : float):
await ctx.send(f"{3.785 * volume} L")
@commands.hybrid_command(
description="Converts liters into gallons"
)
async def vollittogall(self, ctx, volume : float):
await ctx.send(f"{3.785 * volume} gallons")
async def cog_command_error(self, ctx, error):
if isinstance(error, ValueError):
await ctx.send("That's a text, dummy. Send NUMBERS for measurements. **N U M B E R S**.")
async def setup(bot):
await bot.add_cog(Conversions(bot))