Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: intents error #27

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ COPY requirements.txt .

RUN pip install -r requirements.txt

CMD ["python", "nullctf.py"]
CMD ["python", "nullctf.py"]
36 changes: 20 additions & 16 deletions cogs/cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,42 @@
import discord
from discord.ext import commands

class Ciphers(commands.Cog):

class Ciphers(commands.Cog):
def __init__(self, bot):
self.bot = bot

@commands.command()
async def rot(self, ctx, message, direction=None):
# Bruteforce a rot cipher.
allrot = ''
allrot = ""

for i in range(0, 26):
upper = collections.deque(string.ascii_uppercase)
lower = collections.deque(string.ascii_lowercase)

upper.rotate((- i))
lower.rotate((- i))

upper = ''.join(list(upper))
lower = ''.join(list(lower))
translated = message.translate(str.maketrans(string.ascii_uppercase, upper)).translate(str.maketrans(string.ascii_lowercase, lower))
allrot += '{}: {}\n'.format(i, translated)


upper.rotate((-i))
lower.rotate((-i))

upper = "".join(list(upper))
lower = "".join(list(lower))
translated = message.translate(
str.maketrans(string.ascii_uppercase, upper)
).translate(str.maketrans(string.ascii_lowercase, lower))
allrot += "{}: {}\n".format(i, translated)

await ctx.send(f"```{allrot}```")

@commands.command()
async def atbash(self, ctx, message):
# Return the result of performing the atbash cipher on the message.
normal = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
changed = 'zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA'
normal = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
changed = "zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA"
trans = str.maketrans(normal, changed)
atbashed = message.translate(trans)
await ctx.send(atbashed)

def setup(bot):
bot.add_cog(Ciphers(bot))

async def setup(bot):
await bot.add_cog(Ciphers(bot))

49 changes: 32 additions & 17 deletions cogs/configuration.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import discord
from discord.ext import tasks, commands
import sys

sys.path.append("..")
from config_vars import *

# Extension for per-discord-server configuration.
# Configurations are logged in the database under the server id (right click on your server icon in discord dev mode).


class Configuration(commands.Cog):
def __init__(self, bot):
self.bot = bot
Expand All @@ -15,45 +17,58 @@ def __init__(self, bot):
async def config(self, ctx):
if ctx.invoked_subcommand is None:
# If the subcommand passed does not exist, its type is None
config_commands = list(set([c.qualified_name for c in Configuration.walk_commands(self)][1:]))
config_commands = list(
set([c.qualified_name for c in Configuration.walk_commands(self)][1:])
)
await ctx.send(f"Current config commands are: {', '.join(config_commands)}")

@commands.bot_has_permissions(manage_channels=True)
@commands.has_permissions(manage_channels=True)
@config.command()
async def ctf_category(self, ctx, category_name):
# Set the category that new ctf channels are created in by default.
category_name = category_name.replace("$", "")
category = discord.utils.get(ctx.guild.categories, name=category_name)

if category == None: # Checks if category exists, if it doesn't it will create it.

if (
category == None
): # Checks if category exists, if it doesn't it will create it.
await ctx.guild.create_category(name=category_name)
category = discord.utils.get(ctx.guild.categories, name=category_name)

sconf = serverdb[str(ctx.guild.id) + '-CONF'] # sconf means server configuration

sconf = serverdb[
str(ctx.guild.id) + "-CONF"
] # sconf means server configuration
info = {"ctf_category": category_name}
sconf.update({"name": 'category_name'}, {"$set": info}, upsert=True)
categoryset = sconf.find_one({'name': "category_name"})['ctf_category']
sconf.update({"name": "category_name"}, {"$set": info}, upsert=True)
categoryset = sconf.find_one({"name": "category_name"})["ctf_category"]
await ctx.send(f"CTF category set as `{categoryset}`")

@commands.bot_has_permissions(manage_channels=True)
@commands.has_permissions(manage_channels=True)
@config.command()
async def archive_category(self, ctx, category_name):
# Set the category that archived ctf channels are put in by default.
category_name = category_name.replace("$", "")
category = discord.utils.get(ctx.guild.categories, name=category_name)

if category == None: # Checks if category exists, if it doesn't it will create it.

if (
category == None
): # Checks if category exists, if it doesn't it will create it.
await ctx.guild.create_category(name=category_name)
category = discord.utils.get(ctx.guild.categories, name=category_name)

sconf = serverdb[str(ctx.guild.id) + '-CONF'] # sconf means server configuration

sconf = serverdb[
str(ctx.guild.id) + "-CONF"
] # sconf means server configuration
info = {"archive_category": category_name}
sconf.update({"name": 'archive_category_name'}, {"$set": info}, upsert=True)
categoryset = sconf.find_one({'name': "archive_category_name"})['archive_category']
sconf.update({"name": "archive_category_name"}, {"$set": info}, upsert=True)
categoryset = sconf.find_one({"name": "archive_category_name"})[
"archive_category"
]
await ctx.send(f"Archive category set as `{categoryset}`")


def setup(bot):
bot.add_cog(Configuration(bot))
async def setup(bot):
await bot.add_cog(Configuration(bot))

Loading