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
|
import discord, typing, config
from discord.ext import commands
class Explored(commands.Cog):
"""
Explored commands
"""
def __init__(self, bot):
self.bot = bot
async def chancheck(ctx):
if ctx.channel.id == config.LOGCHAN_ID or commands.is_owner():
return True
@commands.command(name='explored',
brief="Explored stats",
help="Shows total world locations and how many have be explored.",
)
@commands.has_any_role(config.PLOC_CMD)
@commands.check(chancheck)
async def explored(self, ctx):
ldrembed = discord.Embed(title="World Explored Stats", color=0x33a163)
botsql = self.bot.get_cog('BotSQL')
mycursor = await botsql.get_cursor()
sql = """SELECT COUNT(*) FROM plocinfo WHERE locations IS NULL"""
mycursor.execute(sql)
Info = mycursor.fetchall()
sql1 = """SELECT locations FROM plocinfo WHERE locations IS NOT NULL LIMIT 1"""
mycursor.execute(sql1)
Info1 = mycursor.fetchall()
mycursor.close()
Info=Info[0]
Info1=Info1[0]
ldrembed.add_field(name="Total Locations",
value="{}".format(Info1[0]),
inline=True)
ldrembed.add_field(name="Locations Explored",
value="{}".format(Info[0]),
inline=True)
ldrembed.add_field(name="Percent of World Explored",
value="{}%".format(format(Info[0]/Info1[0]*100, ".2f")),
inline=True)
await ctx.send(embed=ldrembed)
@explored.error
async def explored_error_handler(self, ctx, error):
if isinstance(error, commands.MissingAnyRole):
if config.USEDEBUGCHAN == True:
bugchan = self.bot.get_channel(config.BUGCHANNEL_ID)
bugerror = discord.Embed(title=":sos: **ERROR** :sos:", description='**{}** Tried to use command: **{}**\n{}'.format(ctx.author, ctx.command, error), color=0xFF001E)
await bugchan.send(embed=bugerror)
if isinstance(error, commands.CheckFailure):
if config.USEDEBUGCHAN == True:
bugchan = self.bot.get_channel(config.BUGCHANNEL_ID)
bugerror = discord.Embed(title=":sos: **ERROR** :sos:", description='**{}** Tried to use command: **{}**\nIn channel **#{}**'.format(ctx.author, ctx.command, ctx.channel), color=0xFF001E)
await bugchan.send(embed=bugerror)
def setup(bot):
bot.add_cog(Explored(bot))
|