Skip to content

Commit

Permalink
Merge pull request #266 from hitblast/main
Browse files Browse the repository at this point in the history
🔨 [tuning] Restart development on IgKnite
  • Loading branch information
hitblast authored Aug 23, 2024
2 parents 2d07b53 + 9d05901 commit 485d231
Show file tree
Hide file tree
Showing 25 changed files with 1,631 additions and 227 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
"image": "mcr.microsoft.com/devcontainers/python:0-3.11",
"postCreateCommand": "sudo apt update && sudo apt install -y --no-install-recommends ffmpeg && pip install -U pip && pip install -r requirements.txt && pip install ruff",
"image": "mcr.microsoft.com/devcontainers/python:3.12",
"postCreateCommand": "sudo apt update && sudo apt install -y --no-install-recommends ffmpeg python3-poetry && python -m venv venv && . venv/bin/activate && poetry install --no-root --sync --all-extras",
"customizations": {
"vscode": {
"extensions": [
Expand Down
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
context: .
push: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- name: Create pull request
if: steps.formatcheck.outcome != 'success'
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "🎨 Automated formatting errors fix"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- name: Create pull request
if: steps.lintcheck.outcome != 'success'
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "🎨 Automated linting errors fix"
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# SPDX-License-Identifier: MIT

# Set image version and type.
FROM python:3.11
FROM python:3.12

# Copy project files and set working directory.
WORKDIR /igknite
COPY . /igknite/
RUN pip install --no-cache-dir -r requirements.txt

# Set proper frontend for Debian and install external dependencies.
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y --no-install-recommends ffmpeg
RUN apt update && apt install -y --no-install-recommends ffmpeg python3-poetry
RUN poetry install --sync --no-root
RUN rm -rf /var/lib/apt/lists/*

# Real-time project view.
ENV PYTHONUNBUFFERED 1

# Run.
CMD [ "python", "main.py" ]
CMD [ "poetry", "run", "python", "main.py" ]
51 changes: 28 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# IgKnite

<!-- a table below -->
> 🌇 As of 24th February 2024, we have decided to **sunset IgKnite.** It might sound unexpectedly straightforward, but we've taken this decision so that we can take the experience we've gained while building this awesome project and apply it to something that'd carry on it's legacy. It has been a very nice journey, and hopefully you'll stay around for updates. Something's on the way!
<img src="https://img.shields.io/github/license/IgKniteDev/IgKnite?color=black&logo=github&style=for-the-badge">
<a aria-label="Inject to your Discord server" href="https://discord.com/oauth2/authorize?client_id=1274430156928319489" target="_blank">
<img src="https://img.shields.io/badge/-Inject%20to%20Server-black?style=for-the-badge&logo=Discord">
</a>

<br> <img src="static/banner.png">

Expand All @@ -20,39 +21,43 @@

</div>

---
## 📌 Table of Contents

## Table of Contents
- [Overview](#-overview)
- [Features](#️-features)
- [Usage](#-usage)
- [Contributing](#-contributing)

- [Mission](#⚔️-our-mission)
- [Features](#🗡-features)
- [Usage](#📝-usage)
- [Contributing](#🔨-contributing)
- [License](#🔖-license)
---

## ⚔️ Mission
## ⚡ Overview

Most Discord bots these days are closed-source and incomplete. This is due to every developer having specific goals on what to make with Discord's API. Thus, there has recently not been a fully open-sourced approach to creating Discord bots that are both easy to access and stable at the frontend.
Most Discord bots available to the end-users nowadays are either built to be a jack-of-all-trades or are too specific to a particular niche. IgKnite is a Discord bot that aims to be the middle ground between these two extremes. It is a bot that is designed to be a playground for creative commands, while also providing a polished experience for moderation and music commands.

Our mission with IgKnite is to fulfill that gap. Meaning that, we're creating a Discord bot that is aimed at both the moderators of Discord servers and the casual, everyday users. We aim to make the moderation experience easier with simple yet stable, fail-safe commands while also entertaining users with music and a handful of easily accessible commands. All of this while also keeping this project **open-source and free forever!**<br>
IgKnite is built on top of the [disnake](https://github.com/DisnakeDev/disnake) API wrapper for Discord, and is easily self-hostable to the point where you can easily run it on your local computer. The bot's codebase is asynchronous and easily extendable since it's made fully open-source. <br>

## Features
## ⚔️ Features

- Moderation commands, made creative and easy.
- Low-level & polished music system (support for both YouTube & Spotify).
- Asynchronous code on top of the [disnake](https://github.com/DisnakeDev/disnake) API wrapper.
- A playground all by itself for creative commands.
- Fully open-source including assets.
- Battle-tested moderation commands for stable community moderation.
- Low-level & polished music system (YouTube + Spotify) for everyday use.
- Both developer and user friendly at once.
- Fully open-sourced with love (including assets!).
- No buzz, all buff! <br>

## 📝 Usage
## 🚀 Usage

IgKnite has its own [documentation webpage](https://igknitedev.github.io/docs) where you can learn about everything, starting from the commands to even self-hosting the bot on your local computer. <br>
- **Invite the bot to your server:** [Click here!](https://discord.com/oauth2/authorize?client_id=1274430156928319489)
- **Look at the documentation:** [Click here!](https://igknitedev.github.io/docs/)
- Voila! You're all set to use the bot! <br>

## 🔨 Contributing

If you'd like to add your own features to this project, consider having a look at the [contribution guidelines.](./.github/CONTRIBUTING.md) It contains all the critical information for you to hack and deploy! The official documentation for IgKnite, as hyperlinked in the previous section, also has similar text (possibly more) written within to help you understand the core functionalities of the project. We're eagerly waiting for your contribution! :D <br>

## 🔖 License
---

<div align="center">

### 🪄 Star the project if you like it! :D 🌟

Licensed under the [MIT License](LICENSE).
</div>
72 changes: 54 additions & 18 deletions cogs/customization.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ class Customization(commands.Cog):
def __init__(self, bot: core.IgKnite) -> None:
self.bot = bot

async def cog_before_slash_command_invoke(self, inter: disnake.CommandInter) -> None:
async def cog_before_slash_command_invoke(
self, inter: disnake.CommandInter
) -> None:
return await inter.response.defer(ephemeral=True)

# makerole
Expand All @@ -59,10 +61,15 @@ async def _makerole(
self,
inter: disnake.CommandInter,
name: str = Param(description='Give a name for the new role.'),
color: str = Param(description='Give a color for the new role in Hex.', default='#000000'),
color: str = Param(
description='Give a color for the new role in Hex.',
default='#000000',
),
) -> None:
color = get_color(color)
embed = core.TypicalEmbed(description=f'Role `{name}` has been created.')
embed = core.TypicalEmbed(
description=f'Role `{name}` has been created.'
)

await inter.guild.create_role(name=name, color=color)
await inter.send(embed=embed)
Expand All @@ -77,14 +84,22 @@ async def _makerole(
async def _assignrole(
self,
inter: disnake.CommandInter,
member: disnake.Member = Param(description='Mention the server member.'),
role: disnake.Role = Param(description='Mention the role to assign to the user.'),
member: disnake.Member = Param(
description='Mention the server member.'
),
role: disnake.Role = Param(
description='Mention the role to assign to the user.'
),
) -> None:
if role in member.roles:
return await inter.send('The member already has this role.', ephemeral=True)
return await inter.send(
'The member already has this role.', ephemeral=True
)

await member.add_roles(role)
await inter.send(f'Role {role.mention} has been assigned to **{member.display_name}**!')
await inter.send(
f'Role {role.mention} has been assigned to **{member.display_name}**!'
)

# unassignrole
@commands.slash_command(
Expand All @@ -96,14 +111,22 @@ async def _assignrole(
async def _unassignrole(
self,
inter: disnake.CommandInter,
member: disnake.Member = Param(description='Mention the server member.'),
role: disnake.Role = Param(description='Mention the role to remove from the user.'),
member: disnake.Member = Param(
description='Mention the server member.'
),
role: disnake.Role = Param(
description='Mention the role to remove from the user.'
),
) -> None:
if role not in member.roles:
return await inter.send("The member doesn't has this role.", ephemeral=True)
return await inter.send(
"The member doesn't has this role.", ephemeral=True
)

await member.remove_roles(role)
await inter.send(f'Role {role.mention} has been removed from **{member.display_name}**!')
await inter.send(
f'Role {role.mention} has been removed from **{member.display_name}**!'
)

# removerole
@commands.slash_command(
Expand Down Expand Up @@ -144,7 +167,8 @@ async def _makeinvite(
min_value=1,
),
reason: str = Param(
description='Give a reason for creating the invite.', default='No reason provided.'
description='Give a reason for creating the invite.',
default='No reason provided.',
),
) -> None:
invite = await inter.channel.create_invite(
Expand Down Expand Up @@ -173,11 +197,17 @@ async def _makeinvite(
async def _nick(
self,
inter: disnake.CommandInter,
member: disnake.Member = Param(description='Mention the server member.'),
nickname: str = Param(description='Give the nickname to set for the mentioned user.'),
member: disnake.Member = Param(
description='Mention the server member.'
),
nickname: str = Param(
description='Give the nickname to set for the mentioned user.'
),
) -> None:
await member.edit(nick=nickname)
await inter.send(f'Member {member.mention} has been nicked to **{nickname}**!')
await inter.send(
f'Member {member.mention} has been nicked to **{nickname}**!'
)

# slowmode
@commands.slash_command(
Expand All @@ -201,7 +231,9 @@ async def _slowmode(
if duration == 0:
await inter.send('Slowmode has been disabled!')
else:
await inter.send(f'Slowmode has been set to **{duration}** seconds.')
await inter.send(
f'Slowmode has been set to **{duration}** seconds.'
)

# makechannel
@commands.slash_command(
Expand All @@ -219,7 +251,9 @@ async def _makechannel(
default=None,
channel_types=[ChannelType.category],
),
topic: str = Param(description='Give a topic for the new channel.', default=None),
topic: str = Param(
description='Give a topic for the new channel.', default=None
),
slowmode: int = Param(
description='The amount of seconds to set the slowmode to. Default is 0.',
default=0,
Expand Down Expand Up @@ -334,7 +368,9 @@ async def _removechannel(

# reset
@commands.slash_command(
name='reset', description='Resets the current channel.', dm_permission=False
name='reset',
description='Resets the current channel.',
dm_permission=False,
)
@commands.has_role(LockRoles.admin)
async def _reset(self, inter: disnake.CommandInter) -> None:
Expand Down
16 changes: 12 additions & 4 deletions cogs/exceptionhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def get_view(self, inter: disnake.CommandInter) -> core.SmallView:
)
return view

async def process_error(self, inter: disnake.CommandInter, error: Any) -> None:
async def process_error(
self, inter: disnake.CommandInter, error: Any
) -> None:
"""
A method for processing the exceptions caused in interaction commands and responding
accordingly.
Expand Down Expand Up @@ -53,15 +55,21 @@ async def process_error(self, inter: disnake.CommandInter, error: Any) -> None:
await inter.send(embed=embed, view=self.get_view(inter), ephemeral=True)

@commands.Cog.listener()
async def on_slash_command_error(self, inter: disnake.CommandInter, error: Any) -> None:
async def on_slash_command_error(
self, inter: disnake.CommandInter, error: Any
) -> None:
await self.process_error(inter, error)

@commands.Cog.listener()
async def on_user_command_error(self, inter: disnake.CommandInter, error: Any) -> None:
async def on_user_command_error(
self, inter: disnake.CommandInter, error: Any
) -> None:
await self.process_error(inter, error)

@commands.Cog.listener()
async def on_message_command_error(self, inter: disnake.CommandInter, error: Any) -> None:
async def on_message_command_error(
self, inter: disnake.CommandInter, error: Any
) -> None:
await self.process_error(inter, error)


Expand Down
Loading

0 comments on commit 485d231

Please sign in to comment.