drpg-warden/drpg.py

81 lines
3.1 KiB
Python

import discord
from discord.ext import commands
import asyncio
from utils import read_adv, read_stats
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')
@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')
async def on_message(self, message: discord.Message):
if message.author.id == '170915625722576896':
if message.content.startswith('```diff\n!======['):
try:
usr, hp = read_adv(message.content)
if hp <= 20:
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))