Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2 from DiamondIceNS/1.4
Browse files Browse the repository at this point in the history
1.4
  • Loading branch information
DiamondIceNS authored May 16, 2018
2 parents 1e702de + 1442c81 commit a3736c4
Show file tree
Hide file tree
Showing 11 changed files with 482 additions and 115 deletions.
Binary file added assets/disdain_for_jpegs.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 77 additions & 36 deletions commands/canvas.py

Large diffs are not rendered by default.

63 changes: 46 additions & 17 deletions commands/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
class Configuration:
def __init__(self, bot):
self.bot = bot
self.langs = {
'en-US': "English (US)",
'pt-BR': "Português (BR)",
}

@commands.group(name="alertchannel", invoke_without_command=True)
@commands.guild_only()
Expand All @@ -33,10 +37,10 @@ async def alertchannel_clear(self, ctx):

@commands.command()
@commands.guild_only()
async def setprefix(self, ctx, prefix):
async def prefix(self, ctx, prefix):
if not ctx.author.permissions_in(ctx.channel).administrator:
raise NoPermission
if len(prefix) > 10:
if len(prefix) > 5:
raise commands.BadArgument
sql.update_guild(ctx.guild.id, prefix=prefix)
await ctx.send(getlang(ctx.guild.id, "configuration.prefix_set").format(prefix))
Expand All @@ -53,42 +57,67 @@ async def autoscan(self, ctx):
sql.update_guild(ctx.guild.id, autoscan=0)
await ctx.send(getlang(ctx.guild.id, "configuration.autoscan_disabled"))

@commands.group(name="setdefaultcanvas", invoke_without_command=True)
@commands.group(name="canvas", invoke_without_command=True)
@commands.guild_only()
async def setdefaultcanvas(self, ctx):
await ctx.send(getlang(ctx.guild.id, "bot.error.no_subcommand"))
async def canvas(self, ctx):
g = sql.select_guild_by_id(ctx.guild.id)
c = {
'pixelcanvas': 'Pixelcanvas.io',
'pixelzio': 'Pixelz.io',
'pixelzone': 'Pixelzone.io',
'pxlsspace': 'Pxls.space'
}[g['default_canvas']]
await ctx.send(getlang(ctx.guild.id, "configuration.canvas_check").format(c, g['prefix']))

@setdefaultcanvas.command(name="pixelcanvas")
@canvas.command(name="pixelcanvas", aliases=["pc"])
@commands.guild_only()
async def setdefaultcanvas_pixelcanvas(self, ctx):
async def canvas_pixelcanvas(self, ctx):
if not ctx.author.permissions_in(ctx.channel).administrator:
raise NoPermission
sql.update_guild(ctx.guild.id, default_canvas="pixelcanvas")
await ctx.send(getlang(ctx.guild.id, "configuration.default_canvas_set").format("Pixelcanvas.io"))
await ctx.send(getlang(ctx.guild.id, "configuration.canvas_set").format("Pixelcanvas.io"))

@setdefaultcanvas.command(name="pixelzio")
@canvas.command(name="pixelzio", aliases=["pzi"])
@commands.guild_only()
async def setdefaultcanvas_pixelzio(self, ctx):
async def canvas_pixelzio(self, ctx):
if not ctx.author.permissions_in(ctx.channel).administrator:
raise NoPermission
sql.update_guild(ctx.guild.id, default_canvas="pixelzio")
await ctx.send(getlang(ctx.guild.id, "configuration.default_canvas_set").format("Pixelz.io"))
await ctx.send(getlang(ctx.guild.id, "configuration.canvas_set").format("Pixelz.io"))

@setdefaultcanvas.command(name="pixelzone")
@canvas.command(name="pixelzone", aliases=["pz"])
@commands.guild_only()
async def setdefaultcanvas_pixelzone(self, ctx):
async def canvas_pixelzone(self, ctx):
if not ctx.author.permissions_in(ctx.channel).administrator:
raise NoPermission
sql.update_guild(ctx.guild.id, default_canvas="pixelzone")
await ctx.send(getlang(ctx.guild.id, "configuration.default_canvas_set").format("Pixelzone.io"))
await ctx.send(getlang(ctx.guild.id, "configuration.canvas_set").format("Pixelzone.io"))

