-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4db145f
Showing
11 changed files
with
967 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.env | ||
*.swp | ||
*.*~ | ||
project.lock.json | ||
.DS_Store | ||
*.pyc | ||
nupkg/ | ||
|
||
# Visual Studio Code | ||
.vscode | ||
|
||
# Rider | ||
.idea | ||
|
||
# User-specific files | ||
*.suo | ||
*.user | ||
*.userosscache | ||
*.sln.docstates | ||
|
||
# Build results | ||
[Dd]ebug/ | ||
[Dd]ebugPublic/ | ||
[Rr]elease/ | ||
[Rr]eleases/ | ||
x64/ | ||
x86/ | ||
build/ | ||
bld/ | ||
[Bb]in/ | ||
[Oo]bj/ | ||
[Oo]ut/ | ||
msbuild.log | ||
msbuild.err | ||
msbuild.wrn | ||
|
||
# Visual Studio 2015 | ||
.vs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Contribution Guidelines | ||
|
||
When contributing to this repository, please first discuss the change you wish to make by contacting one of the bot developers in the Discord server, or by creating a [discussion](https://github.com/oliverbooth/BrackeysBot/discussions) here in this repository. | ||
|
||
Please note we have a code of conduct, please follow it in all your interactions with the project. | ||
|
||
## Pull Request Process | ||
1. Update [README.md](README.md) outlining any necessary changes made to the project - do not leave this down to the repository owners. | ||
2. Do not increase any version numbers. This process is done by us when we feel it necessary to do so. | ||
3. This repository, and its child repositories, follow Microsoft's [C# coding conventions](https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions) and [.NET design guidelines](https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/). Please adhere to these conventions and guidelines. Pull requests which do not fall in line with the code style will be left open until this is adhered to (and may be closed at any time if we feel the changes will not be agreed upon.) | ||
|
||
## Code Style | ||
Where Microsoft's conventions do not suffice, an .editorconfig is provided in the repository which should integrate with Visual Studio or Rider to automate the process. This .editorconfig should roughly coincide with [StyleCop rules](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/tree/master/documentation), with some minor exceptions. | ||
|
||
### Comments | ||
**Please use comments sparingly!** The use of comments to outline what a particular block of code is doing is usually indicative of the code is not being clear enough in its own right. If you feel that a comment is required to clarify logic, consider refactoring the code to includes having meaningfully named variables and methods so that a comment is redundant. | ||
|
||
An example of comment types which would be unacceptable: | ||
```cs | ||
foreach (char character in someString) // loop through every char in the string | ||
{ | ||
Console.WriteLine(character); // print out each character on a new line | ||
} | ||
``` | ||
|
||
The exception to this is if the comment is explaining the "why" rather than the "what". A comment which outlines the rationale behind a specific solution is acceptable. For example: | ||
```cs | ||
for (var index = 0; index < someString.Length; index++) // cheaper than foreach, no allocation of CharEnumerator | ||
{ | ||
char character = someString[index]; | ||
Console.WriteLine(character); | ||
} | ||
``` | ||
In such a case, the comment is not explaining what the code does - but why it does it that way, rather than a different way. This type of comment is accepted and encouraged. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base | ||
WORKDIR /app | ||
|
||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build | ||
WORKDIR /src | ||
COPY ["Present/Present.csproj", "Present/"] | ||
RUN dotnet restore "Present/Present.csproj" | ||
COPY . . | ||
WORKDIR "/src/Present" | ||
RUN dotnet build "Present.csproj" -c Release -o /app/build | ||
|
||
FROM build AS publish | ||
RUN dotnet publish "Present.csproj" -c Release -o /app/publish | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
ENTRYPOINT ["dotnet", "Present.dll"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2022 Oliver Booth | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<h1 align="center">Present</h1> | ||
<p align="center"><img src="icon.png" width="128"></p> | ||
<p align="center"><i>A Discord bot for managing giveaways.</i></p> | ||
<p align="center"> | ||
<a href="https://github.com/BrackeysBot/Present/releases"><img src="https://img.shields.io/github/v/release/BrackeysBot/Present?include_prereleases"></a> | ||
<a href="https://github.com/BrackeysBot/Present/actions?query=workflow%3A%22.NET%22"><img src="https://img.shields.io/github/workflow/status/BrackeysBot/Present/.NET" alt="GitHub Workflow Status" title="GitHub Workflow Status"></a> | ||
<a href="https://github.com/BrackeysBot/Present/issues"><img src="https://img.shields.io/github/issues/BrackeysBot/Present" alt="GitHub Issues" title="GitHub Issues"></a> | ||
<a href="https://github.com/BrackeysBot/Present/blob/main/LICENSE.md"><img src="https://img.shields.io/github/license/BrackeysBot/Present" alt="MIT License" title="MIT License"></a> | ||
</p> | ||
|
||
## About | ||
Present is a Discord bot which manages giveaways in your server. It is capable of allowing multiple winners, as well as excluding specific users and roles form being able to win. | ||
|
||
## Installing and configuring Present | ||
Present runs in a Docker container, and there is a [docker-compose.yaml](docker-compose.yaml) file which simplifies this process. | ||
|
||
### Clone the repository | ||
To start off, clone the repository into your desired directory: | ||
```bash | ||
git clone https://github.com/BrackeysBot/Present.git | ||
``` | ||
Step into the Present directory using `cd Present`, and continue with the steps below. | ||
|
||
### Setting things up | ||
The bot's token is passed to the container using the `DISCORD_TOKEN` environment variable. Define this environment variable whichever way is most convenient for you. | ||
|
||
Two directories are required to exist for Docker compose to mount as container volumes. A folder for persistent data, and a folder for logs: | ||
```bash | ||
sudo mkdir /etc/brackeysbot/present | ||
sudo mkdir /var/log/brackeysbot/present | ||
``` | ||
Copy the example `config.example.json` to `/etc/brackeysbot/present/config.json`, and assign the necessary config keys. Below is breakdown of the config.json layout: | ||
```json | ||
{ | ||
"GUILD_ID": { | ||
"logChannel": /* The ID of the log channel */, | ||
"giveawayColor": /* The primary branding colour, as a 24-bit RGB integer. Defaults to #7837FF */ | ||
} | ||
} | ||
``` | ||
The `logs` directory is used to store logs in a format similar to that of a Minecraft server. `latest.log` will contain the log for the current day and current execution. All past logs are archived. | ||
|
||
The `data` directory is used to store persistent state of the bot, such as config values and the infraction database. | ||
|
||
### Launch Present | ||
To launch Present, simply run the following commands: | ||
```bash | ||
sudo docker-compose build | ||
sudo docker-compose up --detach | ||
``` | ||
|
||
## Updating Present | ||
To update Present, simply pull the latest changes from the repo and restart the container: | ||
```bash | ||
git pull | ||
sudo docker-compose stop | ||
sudo docker-compose build | ||
sudo docker-compose up --detach | ||
``` | ||
|
||
## Using Present | ||
For further usage breakdown and explanation of commands, see [USAGE.md](USAGE.md). | ||
|
||
## License | ||
This bot is under the [MIT License](LICENSE.md). | ||
|
||
## Disclaimer | ||
This bot is tailored for use within the [Brackeys Discord server](https://discord.gg/brackeys). While this bot is open source and you are free to use it in your own servers, you accept responsibility for any mishaps which may arise from the use of this software. Use at your own risk. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Slash Commands | ||
|
||
Below is an outline of every slash command currently implemented in Present, along with their descriptions and parameters. | ||
|
||
## User Blocking | ||
|
||
If you wish for a certain user to be discarded as a potential winner of giveaways, you can block them using the following command. | ||
This does not prevent the user from joining the giveaway, but they will not be considered when determining a winner. | ||
|
||
### `/giveaway blockuser` | ||
|
||
Prevent a user from winning giveaways. | ||
|
||
| Parameter | Required | Type | Description | | ||
|:----------|:---------|:-------------------|:--------------------------| | ||
| user | ✅ Yes | User mention or ID | The user to block. | | ||
| reason | ❌ No | String | The reason for the block. | | ||
|
||
### `/giveaway unblockuser` | ||
|
||
Unblocks a user, so that they are able to win giveaways. | ||
|
||
| Parameter | Required | Type | Description | | ||
|:----------|:---------|:-------------------|:---------------------| | ||
| user | ✅ Yes | User mention or ID | The user to unblock. | | ||
|
||
## Role Blocking | ||
|
||
If you wish for members with a certain role to be discarded as potential winners of giveaways, you can block them using the | ||
following command. | ||
This does not prevent members with that role from joining the giveaway, but they will not be considered when determining a winner. | ||
|
||
### `/giveaway blockrole` | ||
|
||
Prevent members with the role from winning giveaways. | ||
|
||
| Parameter | Required | Type | Description | | ||
|:----------|:---------|:-------------------|:--------------------------| | ||
| role | ✅ Yes | Role mention or ID | The role to block. | | ||
| reason | ❌ No | String | The reason for the block. | | ||
|
||
### `/giveaway unblockrole` | ||
|
||
Unblocks a role, so that members with that role are able to win giveaways. | ||
|
||
| Parameter | Required | Type | Description | | ||
|:----------|:---------|:-------------------|:---------------------| | ||
| role | ✅ Yes | Role mention or ID | The role to unblock. | | ||
|
||
## Giveaway Management | ||
|
||
### `/giveaway create` | ||
|
||
Creates a new giveaway. | ||
|
||
| Parameter | Required | Type | Description | | ||
|:------------|:---------|:----------------------|:--------------------------------------------------| | ||
| channel | ✅ Yes | Channel mention or ID | The channel in which the giveaway will be hosted. | | ||
| winnerCount | ✅ Yes | Integer | The number of winners for this giveaway. | | ||
|
||
Following this command, a modal will appear in which you can specify the giveaway's title, description, end time, and image URL. | ||
The end time can either be a relative time (e.g. 1w3d) or a Unix timestamp in seconds (e.g. 1734998400). | ||
The title cannot exceed 255 characters, and the description cannot exceed 4000 characters. | ||
The image URL must be a valid URI, or an empty string. | ||
|
||
### `/giveaway end` | ||
|
||
Prematurely ends an ongoing giveaway. This command bypasses the winner selection. | ||
|
||
| Parameter | Required | Type | Description | | ||
|:----------|:---------|:----------|:-------------------------------| | ||
| id | ✅ Yes | ShortGuid | The ID of the giveaway to end. | | ||
|
||
### `/giveaway view` | ||
|
||
Views the details of a giveaway. | ||
|
||
| Parameter | Required | Type | Description | | ||
|:----------|:---------|:----------|:--------------------------------| | ||
| id | ✅ Yes | ShortGuid | The ID of the giveaway to view. | | ||
|
||
# Ephemeral responses | ||
|
||
None of the commands respond ephemerally, unless an error occurs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"GUILD_ID": { | ||
"logChannel": 0, | ||
"primaryColor": 7878655, | ||
"secondaryColor": 14892140, | ||
"tertiaryColor": 16769110, | ||
"urgentReportThreshold": 5, | ||
"mute": { | ||
"gagDuration": 300000, | ||
"maxModeratorMuteDuration": 1210000000 | ||
}, | ||
"reactions": { | ||
"deleteMessageReaction": ":wastebasket:", | ||
"gagReaction": ":mute:", | ||
"historyReaction": ":clock4:", | ||
"reportReaction": ":triangular_flag_on_post:", | ||
"trackReaction": ":mag:" | ||
}, | ||
"roles": { | ||
"administratorRoleId": 0, | ||
"guruRoleId": 0, | ||
"moderatorRoleId": 0, | ||
"mutedRoleId": 0 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DISCORD_TOKEN=set_token_here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"sdk": { | ||
"version": "6.0.0", | ||
"rollForward": "latestMinor", | ||
"allowPrerelease": false | ||
} | ||
} |