playing: Add playing

Also this commit includes DRAM optimization (aka I sneakily cleaned
tomGER's code a bit)~
This commit is contained in:
Ave Ozkal 2018-12-23 20:36:40 +03:00
parent b67ddda4f1
commit 5d54ac7aec
No known key found for this signature in database
GPG key ID: 09356ABAA42C842B
4 changed files with 34 additions and 18 deletions

View file

@ -31,7 +31,7 @@ Based on https://gitlab.com/ao/dpybotbase
- [ ] Moderation: timelock (channel lockdown with time)
- [ ] Moderation: mute-unmute
- [ ] Moderation: mutetime
- [ ] Moderation: playing
- [x] Moderation: playing
- [ ] Moderation: botnickname
- [ ] Moderation: nickname
- [ ] Moderation: clear/purge

View file

@ -47,7 +47,7 @@ initial_extensions = ['cogs.common',
'cogs.meme']
bot = commands.Bot(command_prefix=get_prefix,
description=config.bot_description, pm_help=None)
description=config.bot_description, pm_help=True)
bot.log = log
bot.config = config

View file

@ -4,6 +4,7 @@ import discord
from discord.ext import commands
from data.errcodes import *
class Err:
"Everything related to Nintendo 3DS, Wii U and Switch error codes"
@ -12,26 +13,27 @@ class Err:
self.dds_re = re.compile(r'0\d{2}\-\d{4}')
self.wiiu_re = re.compile(r'1\d{2}\-\d{4}')
self.switch_re = re.compile(r'2\d{3}\-\d{4}')
print("Err has been loaded!")
@commands.command(aliases=["nxerr", "serr", "nin_err"])
async def err(self, ctx, err: str):
"""Searches for Nintendo 3DS, Switch and Wii U error codes!
Usage: .serr/.nxerr/.nin_err/.err <Error Code>"""
if self.dds_re.match(err): # 3DS - dds -> Drei DS -> Three DS
if self.dds_re.match(err): # 3DS - dds -> Drei DS -> Three DS
if err in dds_errcodes:
err_description = dds_errcodes[err]
else:
err_description = "It seems like your error code is unknown. You should report relevant details to <@141532589725974528> so it can be added to the bot."
err_description = "It seems like your error code is unknown. You should report relevant details to <@141532589725974528> (tomGER) so it can be added to the bot."
# Make a nice Embed out of it
embed = discord.Embed(title=err, url="https://www.youtube.com/watch?v=x3yXlomPCmU", description=err_description)
embed = discord.Embed(title=err,
url="https://www.youtube.com/watch?v=x3yXlomPCmU",
description=err_description)
embed.set_footer(text="Console: 3DS")
# Send message, crazy
await ctx.send(embed=embed)
elif err.startswith("0x"): # These are not similar to the other errors apperently ... ?
elif err.startswith("0x"): # These are not similar to the other errors apperently ... ?
derr = err[2:]
derr = derr.strip()
rc = int(derr, 16)
@ -51,8 +53,8 @@ class Err:
await ctx.send(embed=embed)
return
elif self.wiiu_re.match(err): # Wii U
module = err[2:3] # Is that even true, idk just guessing
elif self.wiiu_re.match(err): # Wii U
module = err[2:3] # Is that even true, idk just guessing
desc = err[5:8]
if err in wii_u_errors:
err_description = wii_u_errors[err]
@ -66,10 +68,10 @@ class Err:
embed.add_field(name="Description", value=desc, inline=True)
# Send message, crazy
await ctx.send(embed=embed)
await ctx.send(embed=embed)
if self.switch_re.match(err) or err.startswith("0x"): # Switch
if self.switch_re.match(err) or err.startswith("0x"): # Switch
if err.startswith("0x"):
err = err[2:]
errcode = int(err, 16)
@ -79,7 +81,7 @@ class Err:
module = int(err[0:4]) - 2000
desc = int(err[5:9])
errcode = (desc << 9) + module
str_errcode = '{:04}-{:04}'.format(module + 2000, desc)
# Searching for Modules in list
@ -109,8 +111,8 @@ class Err:
# Send message, crazy
await ctx.send(embed=embed)
elif err in switch_game_err: # Special Case Handling because Nintendo feels like its required to break their format lol
game,desc = switch_game_err[err].split(":")
elif err in switch_game_err: # Special Case Handling because Nintendo feels like its required to break their format lol
game, desc = switch_game_err[err].split(":")
embed = discord.Embed(title=err, url="https://www.youtube.com/watch?v=x3yXlomPCmU", description=desc)
embed.set_footer(text="Console: Switch")
@ -132,7 +134,7 @@ class Err:
await ctx.send(hex(errcode))
else:
await ctx.send("This doesn't follow the typical Nintendo Switch 2XXX-XXXX format!")
@commands.command(aliases=["h2e"])
async def hex2err(self, ctx, err: str):
"""Converts Nintendo Switch errors to hex
@ -143,9 +145,9 @@ class Err:
module = err & 0x1FF
desc = (err >> 9) & 0x3FFF
errcode = '{:04}-{:04}'.format(module + 2000, desc)
await ctx.send(errcode)
await ctx.send(errcode)
else:
await ctx.send("This doesn't look like typical hex!")
await ctx.send("This doesn't look like typical hex!")
def setup(bot):

View file

@ -92,6 +92,7 @@ class ModCog:
await modlog_channel.send(chan_message)
await ctx.send(f"{safe_name} is now b&. 👍")
@commands.guild_only()
@commands.bot_has_permissions(ban_members=True)
@commands.check(check_if_staff)
@commands.command()
@ -118,6 +119,7 @@ class ModCog:
modlog_channel = self.bot.get_channel(config.modlog_channel)
await modlog_channel.send(chan_message)
@commands.guild_only()
@commands.check(check_if_staff)
@commands.command()
async def userinfo(self, ctx, *, user: discord.Member):
@ -136,6 +138,18 @@ class ModCog:
f"color = {user.colour}\n"
f"top_role = {role}\n")
@commands.guild_only()
@commands.check(check_if_staff)
@commands.command(aliases=["setplaying", "setgame"])
async def playing(self, ctx, *, game: str = ""):
"""Sets the currently played game name, staff only.
Just send .playing to wipe the playing state."""
if game:
await self.bot.change_presence(activity=discord.Game(name=game))
else:
await self.bot.change_presence(activity=None)
def setup(bot):
bot.add_cog(ModCog(bot))