@setdefaultcanvas.command(name="pxlsspace")
@canvas.command(name="pxlsspace", aliases=["ps"])
@commands.guild_only()
async def setdefaultcanvas_pxlsspace(self, ctx):
async def canvas_pxlsspace(self, ctx):
if not ctx.author.permissions_in(ctx.channel).administrator:
raise NoPermission
sql.update_guild(ctx.guild.id, default_canvas="pxlsspace")
await ctx.send(getlang(ctx.guild.id, "configuration.default_canvas_set").format("Pxls.space"))
await ctx.send(getlang(ctx.guild.id, "configuration.canvas_set").format("Pxls.space"))

@commands.command()
@commands.guild_only()
async def language(self, ctx, option=None):
if not option:
lang_list = ""
for i, (code, name) in enumerate(self.langs.items(), 1):
lang_list = lang_list + "{0} - {1}".format(code, name)
if i < len(self.langs):
lang_list = lang_list + "\n"
current_lang = self.langs[sql.get_guild_language(ctx.guild.id)]
await ctx.send(getlang(ctx.guild.id, "configuration.language_check").format(lang_list, current_lang))
return
if option not in self.langs:
await ctx.send(getlang(ctx.guild.id, "configuration.language_invalid"))
return
sql.update_guild(ctx.guild.id, language=option)
await ctx.send(getlang(ctx.guild.id, "configuration.language_set").format(self.langs[option]))


def setup(bot):
Expand Down
20 changes: 6 additions & 14 deletions glimmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,10 @@ async def on_command_error(ctx, error):
await ctx.send(getlang(ctx.guild.id, "bot.error.command_on_cooldown").format(error.retry_after))
return
if isinstance(error, commands.CommandNotFound):
# await ctx.send(getlang(ctx.guild.id, "bot.error.command_not_found").format(get_prefix(bot, ctx.message)))
return
if isinstance(error, commands.MissingRequiredArgument):
pages = bot.formatter.format_help_for(ctx, ctx.command)
print(pages)
for p in pages:
await ctx.send(p)
return
if isinstance(error, commands.BadArgument):
pages = bot.formatter.format_help_for(ctx, ctx.command)
for p in pages:
await ctx.send(p)
return
if isinstance(error, NoPermission):
await ctx.send(getlang(ctx.guild.id, "bot.error.no_permission"))
Expand Down Expand Up @@ -198,7 +190,7 @@ async def ping(ctx):
ping_start = time()
ping_msg = await ctx.send(getlang(ctx.guild.id, "bot.ping"))
ping_time = time() - ping_start
await ping_msg.edit(content=getlang(ctx.guild.id, "bot.pong").format(ping_time))
await ping_msg.edit(content=getlang(ctx.guild.id, "bot.pong").format(int(ping_time*1000)))


@bot.command()
Expand Down Expand Up @@ -226,30 +218,30 @@ async def suggest(ctx, *, suggestion: str):

@bot.group(name="ditherchart", invoke_without_command=True)
async def ditherchart(ctx):
await ctx.send(getlang(ctx.guild.id, "bot.error.no_subcommand"))
pass


@ditherchart.command(name="pixelcanvas")
async def ditherchart_pixelcanvas(ctx):
f = discord.File("assets/dither_chart_pixelcanvas.png", "assets/dither_chart_pixelcanvas.png")
f = discord.File("assets/dither_chart_pixelcanvas.png", "dither_chart_pixelcanvas.png")
await ctx.send(file=f)


@ditherchart.command(name="pixelzio")
async def ditherchart_pixelzio(ctx):
f = discord.File("assets/dither_chart_pixelzio.png", "assets/dither_chart_pixelzio.png")
f = discord.File("assets/dither_chart_pixelzio.png", "dither_chart_pixelzio.png")
await ctx.send(file=f)


@ditherchart.command(name="pixelzone")
async def ditherchart_pixelzio(ctx):
f = discord.File("assets/dither_chart_pixelzone.png", "assets/dither_chart_pixelzone.png")
f = discord.File("assets/dither_chart_pixelzone.png", "dither_chart_pixelzone.png")
await ctx.send(file=f)


