100 lines
4.2 KiB
Python
100 lines
4.2 KiB
Python
import discord
|
|
from discord.ext import commands
|
|
import asyncio
|
|
from utils import read_adv, read_stats, read_travel, DEST_RE
|
|
|
|
|
|
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.embeds != []:
|
|
try:
|
|
user, destinations = read_travel(**message.embeds[0])
|
|
print(user)
|
|
def travel_check(message):
|
|
return message.author.id == '170915625722576896' and \
|
|
message.content.startswith(user)
|
|
travel = await self.bot.wait_for_message(timeout=30,
|
|
check=travel_check,
|
|
channel=message.channel)
|
|
user = message.server.get_member_named(user)
|
|
if travel is not None:
|
|
destination = DEST_RE.search(travel.content) \
|
|
.groups(0)[0]
|
|
await asyncio.sleep(destinations[destination])
|
|
m = f'{user.mention} you have arived at {destination}'
|
|
await self.bot.send_message(message.channel, m)
|
|
except Exception:
|
|
raise
|
|
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))
|