Compare commits

..

No commits in common. "8f74565abd80da2192d0c80491060d49d37d0629" and "70867e0d7e7ec24b01bf7a434c102bb64cd43b44" have entirely different histories.

8 changed files with 14 additions and 55 deletions

3
.gitignore vendored
View file

@ -1,2 +1 @@
/config.json
/data/
config.json

View file

@ -1,28 +0,0 @@
# Hrochobot
Discord bot for KSP discord server.
## Installation
First install all required libraries:
```sh
pip install -r requirements.txt
```
Then create ``data`` folder from ``data.example``:
```sh
cp data.example data -r
```
Same for ``config.json``:
```sh
cp config.example.json config.json -r
```
Lastly paste your discord bot token into ``config.json``.
If you do not have any discord bot, learn how to create one here:
https://discordjs.guide/preparations/setting-up-a-bot-application.html#your-bot-s-token
## Running
To run the bot simply execute ``main.py``:
```sh
./main.py
```

View file

@ -5,11 +5,11 @@ class Basic(commands.Cog):
def __init__(self, bot):
self.bot = bot
@discord.slash_command(description="Greets the world.")
@discord.slash_command()
async def sayhello(self, ctx):
await ctx.respond('Hello world!')
@discord.slash_command(description="Sends the bot's latency.")
@discord.slash_command()
async def ping(self, ctx):
await ctx.respond('My ping is {:.0f}ms'.format(self.bot.latency*1000), ephemeral=True)

View file

@ -6,8 +6,8 @@ class Ksp(commands.Cog):
def __init__(self, bot):
self.bot = bot
@discord.slash_command(description="Generates urls for given task.")
async def task(self, ctx, task_code: str):
@discord.slash_command()
async def task(self, ctx, task_code):
await ctx.respond(
f'**{task_code}**\n'
f'Task: {task_link(task_code, solution=False)}\n'
@ -15,7 +15,7 @@ class Ksp(commands.Cog):
ephemeral=True
)
@discord.slash_command(description="Shows deadlines of currently running series.")
@discord.slash_command()
async def deadlines(self, ctx):
a_deadlines = active_deadlines()
if len(a_deadlines) == 0:

View file

@ -11,14 +11,11 @@ class Roles(commands.Cog):
secret_roles = discord.SlashCommandGroup(
"secretroles",
"Commands for management of secret roles.",
checks=[commands.has_permissions(manage_roles=True)]
)
@secret_roles.command(description="Adds a new secret role.")
@discord.option("role", discord.role.Role, description="Role locked behind a password.")
@discord.option("password", str, description="Password for given role.")
async def add(self, ctx, role, password):
@secret_roles.command()
async def add(self, ctx, role: discord.role.Role, password: str):
roles = data.load_data(ROLES_JSON)
if password in roles["secret_roles"]:
return await ctx.respond(f"Password ``{password}`` is already used.", ephemeral=True)
@ -27,7 +24,7 @@ class Roles(commands.Cog):
data.dump_data(ROLES_JSON, roles)
return await ctx.respond(f"Secret role {role.mention} added with password {password}.", ephemeral=True)
@secret_roles.command(description="Lists all passwords and their secret roles")
@secret_roles.command()
async def list(self, ctx):
roles = data.load_data(ROLES_JSON)
if len(roles["secret_roles"]) == 0:
@ -38,9 +35,8 @@ class Roles(commands.Cog):
msg += f"``{passwd}``: {role.mention}\n"
return await ctx.respond(msg, ephemeral=True)
@secret_roles.command(description="Deletes given password and its secret role.")
@discord.option("password", str, description="Password to be deleted.")
async def delete(self, ctx, password):
@secret_roles.command()
async def delete(self, ctx, password: str):
roles = data.load_data(ROLES_JSON)
if password not in roles["secret_roles"]:
return await ctx.respond(f"Role with passowrd {password} does not exist.", ephemeral=True)
@ -53,9 +49,9 @@ class Roles(commands.Cog):
ephemeral=True
)
@discord.slash_command(description="Gives a secret role locked by a password.")
@discord.option("password", str, description="Password for secret role.")
async def secretrole(self, ctx, password):
@discord.slash_command()
async def secretrole(self, ctx, password: str):
roles = data.load_data(ROLES_JSON)
if password in roles["secret_roles"]:
author = ctx.author

View file

@ -1,3 +0,0 @@
{
"token": "Paste your token here."
}

View file

@ -1,3 +0,0 @@
{
"secret_roles": {}
}

View file

@ -1,2 +0,0 @@
py-cord
requests