@ditherchart.command(name="pxlsspace")
async def ditherchart_pixelzio(ctx):
f = discord.File("assets/dither_chart_pxlsspace.png", "assets/dither_chart_pxlsspace.png")
f = discord.File("assets/dither_chart_pxlsspace.png", "dither_chart_pxlsspace.png")
await ctx.send(file=f)


Expand Down
89 changes: 49 additions & 40 deletions lang/en_US.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Let's get pixel painting!""",
"bot.help_ending_note": "Type '{0}{1} <command>' for more info on a command.",
"bot.ping": "Pinging...",
"bot.pong": "Pong! | **{0:.01f}s**",
"bot.pong": "Pong! | **{0}ms**",
"bot.suggest": "Your suggestion has been sent. Thank you for your input!",
"bot.version": "My version number is **{0}**",

Expand All @@ -29,18 +29,21 @@
"configuration.alert_channel_set": "Alert channel has been set to {0}.",
"configuration.autoscan_disabled": "Autoscan has been disabled.",
"configuration.autoscan_enabled": "Autoscan has been enabled.",
"configuration.default_canvas_set": "Default canvas has been set to **{0}**.",
"configuration.canvas_check": "This guild's default canvas is **{0}**.\n"
"To change the default canvas, run this command again with a supported canvas. (Use `{1}help canvas` to see a list.)",
"configuration.canvas_set": "Default canvas has been set to **{0}**.",
"configuration.language_check": "This guild's current language is **{1}**.\n"
"To set a new language, run this command again with one of the following options:\n"
"```{0}```",
"configuration.language_set": "Language has been set to **English (US)**.",
"configuration.prefix_set": "Prefix for this guild has been set to **{0}**.",

# Error messages
"bot.error.bad_png": "This image seems to be corrupted. Try re-saving it with an image editor or using `{0}{1}`.",
"bot.error.command_not_found": "That is not a valid command. Use {0}help to see my commands.",
"bot.error.bad_png": "This image seems to be corrupted. Try re-saving it with an image editor or using `{0}quantize`.",
"bot.error.command_on_cooldown": "That command is on cooldown. Try again in {0:.01f}s.",
"bot.error.missing_attachment": "That command requires an attachment.",
"bot.error.no_canvas": "That command requires a subcommand.",
"bot.error.no_permission": "You do not have permission to use that command.",
"bot.error.no_png": "That command requires a PNG image.",
"bot.error.no_subcommand": "That command needs a subcommand. See the help for this command for a list of subcommands.",
"bot.error.jpeg": "Seriously? A JPEG? Gross! Please create a PNG template instead.",
"bot.error.no_private_message": "That command only works in guilds.",
"bot.error.unhandled_command_error": "An error occurred with that command. The dev has been notified.",
Expand All @@ -50,6 +53,11 @@
"brief.alertchannel.clear": "Clears the alert channel.",
"brief.alertchannel.set": "Sets the alert channel.",
"brief.autoscan": "Toggles automatic preview and diff.",
"brief.canvas": "Sets the default canvas website for this guild.",
"brief.canvas.pixelcanvas": "Sets the default canvas to Pixelcanvas.io.",
"brief.canvas.pixelzio": "Sets the default canvas to Pixelz.io.",
"brief.canvas.pixelzone": "Sets the default canvas to Pixelzone.io.",
"brief.canvas.pxlsspace": "Sets the default canvas to Pxls.space.",
"brief.changelog": "Gets a link to my releases page.",
"brief.diff": "Checks completion status of a template on a canvas.",
"brief.diff.pixelcanvas": "Creates a diff using Pixelcanvas.io.",
Expand All @@ -65,8 +73,10 @@
"brief.gridify": "Adds a grid to a template.",
"brief.help": "Displays this message.",
"brief.invite": "Gets my invite link.",
"brief.language": "Sets my language.",
"brief.listemotes": "Lists all the animated emoji that I know about.",
"brief.ping": "Pong!",
"brief.prefix": "Sets my command prefix for this guild.",
"brief.preview": "Previews the canvas at a given coordinate.",
"brief.preview.pixelcanvas": "Creates a preview using Pixelcanvas.io.",
"brief.preview.pixelzio": "Creates a preview using Pixelz.io.",
Expand All @@ -80,12 +90,6 @@
"brief.register": "Toggles animated emoji replacement for a user.",
"brief.registerguild": "Toggles emoji sharing for this guild.",
"brief.repeat": "Repeats the last used canvas command.",
"brief.setdefaultcanvas": "Sets the default canvas website for this guild.",
"brief.setdefaultcanvas.pixelcanvas": "Sets the default canvas to Pixelcanvas.io.",
"brief.setdefaultcanvas.pixelzio": "Sets the default canvas to Pixelz.io.",
"brief.setdefaultcanvas.pixelzone": "Sets the default canvas to Pixelzone.io.",
"brief.setdefaultcanvas.pxlsspace": "Sets the default canvas to Pxls.space.",
"brief.setprefix": "Sets my command prefix for this guild.",
"brief.suggest": "Sends a suggestion to the developer.",
"brief.version": "Gets my version number.",

