aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxultist <xultist@proton.me>2023-02-24 10:08:55 +1100
committerxultist <xultist@proton.me>2023-02-24 10:08:55 +1100
commit8ddcf325bf753b402b7fc4687d9fce088f43499c (patch)
treefcd9c8c6905c02f9d8e4e2b3bf4fc8de2d6e0714
parent322d4fe6ed7d2aecee06c4c2e40b4cfe51d3d052 (diff)
Added a few things
Likely final commit
-rw-r--r--cogs/__pycache__/comic.cpython-310.pycbin2533 -> 0 bytes
-rw-r--r--cogs/__pycache__/fun.cpython-310.pycbin5396 -> 0 bytes
-rw-r--r--cogs/__pycache__/utils.cpython-310.pycbin8202 -> 0 bytes
-rw-r--r--cogs/fun.py3
-rw-r--r--cogs/syntax.py33
-rw-r--r--config.json4
-rw-r--r--main.py1
7 files changed, 33 insertions, 8 deletions
diff --git a/cogs/__pycache__/comic.cpython-310.pyc b/cogs/__pycache__/comic.cpython-310.pyc
deleted file mode 100644
index 212d4e7..0000000
--- a/cogs/__pycache__/comic.cpython-310.pyc
+++ /dev/null
Binary files differ
diff --git a/cogs/__pycache__/fun.cpython-310.pyc b/cogs/__pycache__/fun.cpython-310.pyc
deleted file mode 100644
index 9f6fd8c..0000000
--- a/cogs/__pycache__/fun.cpython-310.pyc
+++ /dev/null
Binary files differ
diff --git a/cogs/__pycache__/utils.cpython-310.pyc b/cogs/__pycache__/utils.cpython-310.pyc
deleted file mode 100644
index 8ab8b38..0000000
--- a/cogs/__pycache__/utils.cpython-310.pyc
+++ /dev/null
Binary files differ
diff --git a/cogs/fun.py b/cogs/fun.py
index 606cd56..ce16014 100644
--- a/cogs/fun.py
+++ b/cogs/fun.py
@@ -109,7 +109,8 @@ class Fun(commands.Cog, name="fun"):
@option("prompt", description="What you want GPT to say.")
@option("temperature", description="How random you want you response to be.")
async def gpt(self, ctx, prompt, temperature: float = 0.7):
- if ctx.channel.id != 1076703526404759602:
+ channel = discord.utils.get(self.bot.get_all_channels(), name='bot-cmds')
+ if ctx.channel != channel:
embed = discord.Embed(title="🛑 Wrong Channel!", description="To prevent spam, this command is limited to <#1076703526404759602>.")
await ctx.respond(embed=embed, ephemeral=True)
else:
diff --git a/cogs/syntax.py b/cogs/syntax.py
index c426c2e..7138319 100644
--- a/cogs/syntax.py
+++ b/cogs/syntax.py
@@ -1,4 +1,5 @@
import discord
+from discord import option
from discord.ext import commands
from discord.ext.commands import Context
from main import config
@@ -7,7 +8,7 @@ from pygments.token import *
from PIL import Image
from pygments import highlight
from pygments.lexers import get_lexer_by_name
-from pygments.styles.onedark import OneDarkStyle
+from pygments.styles import *
from pygments.formatters import ImageFormatter
import io
import secrets
@@ -37,10 +38,31 @@ class Syntax(commands.Cog, name="syntax"):
self.bot = bot
global color
+ global stylesList
color = int(config["bot_color"], base=16)
+ ## The actual list is far too long
+ stylesList = ['Default', 'Emacs', 'Friendly', 'Colorful', 'Autumn', 'Material', 'Monokai', 'Perldoc', 'Rrt', 'Xcode', 'Igor', 'Lovelace', 'Rainbow_dash', 'Zenburn', 'Gruvbox-dark', 'Gruvbox-light', 'Dracula', 'One-dark', 'Nord-darker', 'Github-dark']
+ async def styles(self, ctx: Context):
+ print(stylesList)
+ result = "A list of styles that you can use with `/holyc` are:\n"
+ for item in stylesList:
+ result += f"`{item}`, "
+ embed = discord.Embed(title="Available Styles", description=result)
+ await ctx.respond(embed=embed, ephemeral=True)
+
@discord.slash_command(guild_ids=config['main_guilds'], description="Converts your last message to HolyC Code")
- async def holyc(self, ctx):
+ @option("style", description="Picks the style to use. Otherwise leave blank for OneDark. (Hint: for a list run /styles)", choices=list(stylesList))
+ @option("delete", description="Whether or not your original message is deleted")
+ async def holyc(self, ctx: Context, style: str = None, delete: bool = True):
+ style = style.lower()
+ if style == None:
+ style = "github-dark"
+ try:
+ styleClass = get_style_by_name(style)
+ except ClassNotFound:
+ await ctx.respond(f"I cannot find the '{style}' style. You can obtain a list of avaliable styles with /styles.", ephemeral=True)
+
channel = ctx.channel
user: discord.Member = ctx.author
async for message in channel.history(limit=100):
@@ -50,7 +72,7 @@ class Syntax(commands.Cog, name="syntax"):
lexer = HolyCLexer()
formatter = ImageFormatter(font_name='JetBrainsMono-Medium.ttf', font_size=20, line_numbers=False,
- style=OneDarkStyle)
+ style=styleClass)
highlighted_code = highlight(code, lexer, formatter)
image_data = io.BytesIO(highlighted_code)
@@ -70,7 +92,8 @@ class Syntax(commands.Cog, name="syntax"):
embed = discord.Embed(title=f"HolyC Snippet", description=f"Requested by {user.mention}")
embed.set_footer(text="You can create your own HolyC snippets by sending code in chat and then typing /holyc.")
embed.set_image(url="attachment://image.png")
- await message.delete()
+ if delete == True:
+ await message.delete()
await ctx.respond(file=file, embed=embed)
break
@@ -82,4 +105,4 @@ class Syntax(commands.Cog, name="syntax"):
def setup(bot):
- bot.add_cog(Syntax(bot)) \ No newline at end of file
+ bot.add_cog(Syntax(bot))
diff --git a/config.json b/config.json
index bc60ae5..0cd48d6 100644
--- a/config.json
+++ b/config.json
@@ -14,8 +14,8 @@
"around in TempleOS"
],
"owners": [
- 922299510850486293,
- 1007410169145212958
+ 1074110616895238204,
+ 878313460960731147
],
"main_guilds": [
1076700215521837187
diff --git a/main.py b/main.py
index aa51faa..964c5ea 100644
--- a/main.py
+++ b/main.py
@@ -42,6 +42,7 @@ async def on_ready() -> None:
print(f"Python version: {platform.python_version()}")
print(f"Running on: {platform.system()} {platform.release()} ({os.name})")
print(f"Comics: {totalComics}")
+ print(f"Invite: https://discord.com/api/oauth2/authorize?client_id={bot.application_id}&permissions=137442487361&scope=bot%20applications.commands")
print("-------------------")
channel = bot.get_channel(1040394602710040677)
status_task.start()