drpg-warden/drpg.py

81 lines
3.1 KiB
Python
Raw Permalink Normal View History

2018-08-26 11:00:22 +12:00
import discord
from discord.ext import commands
import asyncio
from utils import read_adv, read_stats
2018-08-26 11:00:22 +12:00
class drpg:
def __init__(self, bot):
self.bot = bot
@commands.command(pass_context=True)
async def adv(self, ctx):
await asyncio.sleep(14)
await self.bot.say(f'🗺️ {ctx.message.author.mention} you can '
f'**{ctx.prefix}adv** again')
@commands.command(pass_context=True)
async def mine(self, ctx):
await asyncio.sleep(300)
await self.bot.say(f'⛏️ {ctx.message.author.mention} you can '
f'**{ctx.prefix}mine** again')
@commands.command(pass_context=True)
async def chop(self, ctx):
await asyncio.sleep(300)
await self.bot.say(f'🌲 {ctx.message.author.mention} you can '
f'**{ctx.prefix}chop** again')
@commands.command(pass_context=True)
async def fish(self, ctx):
await asyncio.sleep(300)
await self.bot.say(f'🎣 {ctx.message.author.mention} you can '
f'**{ctx.prefix}fish** again')
@commands.command(pass_context=True)
async def forage(self, ctx):
await asyncio.sleep(300)
await self.bot.say(f'🍋 {ctx.message.author.mention} you can '
f'**{ctx.prefix}forage** again')
@commands.command(pass_context=True)
async def search(self, ctx):
await asyncio.sleep(600)
await self.bot.say(f'🔍 {ctx.message.author.mention} you can '
f'**{ctx.prefix}search** again')
2018-10-08 16:54:08 +13:00
@commands.command(pass_context=True)
async def catch(self, ctx):
await asyncio.sleep(10)
await self.bot.say(f'🐥 {ctx.message.author.mention} you can '
f'**{ctx.prefix}catch** again')
2018-08-26 11:00:22 +12:00
async def on_message(self, message: discord.Message):
if message.author.id == '170915625722576896':
2019-07-20 15:47:29 +12:00
if message.content.startswith('```diff\n!======['):
2018-08-26 11:00:22 +12:00
try:
usr, hp = read_adv(message.content)
2018-08-26 11:14:25 +12:00
if hp <= 20:
2018-08-26 11:00:22 +12:00
usr = message.server.get_member_named(usr)
msg = f"❤️ **Heal up!** {usr.mention} you only have "\
f"{hp:.2f}% HP left."
await self.bot.send_message(message.channel, msg)
except Exception as e:
raise
elif message.content.startswith('```diff\n!======== ['):
try:
out = read_stats(message.content)
if out is not None:
await self.bot.send_message(message.channel, out)
except Exception:
pass
elif message.server.me in message.mentions and \
'prefix' in message.content.lower():
m1 = '**The prefix for this server is currently set to:** {}'
m2 = m1.format(str(self.bot.command_prefix(self.bot, message)))
await self.bot.send_message(message.channel, m2)
def setup(bot):
bot.add_cog(drpg(bot))