Expand All @@ -106,6 +110,16 @@
See 'setdefaultcanvas' for more information about the default canvas.
Only users with the Administrator role can use this command.""",
"help.canvas":
"""The default canvas is the canvas that will be used for automatic previews or diffs triggered by autoscan. (See 'autoscan')
Defaults to Pixelcanvas.io.
This command can only be used by members with the Administrator permission.""",
"help.canvas.pixelcanvas": """This command can only be used by members with the Administrator permission.""",
"help.canvas.pixelzio": """This command can only be used by members with the Administrator permission.""",
"help.canvas.pixelzone": """This command can only be used by members with the Administrator permission.""",
"help.canvas.pxlsspace": """This command can only be used by members with the Administrator permission.""",
"help.changelog": None,
"help.diff":
"""Takes an uploaded template, compares it to the current state of the canvas, and calculates how complete it is. It will also generate an image showing you where the unfinished pixels are.
Expand All @@ -131,13 +145,20 @@
"""Takes an uploaded template and creates a gridded version for an easier reference. Use the 'size' parameter to set how large the individual pixels should be. (Default 1) You cannot zoom an image to be larger than 1000x1000.""",
"help.help": None,
"help.invite": None,
"help.language": """Use this command with no arguments to see the current and available languages.""",
"help.listemotes": """See 'registerserver' for more information about emoji sharing.""",
"help.ping": None,
"help.prefix":
"""Max length is 5 characters. You really shouldn't need more than 2.
This command can only be used by members with the Administrator permission.""",
"help.preview":
"""Given a coordinate pair or a URL, renders a live view of a canvas at those coordinates.
You can create a zoomed-in preview by adding a zoom factor. (i.e. "0, 0 #4") Maximum zoom is 16.
If you do not specify a canvas to use, the default canvas will be used.
If autoscan is enabled, this happens automatically using the default canvas. (See 'autoscan' and 'setdefaultcanvas')""",
"help.preview.pixelcanvas": None,
"help.preview.pixelzio": None,
Expand Down Expand Up @@ -166,20 +187,6 @@
This command can only be used by members with the Manage Emojis permission.""",
"help.repeat": "This command only applies to 'preview', 'diff', and their autoscan invocations. Only 50 messages back will be searched.",
"help.setdefaultcanvas":
"""The default canvas is the canvas that will be used for automatic previews or diffs triggered by autoscan. (See 'autoscan')
Defaults to Pixelcanvas.io.
This command can only be used by members with the Administrator permission.""",
"help.setdefaultcanvas.pixelcanvas": """This command can only be used by members with the Administrator permission.""",
"help.setdefaultcanvas.pixelzio": """This command can only be used by members with the Administrator permission.""",
"help.setdefaultcanvas.pixelzone": """This command can only be used by members with the Administrator permission.""",
"help.setdefaultcanvas.pxlsspace": """This command can only be used by members with the Administrator permission.""",
"help.setprefix":
"""Max length is 10 characters. You really shouldn't need more than 2.
This command can only be used by members with the Administrator permission.""",
"help.suggest": None,
"help.version": None,

Expand All @@ -188,6 +195,11 @@
"command.alertchannel.clear": "clear",
"command.alertchannel.set": "set",
"command.autoscan": "autoscan",
"command.canvas": "canvas",
"command.canvas.pixelcanvas": "pixelcanvas",
"command.canvas.pixelzio": "pixelzio",
"command.canvas.pixelzone": "pixelzone",
"command.canvas.pxlsspace": "pxlsspace",
"command.changelog": "changelog",
"command.diff": "diff",
"command.diff.pixelcanvas": "pixelcanvas",
Expand All @@ -203,8 +215,10 @@
"command.gridify": "gridify",
"command.help": "help",
"command.invite": "invite",
"command.language": "language",
"command.listemotes": "listemotes",
"command.ping": "ping",
"command.prefix": "prefix",
"command.preview": "preview",
"command.preview.pixelcanvas": "pixelcanvas",
"command.preview.pixelzio": "pixelzio",
Expand All @@ -218,12 +232,6 @@
"command.register": "register",
"command.registerguild": "registerguild",
"command.repeat": "repeat",
"command.setdefaultcanvas": "setdefaultcanvas",
"command.setdefaultcanvas.pixelcanvas": "pixelcanvas",
"command.setdefaultcanvas.pixelzio": "pixelzio",
"command.setdefaultcanvas.pixelzone": "pixelzone",
"command.setdefaultcanvas.pxlsspace": "pxlsspace",
"command.setprefix": "setprefix",
"command.suggest": "suggest",
"command.version": "version",

Expand All @@ -232,6 +240,11 @@
"signature.alertchannel.clear": "alertchannel clear",
"signature.alertchannel.set": "alertchannel set <channel>",
"signature.autoscan": "autoscan",
"signature.canvas": "canvas <canvas>",
"signature.canvas.pixelcanvas": "canvas [pixelcanvas|pc]",
"signature.canvas.pixelzio": "canvas [pixelzio|pzi]",
"signature.canvas.pixelzone": "canvas [pixelzone|pz]",
"signature.canvas.pxlsspace": "canvas [pxlsspace|ps]",
"signature.changelog": "changelog",
"signature.diff": "diff <subcommand>",
"signature.diff.pixelcanvas": "diff pixelcanvas <coordinates> (zoom)",
Expand All @@ -247,10 +260,12 @@
"signature.gridify": "gridify (size)",
"signature.help": "help",
"signature.invite": "invite",
"signature.language": "language (code)",
"signature.listemotes": "listemotes",
"signature.ping": "ping",
"signature.preview": "preview <subcommand>",
"signature.preview.pixelcanvas": "preview pixelcanvas <coordinates> (zoom)",
"signature.prefix": "prefix <prefix>",
"signature.preview": "[preview|p] (canvas) <coordinates> (zoom)",
"signature.preview.pixelcanvas": "[preview|p] [pixelcanvas|pc] <coordinates> (zoom)",
"signature.preview.pixelzio": "preview pixelzio <coordinates> (zoom)",
"signature.preview.pixelzone": "preview pixelzone <coordinates> (zoom)",
"signature.preview.pxlsspace": "preview pxlsspace <coordinates> (zoom)",
Expand All @@ -262,12 +277,6 @@
"signature.register": "register",
"signature.registerguild": "registerguild",
"signature.repeat": "repeat",
"signature.setdefaultcanvas": "setdefaultcanvas <subcommand>",
"signature.setdefaultcanvas.pixelcanvas": "setdefaultcanvas pixelcanvas",
"signature.setdefaultcanvas.pixelzio": "setdefaultcanvas pixelzio",
"signature.setdefaultcanvas.pixelzone": "setdefaultcanvas pixelzone",
"signature.setdefaultcanvas.pxlsspace": "setdefaultcanvas pxlsspace",
"signature.setprefix": "setprefix <prefix>",
"signature.suggest": "suggest <suggestion>",
"signature.version": "version",
}
Loading

0 comments on commit a3736c4

Please sign in to comment.