commit 9505750e296517e92d58ce0c5ef864fa1fed0cee
Author: Mira <56395159+TheXorog@users.noreply.github.com>
Date: Mon Jan 27 17:17:53 2025 +0100
refactor: Initial release
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000..dfe07704
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+# Auto detect text files and perform LF normalization
+* text=auto
diff --git a/.gitconfig b/.gitconfig
new file mode 100644
index 00000000..a5440100
--- /dev/null
+++ b/.gitconfig
@@ -0,0 +1,2 @@
+[core]
+ hooksPath = hooks
diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md
new file mode 100644
index 00000000..4e2473b8
--- /dev/null
+++ b/.github/CODE_OF_CONDUCT.md
@@ -0,0 +1,134 @@
+
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+We as members, contributors, and leaders pledge to make participation in our
+community a harassment-free experience for everyone, regardless of age, body
+size, visible or invisible disability, ethnicity, sex characteristics, gender
+identity and expression, level of experience, education, socio-economic status,
+nationality, personal appearance, race, religion, or sexual identity
+and orientation.
+
+We pledge to act and interact in ways that contribute to an open, welcoming,
+diverse, inclusive, and healthy community.
+
+## Our Standards
+
+Examples of behavior that contributes to a positive environment for our
+community include:
+
+* Demonstrating empathy and kindness toward other people
+* Being respectful of differing opinions, viewpoints, and experiences
+* Giving and gracefully accepting constructive feedback
+* Accepting responsibility and apologizing to those affected by our mistakes,
+ and learning from the experience
+* Focusing on what is best not just for us as individuals, but for the
+ overall community
+
+Examples of unacceptable behavior include:
+
+* The use of sexualized language or imagery, and sexual attention or
+ advances of any kind
+* Trolling, insulting or derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or email
+ address, without their explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Enforcement Responsibilities
+
+Community leaders are responsible for clarifying and enforcing our standards of
+acceptable behavior and will take appropriate and fair corrective action in
+response to any behavior that they deem inappropriate, threatening, offensive,
+or harmful.
+
+Community leaders have the right and responsibility to remove, edit, or reject
+comments, commits, code, wiki edits, issues, and other contributions that are
+not aligned to this Code of Conduct, and will communicate reasons for moderation
+decisions when appropriate.
+
+## Scope
+
+This Code of Conduct applies within all community spaces, and also applies when
+an individual is officially representing the community in public spaces.
+Examples of representing our community include using an official e-mail address,
+posting via an official social media account, or acting as an appointed
+representative at an online or offline event.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported to the community leaders responsible for enforcement at
+[INSERT CONTACT METHOD].
+All complaints will be reviewed and investigated promptly and fairly.
+
+All community leaders are obligated to respect the privacy and security of the
+reporter of any incident.
+
+## Enforcement Guidelines
+
+Community leaders will follow these Community Impact Guidelines in determining
+the consequences for any action they deem in violation of this Code of Conduct:
+
+### 1. Correction
+
+**Community Impact**: Use of inappropriate language or other behavior deemed
+unprofessional or unwelcome in the community.
+
+**Consequence**: A private, written warning from community leaders, providing
+clarity around the nature of the violation and an explanation of why the
+behavior was inappropriate. A public apology may be requested.
+
+### 2. Warning
+
+**Community Impact**: A violation through a single incident or series
+of actions.
+
+**Consequence**: A warning with consequences for continued behavior. No
+interaction with the people involved, including unsolicited interaction with
+those enforcing the Code of Conduct, for a specified period of time. This
+includes avoiding interactions in community spaces as well as external channels
+like social media. Violating these terms may lead to a temporary or
+permanent ban.
+
+### 3. Temporary Ban
+
+**Community Impact**: A serious violation of community standards, including
+sustained inappropriate behavior.
+
+**Consequence**: A temporary ban from any sort of interaction or public
+communication with the community for a specified period of time. No public or
+private interaction with the people involved, including unsolicited interaction
+with those enforcing the Code of Conduct, is allowed during this period.
+Violating these terms may lead to a permanent ban.
+
+### 4. Permanent Ban
+
+**Community Impact**: Demonstrating a pattern of violation of community
+standards, including sustained inappropriate behavior, harassment of an
+individual, or aggression toward or disparagement of classes of individuals.
+
+**Consequence**: A permanent ban from any sort of public interaction within
+the community.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage],
+version 2.0, available at
+[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
+
+Community Impact Guidelines were inspired by
+[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
+
+For answers to common questions about this code of conduct, see the FAQ at
+[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
+at [https://www.contributor-covenant.org/translations][translations].
+
+[homepage]: https://www.contributor-covenant.org
+[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
+[Mozilla CoC]: https://github.com/mozilla/diversity
+[FAQ]: https://www.contributor-covenant.org/faq
+[translations]: https://www.contributor-covenant.org/translations
+
diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml
new file mode 100644
index 00000000..68beb209
--- /dev/null
+++ b/.github/workflows/dev.yml
@@ -0,0 +1,71 @@
+name: Test Dev Branch
+on:
+ push:
+ branches: [ "dev" ]
+ workflow_dispatch:
+jobs:
+ secretscan:
+ name: Scan for Secrets
+ runs-on: self-hosted
+ steps:
+ - name: Clone Repository
+ uses: actions/checkout@v4
+ with:
+ ref: dev
+
+ - name: Secret Scan
+ uses: max/secret-scan@master
+ with:
+ exclude_path: 'SecretsIgnore.txt'
+ spellcheck:
+ name: Clone Repository
+ runs-on: self-hosted
+ steps:
+ - name: Checkout Actions Repository
+ uses: actions/checkout@v4
+ with:
+ ref: dev
+
+ - name: Check spelling
+ uses: crate-ci/typos@master
+ testbuild:
+ name: Build Project
+ runs-on: self-hosted
+ steps:
+ - name: Cleanup before build
+ run: rm -rf ProjectMakotoTest/
+
+ - name: Setup .NET Core SDK
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: |
+ 9.x
+
+ - name: "Clone Repository"
+ uses: actions/checkout@v4
+ with:
+ submodules: recursive
+ path: ProjectMakotoTest
+ token: ${{ secrets.Access_token }}
+ ref: dev
+
+ - name: Install dependencies
+ run: dotnet restore
+ working-directory: ProjectMakotoTest/ProjectMakoto/
+
+ - name: Mark .sh files as executable
+ run: find . -type f -name "*.sh" -exec chmod +x {} +
+ working-directory: ProjectMakotoTest/OfficialPlugins/
+
+ - name: Prepare Makoto Plugin Build
+ run: sh update_deps.sh
+ working-directory: ProjectMakotoTest/OfficialPlugins/
+
+ - name: Test Build Makoto
+ run: dotnet publish --configuration RELEASE --runtime linux-x64 --no-self-contained --framework net9.0
+ working-directory: ProjectMakotoTest/ProjectMakoto/
+ timeout-minutes: 5
+
+ - name: Test Build Makoto Plugins
+ run: sh build_all.sh 1
+ working-directory: ProjectMakotoTest/OfficialPlugins/
\ No newline at end of file
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 00000000..99f8f981
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,119 @@
+name: Deploy to Production Server
+on:
+ push:
+ branches: [ main ]
+ workflow_dispatch:
+
+permissions: write-all
+
+jobs:
+ build:
+ name: Build Project and Upload to Server
+ runs-on: self-hosted
+ steps:
+ - name: Cleanup
+ run: rm -rf ProjectMakoto/
+
+ - name: Install SSH Key
+ if: ${{ !github.event.act }} # skip during local actions testing
+ uses: shimataro/ssh-key-action@v2
+ with:
+ key: ${{ secrets.SSH_TOKEN }}
+ known_hosts: ${{ secrets.SSH_KNOWN_HOST }}
+
+ - name: Setup .NET Core SDK 9.x
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: '9.x'
+
+ - name: "Clone Repository"
+ uses: actions/checkout@v4
+ with:
+ ref: main
+ submodules: recursive
+ path: ProjectMakoto
+ token: ${{ secrets.Access_token }}
+
+ - name: Install Dependencies
+ run: dotnet restore
+ working-directory: ProjectMakoto/ProjectMakoto/
+
+ - name: Mark .sh files as executable
+ run: find . -type f -name "*.sh" -exec chmod +x {} +
+ working-directory: ProjectMakoto/OfficialPlugins/
+
+ - name: Prepare Makoto Plugin Build
+ run: sh update_deps.sh
+ working-directory: ProjectMakoto/OfficialPlugins/
+
+ - name: Build Makoto
+ run: dotnet publish --configuration RELEASE --runtime linux-x64 --no-self-contained --output "build" --property:PublishDir="build" --framework net9.0
+ working-directory: ProjectMakoto/ProjectMakoto/
+ timeout-minutes: 5
+
+ - name: Create Version File
+ run: git rev-parse --short HEAD > "ProjectMakoto/build/LatestGitPush.cfg" && git branch --show-current >> ProjectMakoto/build/LatestGitPush.cfg && echo $(date +%d.%m.%y) >> ProjectMakoto/build/LatestGitPush.cfg && echo $(date +%H:%M:%S,00) >> ProjectMakoto/build/LatestGitPush.cfg
+ working-directory: ProjectMakoto/
+
+ - name: Build Makoto Plugins
+ run: sh build_all.sh
+ working-directory: ProjectMakoto/OfficialPlugins/
+
+ - name: Create plugins directory
+ run: mkdir Plugins
+ working-directory: ProjectMakoto/ProjectMakoto/build
+
+ - name: Move plugins into directory
+ run: mv ../OfficialPlugins/*.pmpl build/Plugins/
+ working-directory: ProjectMakoto/ProjectMakoto/
+
+ - name: Commit new trusted hashes
+ working-directory: ProjectMakoto/
+ run: |
+ git clone https://github.com/Fortunevale/ProjectMakoto.TrustedPlugins
+ cd ProjectMakoto.TrustedPlugins
+ mv ../OfficialPlugins/trusted_manifests/*.json hashes/
+ git config --global user.name 'Project Makoto'
+ git config --global user.email 'ichigo@aitsys.dev'
+ git remote set-url origin https://x-access-token:${{ secrets.PROJECT_MAKOTO_ACCESS_TOKEN }}@github.com/Fortunevale/ProjectMakoto.TrustedPlugins
+ git add -A
+ git commit -am "Add new hashes"
+ git push
+
+ - name: Sleep for 10 seconds
+ run: sleep 10
+ shell: bash
+
+ - name: Deploy to Production Server
+ if: ${{ !github.event.act }} # skip during local actions testing
+ run: rsync -avz --delete --force -e "ssh -p ${{ secrets.SSH_PORT }}" . ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_SERVER }}:/home/${{ secrets.SSH_USERNAME }}/Bots/latestProjectIchigo/
+ working-directory: ProjectMakoto/ProjectMakoto/build/
+
+ - name: Send Update Signal to Production Client
+ if: ${{ !github.event.act }} # skip during local actions testing
+ run: ssh ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_SERVER }} -p ${{ secrets.SSH_PORT }} touch /home/${{ secrets.SSH_USERNAME }}/Bots/ProjectIchigo/updated
+
+ - name: Create Zip File from Build
+ run: zip -r Release.zip build
+ working-directory: ProjectMakoto/ProjectMakoto/
+
+ - name: Truncate String
+ uses: 2428392/gh-truncate-string-action@v1.3.0
+ id: truncatedString
+ with:
+ stringToTruncate: ${{ github.sha }}
+ maxLength: 10
+
+ - name: Create Release
+ if: ${{ !github.event.act }} # skip during local actions testing
+ uses: ncipollo/release-action@v1.14.0
+ with:
+ artifacts: "ProjectMakoto/ProjectMakoto/Release.zip"
+ generateReleaseNotes: true
+ prerelease: false
+ tag: ${{ steps.truncatedString.outputs.string }}
+ commit: ${{ github.sha }}
+
+ - name: Cleanup
+ run: rm -rf ProjectMakoto/
+ if: always()
\ No newline at end of file
diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml
new file mode 100644
index 00000000..175be6a7
--- /dev/null
+++ b/.github/workflows/preview.yml
@@ -0,0 +1,148 @@
+name: Deploy to Preview Server
+on:
+ push:
+ branches: [ preview ]
+ workflow_dispatch:
+
+permissions: write-all
+
+jobs:
+ secretscan:
+ if: ${{ !github.event.act }} # skip during local actions testing
+ name: Scan for Secrets
+ runs-on: self-hosted
+ steps:
+ - name: Clone Repository
+ uses: actions/checkout@v4
+ with:
+ ref: preview
+
+ - name: Secret Scan
+ uses: max/secret-scan@master
+ with:
+ exclude_path: 'SecretsIgnore.txt'
+
+ spellcheck:
+ if: ${{ !github.event.act }} # skip during local actions testing
+ name: Spell Check with Typos
+ runs-on: self-hosted
+ steps:
+ - name: Clone Repository
+ uses: actions/checkout@v4
+ with:
+ ref: preview
+
+ - name: Check spelling
+ uses: crate-ci/typos@master
+
+ preview_deploy:
+ name: Build Project and Upload to Server
+ runs-on: self-hosted
+ steps:
+ - name: Cleanup
+ run: rm -rf ProjectMakotoPreview/
+
+ - name: Install SSH Key
+ if: ${{ !github.event.act }} # skip during local actions testing
+ uses: shimataro/ssh-key-action@v2
+ with:
+ key: ${{ secrets.SSH_TOKEN }}
+ known_hosts: ${{ secrets.SSH_KNOWN_HOST }}
+
+ - name: Setup .NET Core SDK 8.x
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: |
+ 9.x
+
+ - name: "Clone Repository"
+ uses: actions/checkout@v4
+ with:
+ ref: preview
+ submodules: recursive
+ path: ProjectMakotoPreview
+ token: ${{ secrets.Access_token }}
+
+ - name: Install Dependencies
+ run: dotnet restore
+ working-directory: ProjectMakotoPreview/ProjectMakoto/
+
+ - name: Mark .sh files as executable
+ run: find . -type f -name "*.sh" -exec chmod +x {} +
+ working-directory: ProjectMakotoPreview/OfficialPlugins/
+
+ - name: Prepare Makoto Plugin Build
+ run: sh update_deps.sh
+ working-directory: ProjectMakotoPreview/OfficialPlugins/
+
+ - name: Build Makoto
+ run: dotnet publish --configuration RELEASE --runtime linux-x64 --no-self-contained --output "build" --property:PublishDir="build" --framework net9.0
+ working-directory: ProjectMakotoPreview/ProjectMakoto/
+ timeout-minutes: 5
+
+ - name: Create Version File
+ run: git rev-parse --short HEAD > "ProjectMakoto/build/LatestGitPush.cfg" && git branch --show-current >> ProjectMakoto/build/LatestGitPush.cfg && echo $(date +%d.%m.%y) >> ProjectMakoto/build/LatestGitPush.cfg && echo $(date +%H:%M:%S,00) >> ProjectMakoto/build/LatestGitPush.cfg
+ working-directory: ProjectMakotoPreview/
+
+ - name: Build Makoto Plugins
+ run: sh build_all.sh 1
+ working-directory: ProjectMakotoPreview/OfficialPlugins/
+
+ - name: Create plugins directory
+ run: mkdir Plugins
+ working-directory: ProjectMakotoPreview/ProjectMakoto/build
+
+ - name: Move plugins into directory
+ run: mv ../OfficialPlugins/*.pmpl build/Plugins/
+ working-directory: ProjectMakotoPreview/ProjectMakoto/
+
+ - name: Commit new trusted hashes
+ working-directory: ProjectMakotoPreview/
+ run: |
+ git clone https://github.com/Fortunevale/ProjectMakoto.TrustedPlugins
+ cd ProjectMakoto.TrustedPlugins
+ mv ../OfficialPlugins/trusted_manifests/*.json hashes/
+ git config --global user.name 'Project Makoto'
+ git config --global user.email 'ichigo@aitsys.dev'
+ git remote set-url origin https://x-access-token:${{ secrets.PROJECT_MAKOTO_ACCESS_TOKEN }}@github.com/Fortunevale/ProjectMakoto.TrustedPlugins
+ git add -A
+ git commit -am "Add new preview hashes"
+ git push
+
+ - name: Sleep for 10 seconds
+ run: sleep 10
+ shell: bash
+
+ - name: Deploy to Preview Server
+ if: ${{ !github.event.act }} # skip during local actions testing
+ run: rsync -avz --delete --force -e "ssh -p ${{ secrets.SSH_PORT }}" . ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_SERVER }}:/home/${{ secrets.SSH_USERNAME }}/Bots/latestProjectIchigoPreview/
+ working-directory: ProjectMakotoPreview/ProjectMakoto/build/
+
+ - name: Send Update Signal to Preview Client
+ if: ${{ !github.event.act }} # skip during local actions testing
+ run: ssh ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_SERVER }} -p ${{ secrets.SSH_PORT }} touch /home/${{ secrets.SSH_USERNAME }}/Bots/ProjectIchigoPreview/updated
+
+ - name: Create Zip File from Build
+ run: zip -r Release.zip build
+ working-directory: ProjectMakotoPreview/ProjectMakoto/
+
+ - name: Truncate String
+ uses: 2428392/gh-truncate-string-action@v1.3.0
+ id: truncatedString
+ with:
+ stringToTruncate: ${{ github.sha }}
+ maxLength: 10
+
+ - name: Create Release
+ if: ${{ !github.event.act }} # skip during local actions testing
+ uses: ncipollo/release-action@v1.14.0
+ with:
+ artifacts: "ProjectMakotoPreview/ProjectMakoto/Release.zip"
+ generateReleaseNotes: true
+ prerelease: true
+ tag: ${{ steps.truncatedString.outputs.string }}-pre
+ commit: ${{ github.sha }}
+
+ - name: Cleanup
+ run: rm -rf ProjectMakotoPreview/
+ if: always()
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..a22b5467
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,348 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+.vscode/*
+ProjectMakoto/Properties/launchSettings.json
+ProjectMakoto/Properties/
+launchSettings.json
+
+!.vscode/Snippets.code-snippets
+!.vscode/tasks.json
+!.vscode/extensions.json
+!.vscode/settings.json
+ProjectMakoto/Plugins/*
+OfficialPlugins/deps/
+OfficialPlugins/trusted_manifests/
+*.pmpl
\ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..9411d4c7
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,33 @@
+[submodule "Xorog.UniversalExtensions"]
+ path = Dependencies/Xorog.UniversalExtensions
+ url = https://github.com/Fortunevale/Xorog.UniversalExtensions
+ branch = main
+[submodule "quickchart-csharp"]
+ path = Dependencies/quickchart-csharp
+ url = https://github.com/TheXorog/quickchart-csharp
+ branch = applied-editorconfig
+[submodule "DisCatSharp"]
+ path = Dependencies/DisCatSharp
+ url = https://github.com/Aiko-IT-Systems/DisCatSharp
+ branch = main
+[submodule "OfficialPlugins/Example"]
+ path = OfficialPlugins/Example
+ url = https://github.com/Fortunevale/ProjectMakoto.Plugins.Example
+ branch = main
+[submodule "OfficialPlugins/Social"]
+ path = OfficialPlugins/Social
+ url = https://github.com/Fortunevale/ProjectMakoto.Plugins.Social
+ branch = main
+[submodule "OfficialPlugins/Translations"]
+ path = OfficialPlugins/Translations
+ url = https://github.com/Fortunevale/ProjectMakoto.Plugins.Translations
+ branch = main
+[submodule "Tools"]
+ path = Tools
+ url = https://github.com/Fortunevale/ProjectMakoto.Tools
+[submodule "OfficialPlugins/ProjectMakoto.Plugins.Music"]
+ path = OfficialPlugins/Music
+ url = https://github.com/Fortunevale/ProjectMakoto.Plugins.Music
+[submodule "ScoreSaber"]
+ path = OfficialPlugins/ScoreSaber
+ url = https://github.com/Fortunevale/ProjectMakoto.Plugins.ScoreSaber
diff --git a/.vscode/Snippets.code-snippets b/.vscode/Snippets.code-snippets
new file mode 100644
index 00000000..6fb5d397
--- /dev/null
+++ b/.vscode/Snippets.code-snippets
@@ -0,0 +1,97 @@
+{
+ // Place your ProjectIchigo workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
+ // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
+ // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
+ // used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
+ // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
+ // Placeholders with the same ids are connected.
+ // Example:
+ // "Print to console": {
+ // "scope": "javascript,typescript",
+ // "prefix": "log",
+ // "body": [
+ // "console.log('$1');",
+ // "$2"
+ // ],
+ // "description": "Log output to console"
+ // }
+ "FileHeader": {
+ "prefix": "header",
+ "body": [
+ "Project Makoto",
+ "Copyright (C) 2024 Fortunevale",
+ "This program is free software: you can redistribute it and/or modify",
+ "it under the terms of the GNU General Public License as published by",
+ "the Free Software Foundation, either version 3 of the License, or",
+ "(at your option) any later version.",
+ "This program is distributed in the hope that it will be useful,",
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of",
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
+ "GNU General Public License for more details.",
+ "You should have received a copy of the GNU General Public License",
+ "along with this program. If not, see ."
+ ]
+ },
+ "LogFatal": {
+ "prefix": "fatal",
+ "body": [
+ "Log.Fatal($0$TM_SELECTED_TEXT);"
+ ]
+ },
+ "LogError": {
+ "prefix": "error",
+ "body": [
+ "Log.Error($0$TM_SELECTED_TEXT);"
+ ]
+ },
+ "LogWarn": {
+ "prefix": "warn",
+ "body": [
+ "Log.Warning($0$TM_SELECTED_TEXT);"
+ ]
+ },
+ "LogInfo": {
+ "prefix": "info",
+ "body": [
+ "Log.Information($0$TM_SELECTED_TEXT);"
+ ]
+ },
+ "LogDebug": {
+ "prefix": "debug",
+ "body": [
+ "Log.Debug($0$TM_SELECTED_TEXT);"
+ ]
+ },
+ "LogVerbose": {
+ "prefix": "verbose",
+ "body": [
+ "Log.Verbose($0$TM_SELECTED_TEXT);"
+ ]
+ },
+ "AsyncTask": {
+ "prefix": "asynctask",
+ "body": [
+ "$0_ = Task.Run(async () =>",
+ "{",
+ "\t$TM_SELECTED_TEXT",
+ "});"
+ ]
+ },
+ "Task": {
+ "prefix": "task",
+ "body": [
+ "$0_ = Task.Run(() =>",
+ "{",
+ "\t$TM_SELECTED_TEXT",
+ "});"
+ ]
+ },
+ "Braces": {
+ "prefix": "braces",
+ "body": [
+ "$0{",
+ "\t$TM_SELECTED_TEXT",
+ "}"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 00000000..be1557ab
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,11 @@
+{
+ "recommendations": [
+ "ms-dotnettools.vscode-dotnet-runtime",
+ "ms-dotnettools.csharp",
+ "tdallau-csharpextensions.csharpextensions",
+ "anseki.vscode-color",
+ "peterschmalfeldt.explorer-exclude",
+ "christian-kohler.path-intellisense",
+ "ms-vscode.vs-keybindings"
+ ]
+}
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 00000000..c754a380
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,28 @@
+{
+ "files.exclude": {
+ "**/.git": true,
+ "**/.svn": true,
+ "**/.hg": true,
+ "**/CVS": true,
+ "**/.DS_Store": true,
+ "**/Thumbs.db": false,
+ "OfficialPlugins/deps": true,
+ "OfficialPlugins/trusted_manifests": true,
+ "hooks": true,
+ "_typos.toml": true,
+ "InitSubmodules.sh": true,
+ ".gitattributes": true,
+ ".gitconfig": true,
+ "LICENSE": true,
+ "renovate.json": true,
+ "ResetDevToPreview.sh": true,
+ "ResetPreviewToMain.sh": true,
+ "SetupGit.sh": true,
+ "TestRun.sh": true,
+ "UpdateSubmodules.sh": true,
+ "**/*.pmpl": true,
+ "event.json": true
+ },
+ "explorerExclude.backup": {},
+ "dotnet.defaultSolution": "ProjectMakoto/ProjectMakoto.sln"
+}
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 00000000..237cd71e
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,41 @@
+{
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "build",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "build",
+ "${workspaceFolder}/ProjectMakoto/ProjectMakoto.sln",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary;ForceNoAlign"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "publish",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "publish",
+ "${workspaceFolder}/ProjectMakoto/ProjectMakoto.sln",
+ "/property:GenerateFullPaths=true",
+ "/consoleloggerparameters:NoSummary;ForceNoAlign"
+ ],
+ "problemMatcher": "$msCompile"
+ },
+ {
+ "label": "watch",
+ "command": "dotnet",
+ "type": "process",
+ "args": [
+ "watch",
+ "run",
+ "--project",
+ "${workspaceFolder}/ProjectMakoto/ProjectMakoto.sln"
+ ],
+ "problemMatcher": "$msCompile"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 00000000..fd392c53
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,49 @@
+
Makoto
+
+A feature packed discord bot!
+
+
+

+
+
+

+
+## Step by Step Guide on how to set up a Development Environment
+
+1. Install the following applications. These should get you started with a basic environment for C# development.
+ - [Git CLI](https://www.git-scm.com/downloads)
+ - [Visual Studio 2022](https://visualstudio.microsoft.com/vs/)
+ - Select .NET desktop development
+2. Log into your Github Account with the Git CLI and clone the following repository:
+ - `Fortunevale/ProjectMakoto`
+ - To clone `ProjectMakoto` with it's submodules run: `git clone --recurse-submodules "https://github.com/Fortunevale/ProjectMakoto.git"`
+ - _You can skip this step if you're developing a plugin._
+3. With this completed, you can already start developing for Makoto. To be able to debug Makoto, follow the guide below.
+
+## Running/Debugging Makoto with all necessary dependencies
+
+1. Install the following:
+ - [MariaDB Server](https://mariadb.org/download/)
+ - After installing the MariaDB Server, create 2 new databases: One for the main tables (guilds, users, scam_urls, etc.) and one for server members.
+ - You'll need a third database if you're using plugins.
+
+2. Create an account on the following sites:
+ - [Discord](https://discord.com)
+ - Create a new [Discord Team](https://discord.com/developers/teams) and add a new [Discord Application](https://discord.com/developers/applications/) to the previously created team.
+ - Add a bot to the application and note down the bot token.
+ - Makoto currently requires the `Presence`, `Server Members` and `Message Content` Intents.
+ - I recommend disabling the `Public Bot` Option so no one can add your development client to their server.
+ - [AbuseIPDB API Key](https://www.abuseipdb.com/account)
+ - After creating your account, you can create an api key [here](https://www.abuseipdb.com/account/api).
+ - [Github](https://github.com/)
+ - Create a [Personal Access Token](https://github.com/settings/tokens) to your Github Account.
+ - The bot needs to be able to create issues and read your repository.
+3. Build and run Makoto until the console says something like "Config reloaded".
+4. Open the `config.json` in the path you built Makoto in (usually `bin/Debug/`) and put in all values.
+5. You're all set.
+
+## Useful resources for development
+
+- [DisCatSharp Documentation](https://docs.dcs.aitsys.dev/articles/preamble.html)
+- [Translation Documentation](TRANSLATING.md)
+- [Plugin Documentation](PLUGINS.md)
\ No newline at end of file
diff --git a/DeleteDrafts.sh b/DeleteDrafts.sh
new file mode 100644
index 00000000..21a51142
--- /dev/null
+++ b/DeleteDrafts.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# GitHub repository details (replace these with your repo owner and name)
+REPO_OWNER="Fortunevale"
+REPO_NAME="ProjectMakoto"
+
+# Check if dry-run switch is passed
+dry_run=false
+if [[ "$1" == "--dry-run" ]]; then
+ dry_run=true
+fi
+
+# List all draft releases associated with the repository
+echo "Fetching all draft releases for repository $REPO_OWNER/$REPO_NAME..."
+
+draft_releases=$(gh release list --repo "$REPO_OWNER/$REPO_NAME" --limit 100 | grep "Draft")
+
+if [[ -z "$draft_releases" ]]; then
+ echo "No draft releases found."
+ exit 0
+fi
+
+# Iterate through each draft release
+echo "$draft_releases" | while read -r release; do
+ release_tag=$(echo "$release" | awk '{print $1}')
+ echo "Found draft release: $release_tag"
+
+ if [[ "$dry_run" == true ]]; then
+ echo "[DRY RUN] Draft release '$release_tag' would be deleted."
+ else
+ echo "Deleting draft release '$release_tag'..."
+ gh release delete "$release_tag" --repo "$REPO_OWNER/$REPO_NAME" --yes
+ echo "Draft release '$release_tag' deleted."
+ fi
+done
diff --git a/DeleteOldTags.sh b/DeleteOldTags.sh
new file mode 100644
index 00000000..ba341236
--- /dev/null
+++ b/DeleteOldTags.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# Check if dry-run switch is passed
+dry_run=false
+if [[ "$1" == "--dry-run" ]]; then
+ dry_run=true
+fi
+
+# Get current date in seconds since the epoch
+current_date=$(date +%s)
+
+# Find tags older than a month (30 days)
+month_in_seconds=$((30 * 24 * 60 * 60))
+
+# Get the list of tags
+tags=$(git tag)
+
+echo "Checking for tags older than one month..."
+
+for tag in $tags; do
+ # Get the date of the tag in seconds since the epoch
+ tag_date=$(git log -1 --format=%at "$tag")
+
+ # Calculate the age of the tag
+ tag_age=$((current_date - tag_date))
+
+ # Check if the tag is older than a month
+ if [[ $tag_age -ge $month_in_seconds ]]; then
+ if [[ "$dry_run" == true ]]; then
+ echo "[DRY RUN] Tag '$tag' would be deleted (Created: $(date -d @$tag_date))"
+ else
+ echo "Deleting tag '$tag' (Created: $(date -d @$tag_date))"
+ git tag -d "$tag"
+ git push --delete origin "$tag"
+ fi
+ fi
+done
diff --git a/Dependencies/DisCatSharp b/Dependencies/DisCatSharp
new file mode 160000
index 00000000..5f4f5c46
--- /dev/null
+++ b/Dependencies/DisCatSharp
@@ -0,0 +1 @@
+Subproject commit 5f4f5c46f808fd2199a6cc8b6b9dabaa646b5d86
diff --git a/Dependencies/Xorog.UniversalExtensions b/Dependencies/Xorog.UniversalExtensions
new file mode 160000
index 00000000..dadeb77e
--- /dev/null
+++ b/Dependencies/Xorog.UniversalExtensions
@@ -0,0 +1 @@
+Subproject commit dadeb77e1667b6785ee8368eb92b2bbe1efba06e
diff --git a/Dependencies/quickchart-csharp b/Dependencies/quickchart-csharp
new file mode 160000
index 00000000..0b60f2e3
--- /dev/null
+++ b/Dependencies/quickchart-csharp
@@ -0,0 +1 @@
+Subproject commit 0b60f2e32db9d79dcc45311ee77b38b7a32ef776
diff --git a/DocAssets/DownloadProject1.png b/DocAssets/DownloadProject1.png
new file mode 100644
index 00000000..0979e569
Binary files /dev/null and b/DocAssets/DownloadProject1.png differ
diff --git a/DocAssets/DownloadRelease1.png b/DocAssets/DownloadRelease1.png
new file mode 100644
index 00000000..26151bef
Binary files /dev/null and b/DocAssets/DownloadRelease1.png differ
diff --git a/DocAssets/ExamplePluginInfo1.png b/DocAssets/ExamplePluginInfo1.png
new file mode 100644
index 00000000..ae25f45b
Binary files /dev/null and b/DocAssets/ExamplePluginInfo1.png differ
diff --git a/InitSubmodules.sh b/InitSubmodules.sh
new file mode 100644
index 00000000..272af333
--- /dev/null
+++ b/InitSubmodules.sh
@@ -0,0 +1,5 @@
+echo "Downloading submodules.."
+git submodule update --recursive
+echo "Done"
+sleep 10
+exit
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..e62ec04c
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/OfficialPlugins/Example b/OfficialPlugins/Example
new file mode 160000
index 00000000..03899f8e
--- /dev/null
+++ b/OfficialPlugins/Example
@@ -0,0 +1 @@
+Subproject commit 03899f8e5bc3d3b2807be7f90a518c28a830a0bb
diff --git a/OfficialPlugins/Music b/OfficialPlugins/Music
new file mode 160000
index 00000000..79e7cffb
--- /dev/null
+++ b/OfficialPlugins/Music
@@ -0,0 +1 @@
+Subproject commit 79e7cffb4e38d68d2af71d321d8698fd799b3e59
diff --git a/OfficialPlugins/ScoreSaber b/OfficialPlugins/ScoreSaber
new file mode 160000
index 00000000..b0318f56
--- /dev/null
+++ b/OfficialPlugins/ScoreSaber
@@ -0,0 +1 @@
+Subproject commit b0318f5602b29482638a71dae7184b075bc58b5a
diff --git a/OfficialPlugins/Social b/OfficialPlugins/Social
new file mode 160000
index 00000000..4e795fdd
--- /dev/null
+++ b/OfficialPlugins/Social
@@ -0,0 +1 @@
+Subproject commit 4e795fddc75a59f2512243f59c02de3d0823cdd2
diff --git a/OfficialPlugins/Translations b/OfficialPlugins/Translations
new file mode 160000
index 00000000..ea04fd27
--- /dev/null
+++ b/OfficialPlugins/Translations
@@ -0,0 +1 @@
+Subproject commit ea04fd278535c33a3b78d056adf6c25a5cb687bc
diff --git a/OfficialPlugins/build_all.cmd b/OfficialPlugins/build_all.cmd
new file mode 100644
index 00000000..e4bc8a91
--- /dev/null
+++ b/OfficialPlugins/build_all.cmd
@@ -0,0 +1,29 @@
+@echo off
+
+set "current_dir=%CD%"
+call update_deps.cmd
+cd /d "%current_dir%"
+
+del /q *.pmpl
+
+for /D %%i in (*) do (
+ if /I "%%i" neq "deps" (
+ if /I "%%i" neq "Example" (
+ if exist "%%i\.build.cmd" (
+ pushd "%%i"
+ echo Running .build.cmd in %%i
+ call .\.build.cmd
+ popd
+
+ rem Move pmpl files to parent directory
+ move "%%i\*.pmpl" .
+ )
+ )
+ )
+)
+
+rmdir /s /q trusted_manifests
+mkdir trusted_manifests
+
+cd deps
+dotnet ProjectMakoto.dll --build-manifests .. --output-manifests ../trusted_manifests
\ No newline at end of file
diff --git a/OfficialPlugins/build_all.sh b/OfficialPlugins/build_all.sh
new file mode 100644
index 00000000..e6b0c39a
--- /dev/null
+++ b/OfficialPlugins/build_all.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+current_dir=$(pwd)
+./update_deps.sh
+
+if [ "$1" -ne 1 ]; then
+ ./update_deps.sh
+fi
+
+if [ $? -ne 0 ]; then
+ echo "Error: update_deps.sh script failed. Exiting."
+ exit 1
+fi
+
+cd "$current_dir"
+rm -f *.pmpl
+
+for i in */; do
+ # Exclude 'deps' and 'Example' directories
+ if [ "$i" != "deps/" ] && [ "$i" != "Example/" ]; then
+ # Check if .build.sh file exists and is executable
+ if [ -x "$i.build.sh" ]; then
+ cd "$i"
+ echo "Running .build.sh in $i"
+ ./.build.sh
+
+ if [ $? -ne 0 ]; then
+ echo "Error: Build failed."
+ exit 1
+ fi
+
+ cd ..
+
+ # Move pmpl files to parent directory
+ mv "$i"/*.pmpl .
+ fi
+ fi
+done
+
+rm -rf trusted_manifests
+mkdir trusted_manifests
+
+cd deps
+dotnet ProjectMakoto.dll --build-manifests .. --output-manifests ../trusted_manifests
\ No newline at end of file
diff --git a/OfficialPlugins/move_all.cmd b/OfficialPlugins/move_all.cmd
new file mode 100644
index 00000000..f0cf7ec8
--- /dev/null
+++ b/OfficialPlugins/move_all.cmd
@@ -0,0 +1,7 @@
+@echo off
+echo Cleaning up old versions..
+rmdir \s \q "..\ProjectMakoto\bin\x64\Debug\net8.0\Plugins\"
+mkdir "..\ProjectMakoto\bin\x64\Debug\net8.0\Plugins\"
+
+echo Moving new plugins..
+move "*.pmpl" "..\ProjectMakoto\bin\x64\Debug\net8.0\Plugins\"
\ No newline at end of file
diff --git a/OfficialPlugins/move_all.sh b/OfficialPlugins/move_all.sh
new file mode 100644
index 00000000..16768d5a
--- /dev/null
+++ b/OfficialPlugins/move_all.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+echo "Cleaning up old versions.."
+rm -rf "../ProjectMakoto/bin/x64/Debug/net8.0/Plugins/"
+mkdir -p "../ProjectMakoto/bin/x64/Debug/net8.0/Plugins/"
+
+echo "Moving new plugins.."
+mv *.pmpl "../ProjectMakoto/bin/x64/Debug/net8.0/Plugins/"
diff --git a/OfficialPlugins/update_deps.cmd b/OfficialPlugins/update_deps.cmd
new file mode 100644
index 00000000..515bfcdb
--- /dev/null
+++ b/OfficialPlugins/update_deps.cmd
@@ -0,0 +1,34 @@
+@echo off
+
+rmdir /S /Q deps
+dotnet publish ..\ProjectMakoto\ProjectMakoto.csproj --configuration RELEASE --runtime linux-x64 --no-self-contained --property:PublishDir="deps" --framework net9.0
+move ..\ProjectMakoto\deps deps
+
+set "original_dir=%CD%"
+cd /d "..\Dependencies"
+
+for /d /r %%i in (*deps*) do (
+ rd /s /q "%%i"
+)
+
+cd /d "%original_dir%"
+
+git submodule update --init --depth 0
+
+for /D %%i in (*) do (
+ if /I "%%i" neq "deps" (
+ if exist "%%i\.build.cmd" (
+ echo Creating symlink in %%i to deps
+ if not exist "%%i\deps" (
+ mklink /d "%%i\deps" "..\deps"
+ )
+
+ cd "%%i"
+
+ echo Syncing git submodules in %%i
+ git submodule update --init --depth 0
+
+ cd ..
+ )
+ )
+)
diff --git a/OfficialPlugins/update_deps.sh b/OfficialPlugins/update_deps.sh
new file mode 100644
index 00000000..4c538417
--- /dev/null
+++ b/OfficialPlugins/update_deps.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+
+# Remove existing deps directory
+rm -rf deps
+
+# Publish ProjectMakoto
+dotnet publish ../ProjectMakoto/ProjectMakoto.csproj --configuration RELEASE --runtime linux-x64 --no-self-contained --property:PublishDir="deps" --framework net9.0
+mv ../ProjectMakoto/deps deps
+
+# Change to Dependencies directory
+original_dir=$(pwd)
+cd ../Dependencies
+
+# Remove all directories with "*deps*" recursively
+find . -type d -name "*deps*" -exec rm -rf {} \;
+
+# Change back to the original directory
+cd "$original_dir"
+
+# Update git submodules in the current directory
+git submodule update --init --depth 0
+
+# Iterate over subdirectories
+for i in */; do
+ # Exclude 'deps' directory
+ if [ "$i" != "deps/" ]; then
+ # Check if .build.cmd file exists
+ if [ -f "$i.build.cmd" ]; then
+ echo "Creating symlink in $i to deps"
+
+ # Create symlink to deps directory
+ if [ ! -e "$i/deps" ]; then
+ # Check the operating system type
+ if [[ "$OSTYPE" == "msys" ]]; then
+ # MSYS (Git Bash) system
+ echo "mklink /d \"$i\\deps\" \"..\\deps\"" > temp.bat
+ c:/windows/system32/cmd.exe //c temp.bat
+ rm temp.bat
+ else
+ # Assume Linux
+ ln -s "../deps" "$i/deps"
+ fi
+ fi
+
+ # Change to subdirectory
+ cd "$i"
+
+ echo "Syncing git submodules in $i"
+ git submodule update --init --depth 0
+
+ # Change back to the original directory
+ cd "$original_dir"
+ fi
+ fi
+done
diff --git a/PLUGINS.md b/PLUGINS.md
new file mode 100644
index 00000000..95c3dd5f
--- /dev/null
+++ b/PLUGINS.md
@@ -0,0 +1,37 @@
+Makoto
+
+A feature packed discord bot!
+
+
+

+
+
+

+
+## Developing Plugins
+
+1. Download the latest version of Makoto [here](https://github.com/Fortunevale/ProjectMakoto/releases).
+
+
+
+2. Download the example plugin's source code [here](https://github.com/Fortunevale/ProjectMakoto.Plugins.Example).
+
+
+
+3. Create a folder called `deps` in the root directory of the example plugin.
+
+4. Drop all files of release zip archive into the `deps` folder.
+
+5. Open the project.
+
+6. Specify your Plugin's Name, Author and other details in `ExamplePlugin.cs`.
+ - The comments should help you get started.
+ - You can rename this file, project and everything else, inheriting the `BasePlugin` is what matters for Makoto to find and load your plugin.
+
+
+
+## Testing your plugin
+
+You need to set up Makoto ([Guide](CONTRIBUTING.md#running-makoto-with-all-necessary-dependencies)). Running/Debugging Makoto with all necessary dependencies.
+
+To run Makoto, you can instead use `dotnet run ProjectMakoto.dll` in the folder you saved Makoto to in Step 1 of Developing.
\ No newline at end of file
diff --git a/ProjectMakoto/.editorconfig b/ProjectMakoto/.editorconfig
new file mode 100644
index 00000000..1bf01318
--- /dev/null
+++ b/ProjectMakoto/.editorconfig
@@ -0,0 +1,110 @@
+[*.cs]
+
+# CS8601: Possible null reference assignment.
+dotnet_diagnostic.CS8601.severity = none
+
+# CS1998: Async method lacks 'await' operators and will run synchronously
+dotnet_diagnostic.CS1998.severity = silent
+
+# CA1822: Mark members as static
+dotnet_diagnostic.CA1822.severity = silent
+
+# IDE1006: Naming Styles
+dotnet_diagnostic.IDE1006.severity = silent
+
+# IDE0044: Add readonly modifier
+dotnet_diagnostic.IDE0044.severity = silent
+
+# IDE0017: Simplify object initialization
+dotnet_diagnostic.CS8981.severity = silent
+dotnet_diagnostic.IDE0017.severity = silent
+csharp_indent_labels = one_less_than_current
+csharp_using_directive_placement = outside_namespace:silent
+csharp_prefer_simple_using_statement = false:suggestion
+csharp_prefer_braces = true:silent
+csharp_style_namespace_declarations = file_scoped:silent
+csharp_style_prefer_method_group_conversion = true:silent
+csharp_style_prefer_top_level_statements = true:silent
+csharp_style_expression_bodied_methods = false:silent
+csharp_style_expression_bodied_constructors = false:silent
+csharp_style_expression_bodied_operators = false:silent
+csharp_style_expression_bodied_properties = true:silent
+csharp_style_expression_bodied_indexers = true:silent
+csharp_style_expression_bodied_accessors = true:silent
+csharp_style_expression_bodied_lambdas = true:silent
+csharp_style_expression_bodied_local_functions = false:silent
+csharp_space_around_binary_operators = before_and_after
+
+# SYSLIB1045: Convert to 'GeneratedRegexAttribute'.
+dotnet_diagnostic.SYSLIB1045.severity = silent
+
+# DCS0200: [Discord] Requires Features
+dotnet_diagnostic.DCS0200.severity = silent
+
+# IDE0079: Remove unnecessary suppression
+dotnet_diagnostic.IDE0079.severity = silent
+
+[*.{cs,vb}]
+#### Naming styles ####
+
+# Naming rules
+
+dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
+dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
+dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
+
+dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.types_should_be_pascal_case.symbols = types
+dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
+
+dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
+dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
+
+# Symbol specifications
+
+dotnet_naming_symbols.interface.applicable_kinds = interface
+dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.interface.required_modifiers =
+
+dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
+dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.types.required_modifiers =
+
+dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
+dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.non_field_members.required_modifiers =
+
+# Naming styles
+
+dotnet_naming_style.begins_with_i.required_prefix = I
+dotnet_naming_style.begins_with_i.required_suffix =
+dotnet_naming_style.begins_with_i.word_separator =
+dotnet_naming_style.begins_with_i.capitalization = pascal_case
+
+dotnet_naming_style.pascal_case.required_prefix =
+dotnet_naming_style.pascal_case.required_suffix =
+dotnet_naming_style.pascal_case.word_separator =
+dotnet_naming_style.pascal_case.capitalization = pascal_case
+
+dotnet_naming_style.pascal_case.required_prefix =
+dotnet_naming_style.pascal_case.required_suffix =
+dotnet_naming_style.pascal_case.word_separator =
+dotnet_naming_style.pascal_case.capitalization = pascal_case
+dotnet_style_operator_placement_when_wrapping = beginning_of_line
+tab_width = 4
+indent_size = 4
+end_of_line = lf
+dotnet_style_coalesce_expression = true:suggestion
+dotnet_style_null_propagation = true:suggestion
+dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
+dotnet_style_prefer_auto_properties = true:silent
+dotnet_style_object_initializer = true:suggestion
+dotnet_style_collection_initializer = false:silent
+dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
+dotnet_style_prefer_conditional_expression_over_assignment = true:silent
+dotnet_style_prefer_conditional_expression_over_return = true:silent
+file_header_template = Project Makoto\nCopyright (C) 2024 Fortunevale\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see .
+
+# IDE0060: Remove unused parameter
+dotnet_diagnostic.IDE0060.severity = silent
diff --git a/ProjectMakoto/Assets/1.png b/ProjectMakoto/Assets/1.png
new file mode 100644
index 00000000..578ff2a6
Binary files /dev/null and b/ProjectMakoto/Assets/1.png differ
diff --git a/ProjectMakoto/Assets/ASCII.txt b/ProjectMakoto/Assets/ASCII.txt
new file mode 100644
index 00000000..faeaa213
--- /dev/null
+++ b/ProjectMakoto/Assets/ASCII.txt
@@ -0,0 +1,44 @@
+r g?:?
+r g:#J#g~?
+r g:#YYY#~g?? g~7#JJJY?
+r g?^YYYYJ7^g??????????~JYYYY#5g?
+r g?7Y#!^:p????:::::???g^#YYYY#5g?
+r g?!^p?????????????????g!JJYYJgY
+r g??p???????????????????g!GYJ#5g#
+r g?:p?????g?p??????g?p??::???g~PGYYGg:
+r g?p??????g???p????g???p???????g^!!7g^
+r g?p??????????????????? ?????g?
+r g?p:????????????????:??????g?
+r g??p?????g:!!~?p?????????:?g??
+r g??p????g:^:p????::::g???
+r g???p???????????????g???
+r g??p::????????????????g?
+r g??p:???????????????????::g?
+r g?p?:???????????????????????:g?
+r g?:p???????????????????????????g?
+r g?p??????????????????????????????:g?
+r g?:?p????g?^b!~~^^::g?p???????????????:g?
+r g?::g?p?????g?:!bJ#####!g:?p??????????:::g?
+r g:!b###!:g?p?????g?~b####~:g?p???g?p????????g??
+r g:!b#######~g?p?????g?b7#7:g?p????g?p???????g?
+r g~b##########!g?p????g?b7#g~ ?p???g?:~!7~?p?:g?
+r g!b############!:g?p??~b###!~g^~!7b#####g~?p:g?
+r g~b###############77#################g^p?g?
+r g?g:b###################################7:g?
+r g??g^b####################################:g?
+r g?:??g^b####################################:g?
+r g??p?????g:b###################################7?:g^
+r g?p:!!^???g?b~######################g777b#########g^p^YPg^
+r g?p#GG5^???g:b!###################7g:p???b:~######~?~JJ#g? g?:^^^:?
+r g?p:~^:?????g:b!##################g:p?~#!:g?b!####~g??p:YGGg# g?p~#5PGGGGGPJg:
+r g?p????????:?g?b^7###############7g?p^PGG7g?:b##!g:p???~GGGGg: g~p5PGGGGGGGGGgg5
+r g?p???????????g?b^!#############7g?p:^^::?g?b^g^p????:JGGGGg! g?p?!5PGGgP5YYY55Y~
+r g?p????????????g?:b^!7##########g:p???????????:!5GGGGGg~ g?p??:YGY~g?
+r g?p:??????::::g??? g?p^^g~~~~~~~g:p???????????7GGGGGGPg? g?p:???~7g^
+r g??:???????? ?p????????????????????~5GGGGPg^ g?p?:????g?
+r g?:p???????:?????????:??^!#Jg#: g?p:???:?g?
+r g??p???????????:::??:?g??? g?p?:???:g?
+r g??p:?????? ??? g? g?p?:???:?g?
+r g??::p?:???????g??????:p::::??g?
+r g????:p:::::::::::???g??
+r g?????????????
\ No newline at end of file
diff --git a/ProjectMakoto/Assets/AddToServer.pdn b/ProjectMakoto/Assets/AddToServer.pdn
new file mode 100644
index 00000000..892299c1
Binary files /dev/null and b/ProjectMakoto/Assets/AddToServer.pdn differ
diff --git a/ProjectMakoto/Assets/AddToServer.png b/ProjectMakoto/Assets/AddToServer.png
new file mode 100644
index 00000000..9a920f04
Binary files /dev/null and b/ProjectMakoto/Assets/AddToServer.png differ
diff --git a/ProjectMakoto/Assets/Countries.json b/ProjectMakoto/Assets/Countries.json
new file mode 100644
index 00000000..4ce947e1
--- /dev/null
+++ b/ProjectMakoto/Assets/Countries.json
@@ -0,0 +1,1262 @@
+[
+ [
+ "Andorra",
+ "EU",
+ "AD"
+ ],
+ [
+ "United Arab Emirates",
+ "AS",
+ "AE"
+ ],
+ [
+ "Afghanistan",
+ "AS",
+ "AF"
+ ],
+ [
+ "Antigua and Barbuda",
+ "NA",
+ "AG"
+ ],
+ [
+ "Anguilla",
+ "NA",
+ "AI"
+ ],
+ [
+ "Albania",
+ "EU",
+ "AL"
+ ],
+ [
+ "Armenia",
+ "AS",
+ "AM"
+ ],
+ [
+ "Angola",
+ "AF",
+ "AO"
+ ],
+ [
+ "Antarctica",
+ "AN",
+ "AQ"
+ ],
+ [
+ "Argentina",
+ "SA",
+ "AR"
+ ],
+ [
+ "American Samoa",
+ "OC",
+ "AS"
+ ],
+ [
+ "Austria",
+ "EU",
+ "AT"
+ ],
+ [
+ "Australia",
+ "OC",
+ "AU"
+ ],
+ [
+ "Aruba",
+ "NA",
+ "AW"
+ ],
+ [
+ "Aland Islands",
+ "EU",
+ "AX"
+ ],
+ [
+ "Azerbaijan",
+ "AS",
+ "AZ"
+ ],
+ [
+ "Bosnia and Herzegovina",
+ "EU",
+ "BA"
+ ],
+ [
+ "Barbados",
+ "NA",
+ "BB"
+ ],
+ [
+ "Bangladesh",
+ "AS",
+ "BD"
+ ],
+ [
+ "Belgium",
+ "EU",
+ "BE"
+ ],
+ [
+ "Burkina Faso",
+ "AF",
+ "BF"
+ ],
+ [
+ "Bulgaria",
+ "EU",
+ "BG"
+ ],
+ [
+ "Bahrain",
+ "AS",
+ "BH"
+ ],
+ [
+ "Burundi",
+ "AF",
+ "BI"
+ ],
+ [
+ "Benin",
+ "AF",
+ "BJ"
+ ],
+ [
+ "Saint Barthelemy",
+ "NA",
+ "BL"
+ ],
+ [
+ "Bermuda",
+ "NA",
+ "BM"
+ ],
+ [
+ "Brunei",
+ "AS",
+ "BN"
+ ],
+ [
+ "Bolivia",
+ "SA",
+ "BO"
+ ],
+ [
+ "Bonaire, Saint Eustatius and Saba ",
+ "NA",
+ "BQ"
+ ],
+ [
+ "Brazil",
+ "SA",
+ "BR"
+ ],
+ [
+ "Bahamas",
+ "NA",
+ "BS"
+ ],
+ [
+ "Bhutan",
+ "AS",
+ "BT"
+ ],
+ [
+ "Bouvet Island",
+ "AN",
+ "BV"
+ ],
+ [
+ "Botswana",
+ "AF",
+ "BW"
+ ],
+ [
+ "Belarus",
+ "EU",
+ "BY"
+ ],
+ [
+ "Belize",
+ "NA",
+ "BZ"
+ ],
+ [
+ "Canada",
+ "NA",
+ "CA"
+ ],
+ [
+ "Cocos Islands",
+ "AS",
+ "CC"
+ ],
+ [
+ "Democratic Republic of the Congo",
+ "AF",
+ "CD"
+ ],
+ [
+ "Central African Republic",
+ "AF",
+ "CF"
+ ],
+ [
+ "Republic of the Congo",
+ "AF",
+ "CG"
+ ],
+ [
+ "Switzerland",
+ "EU",
+ "CH"
+ ],
+ [
+ "Ivory Coast",
+ "AF",
+ "CI"
+ ],
+ [
+ "Cook Islands",
+ "OC",
+ "CK"
+ ],
+ [
+ "Chile",
+ "SA",
+ "CL"
+ ],
+ [
+ "Cameroon",
+ "AF",
+ "CM"
+ ],
+ [
+ "China",
+ "AS",
+ "CN"
+ ],
+ [
+ "Colombia",
+ "SA",
+ "CO"
+ ],
+ [
+ "Costa Rica",
+ "NA",
+ "CR"
+ ],
+ [
+ "Cuba",
+ "NA",
+ "CU"
+ ],
+ [
+ "Cabo Verde",
+ "AF",
+ "CV"
+ ],
+ [
+ "Curacao",
+ "NA",
+ "CW"
+ ],
+ [
+ "Christmas Island",
+ "OC",
+ "CX"
+ ],
+ [
+ "Cyprus",
+ "EU",
+ "CY"
+ ],
+ [
+ "Czechia",
+ "EU",
+ "CZ"
+ ],
+ [
+ "Germany",
+ "EU",
+ "DE"
+ ],
+ [
+ "Djibouti",
+ "AF",
+ "DJ"
+ ],
+ [
+ "Denmark",
+ "EU",
+ "DK"
+ ],
+ [
+ "Dominica",
+ "NA",
+ "DM"
+ ],
+ [
+ "Dominican Republic",
+ "NA",
+ "DO"
+ ],
+ [
+ "Algeria",
+ "AF",
+ "DZ"
+ ],
+ [
+ "Ecuador",
+ "SA",
+ "EC"
+ ],
+ [
+ "Estonia",
+ "EU",
+ "EE"
+ ],
+ [
+ "Egypt",
+ "AF",
+ "EG"
+ ],
+ [
+ "Western Sahara",
+ "AF",
+ "EH"
+ ],
+ [
+ "Eritrea",
+ "AF",
+ "ER"
+ ],
+ [
+ "Spain",
+ "EU",
+ "ES"
+ ],
+ [
+ "Ethiopia",
+ "AF",
+ "ET"
+ ],
+ [
+ "Finland",
+ "EU",
+ "FI"
+ ],
+ [
+ "Fiji",
+ "OC",
+ "FJ"
+ ],
+ [
+ "Falkland Islands",
+ "SA",
+ "FK"
+ ],
+ [
+ "Micronesia",
+ "OC",
+ "FM"
+ ],
+ [
+ "Faroe Islands",
+ "EU",
+ "FO"
+ ],
+ [
+ "France",
+ "EU",
+ "FR"
+ ],
+ [
+ "Gabon",
+ "AF",
+ "GA"
+ ],
+ [
+ "United Kingdom",
+ "EU",
+ "GB"
+ ],
+ [
+ "Grenada",
+ "NA",
+ "GD"
+ ],
+ [
+ "Georgia",
+ "AS",
+ "GE"
+ ],
+ [
+ "French Guiana",
+ "SA",
+ "GF"
+ ],
+ [
+ "Guernsey",
+ "EU",
+ "GG"
+ ],
+ [
+ "Ghana",
+ "AF",
+ "GH"
+ ],
+ [
+ "Gibraltar",
+ "EU",
+ "GI"
+ ],
+ [
+ "Greenland",
+ "NA",
+ "GL"
+ ],
+ [
+ "Gambia",
+ "AF",
+ "GM"
+ ],
+ [
+ "Guinea",
+ "AF",
+ "GN"
+ ],
+ [
+ "Guadeloupe",
+ "NA",
+ "GP"
+ ],
+ [
+ "Equatorial Guinea",
+ "AF",
+ "GQ"
+ ],
+ [
+ "Greece",
+ "EU",
+ "GR"
+ ],
+ [
+ "South Georgia and the South Sandwich Islands",
+ "AN",
+ "GS"
+ ],
+ [
+ "Guatemala",
+ "NA",
+ "GT"
+ ],
+ [
+ "Guam",
+ "OC",
+ "GU"
+ ],
+ [
+ "Guinea-Bissau",
+ "AF",
+ "GW"
+ ],
+ [
+ "Guyana",
+ "SA",
+ "GY"
+ ],
+ [
+ "Hong Kong",
+ "AS",
+ "HK"
+ ],
+ [
+ "Heard Island and McDonald Islands",
+ "AN",
+ "HM"
+ ],
+ [
+ "Honduras",
+ "NA",
+ "HN"
+ ],
+ [
+ "Croatia",
+ "EU",
+ "HR"
+ ],
+ [
+ "Haiti",
+ "NA",
+ "HT"
+ ],
+ [
+ "Hungary",
+ "EU",
+ "HU"
+ ],
+ [
+ "Indonesia",
+ "AS",
+ "ID"
+ ],
+ [
+ "Ireland",
+ "EU",
+ "IE"
+ ],
+ [
+ "Israel",
+ "AS",
+ "IL"
+ ],
+ [
+ "Isle of Man",
+ "EU",
+ "IM"
+ ],
+ [
+ "India",
+ "AS",
+ "IN"
+ ],
+ [
+ "British Indian Ocean Territory",
+ "AS",
+ "IO"
+ ],
+ [
+ "Iraq",
+ "AS",
+ "IQ"
+ ],
+ [
+ "Iran",
+ "AS",
+ "IR"
+ ],
+ [
+ "Iceland",
+ "EU",
+ "IS"
+ ],
+ [
+ "Italy",
+ "EU",
+ "IT"
+ ],
+ [
+ "Jersey",
+ "EU",
+ "JE"
+ ],
+ [
+ "Jamaica",
+ "NA",
+ "JM"
+ ],
+ [
+ "Jordan",
+ "AS",
+ "JO"
+ ],
+ [
+ "Japan",
+ "AS",
+ "JP"
+ ],
+ [
+ "Kenya",
+ "AF",
+ "KE"
+ ],
+ [
+ "Kyrgyzstan",
+ "AS",
+ "KG"
+ ],
+ [
+ "Cambodia",
+ "AS",
+ "KH"
+ ],
+ [
+ "Kiribati",
+ "OC",
+ "KI"
+ ],
+ [
+ "Comoros",
+ "AF",
+ "KM"
+ ],
+ [
+ "Saint Kitts and Nevis",
+ "NA",
+ "KN"
+ ],
+ [
+ "North Korea",
+ "AS",
+ "KP"
+ ],
+ [
+ "South Korea",
+ "AS",
+ "KR"
+ ],
+ [
+ "Kosovo",
+ "EU",
+ "XK"
+ ],
+ [
+ "Kuwait",
+ "AS",
+ "KW"
+ ],
+ [
+ "Cayman Islands",
+ "NA",
+ "KY"
+ ],
+ [
+ "Kazakhstan",
+ "AS",
+ "KZ"
+ ],
+ [
+ "Laos",
+ "AS",
+ "LA"
+ ],
+ [
+ "Lebanon",
+ "AS",
+ "LB"
+ ],
+ [
+ "Saint Lucia",
+ "NA",
+ "LC"
+ ],
+ [
+ "Liechtenstein",
+ "EU",
+ "LI"
+ ],
+ [
+ "Sri Lanka",
+ "AS",
+ "LK"
+ ],
+ [
+ "Liberia",
+ "AF",
+ "LR"
+ ],
+ [
+ "Lesotho",
+ "AF",
+ "LS"
+ ],
+ [
+ "Lithuania",
+ "EU",
+ "LT"
+ ],
+ [
+ "Luxembourg",
+ "EU",
+ "LU"
+ ],
+ [
+ "Latvia",
+ "EU",
+ "LV"
+ ],
+ [
+ "Libya",
+ "AF",
+ "LY"
+ ],
+ [
+ "Morocco",
+ "AF",
+ "MA"
+ ],
+ [
+ "Monaco",
+ "EU",
+ "MC"
+ ],
+ [
+ "Moldova",
+ "EU",
+ "MD"
+ ],
+ [
+ "Montenegro",
+ "EU",
+ "ME"
+ ],
+ [
+ "Saint Martin",
+ "NA",
+ "MF"
+ ],
+ [
+ "Madagascar",
+ "AF",
+ "MG"
+ ],
+ [
+ "Marshall Islands",
+ "OC",
+ "MH"
+ ],
+ [
+ "North Macedonia",
+ "EU",
+ "MK"
+ ],
+ [
+ "Mali",
+ "AF",
+ "ML"
+ ],
+ [
+ "Myanmar",
+ "AS",
+ "MM"
+ ],
+ [
+ "Mongolia",
+ "AS",
+ "MN"
+ ],
+ [
+ "Macao",
+ "AS",
+ "MO"
+ ],
+ [
+ "Northern Mariana Islands",
+ "OC",
+ "MP"
+ ],
+ [
+ "Martinique",
+ "NA",
+ "MQ"
+ ],
+ [
+ "Mauritania",
+ "AF",
+ "MR"
+ ],
+ [
+ "Montserrat",
+ "NA",
+ "MS"
+ ],
+ [
+ "Malta",
+ "EU",
+ "MT"
+ ],
+ [
+ "Mauritius",
+ "AF",
+ "MU"
+ ],
+ [
+ "Maldives",
+ "AS",
+ "MV"
+ ],
+ [
+ "Malawi",
+ "AF",
+ "MW"
+ ],
+ [
+ "Mexico",
+ "NA",
+ "MX"
+ ],
+ [
+ "Malaysia",
+ "AS",
+ "MY"
+ ],
+ [
+ "Mozambique",
+ "AF",
+ "MZ"
+ ],
+ [
+ "Namibia",
+ "AF",
+ "NA"
+ ],
+ [
+ "New Caledonia",
+ "OC",
+ "NC"
+ ],
+ [
+ "Niger",
+ "AF",
+ "NE"
+ ],
+ [
+ "Norfolk Island",
+ "OC",
+ "NF"
+ ],
+ [
+ "Nigeria",
+ "AF",
+ "NG"
+ ],
+ [
+ "Nicaragua",
+ "NA",
+ "NI"
+ ],
+ [
+ "Netherlands",
+ "EU",
+ "NL"
+ ],
+ [
+ "Norway",
+ "EU",
+ "NO"
+ ],
+ [
+ "Nepal",
+ "AS",
+ "NP"
+ ],
+ [
+ "Nauru",
+ "OC",
+ "NR"
+ ],
+ [
+ "Niue",
+ "OC",
+ "NU"
+ ],
+ [
+ "New Zealand",
+ "OC",
+ "NZ"
+ ],
+ [
+ "Oman",
+ "AS",
+ "OM"
+ ],
+ [
+ "Panama",
+ "NA",
+ "PA"
+ ],
+ [
+ "Peru",
+ "SA",
+ "PE"
+ ],
+ [
+ "French Polynesia",
+ "OC",
+ "PF"
+ ],
+ [
+ "Papua New Guinea",
+ "OC",
+ "PG"
+ ],
+ [
+ "Philippines",
+ "AS",
+ "PH"
+ ],
+ [
+ "Pakistan",
+ "AS",
+ "PK"
+ ],
+ [
+ "Poland",
+ "EU",
+ "PL"
+ ],
+ [
+ "Saint Pierre and Miquelon",
+ "NA",
+ "PM"
+ ],
+ [
+ "Pitcairn",
+ "OC",
+ "PN"
+ ],
+ [
+ "Puerto Rico",
+ "NA",
+ "PR"
+ ],
+ [
+ "Palestinian Territory",
+ "AS",
+ "PS"
+ ],
+ [
+ "Portugal",
+ "EU",
+ "PT"
+ ],
+ [
+ "Palau",
+ "OC",
+ "PW"
+ ],
+ [
+ "Paraguay",
+ "SA",
+ "PY"
+ ],
+ [
+ "Qatar",
+ "AS",
+ "QA"
+ ],
+ [
+ "Reunion",
+ "AF",
+ "RE"
+ ],
+ [
+ "Romania",
+ "EU",
+ "RO"
+ ],
+ [
+ "Serbia",
+ "EU",
+ "RS"
+ ],
+ [
+ "Russia",
+ "EU",
+ "RU"
+ ],
+ [
+ "Rwanda",
+ "AF",
+ "RW"
+ ],
+ [
+ "Saudi Arabia",
+ "AS",
+ "SA"
+ ],
+ [
+ "Solomon Islands",
+ "OC",
+ "SB"
+ ],
+ [
+ "Seychelles",
+ "AF",
+ "SC"
+ ],
+ [
+ "Sudan",
+ "AF",
+ "SD"
+ ],
+ [
+ "South Sudan",
+ "AF",
+ "SS"
+ ],
+ [
+ "Sweden",
+ "EU",
+ "SE"
+ ],
+ [
+ "Singapore",
+ "AS",
+ "SG"
+ ],
+ [
+ "Saint Helena",
+ "AF",
+ "SH"
+ ],
+ [
+ "Slovenia",
+ "EU",
+ "SI"
+ ],
+ [
+ "Svalbard and Jan Mayen",
+ "EU",
+ "SJ"
+ ],
+ [
+ "Slovakia",
+ "EU",
+ "SK"
+ ],
+ [
+ "Sierra Leone",
+ "AF",
+ "SL"
+ ],
+ [
+ "San Marino",
+ "EU",
+ "SM"
+ ],
+ [
+ "Senegal",
+ "AF",
+ "SN"
+ ],
+ [
+ "Somalia",
+ "AF",
+ "SO"
+ ],
+ [
+ "Suriname",
+ "SA",
+ "SR"
+ ],
+ [
+ "Sao Tome and Principe",
+ "AF",
+ "ST"
+ ],
+ [
+ "El Salvador",
+ "NA",
+ "SV"
+ ],
+ [
+ "Sint Maarten",
+ "NA",
+ "SX"
+ ],
+ [
+ "Syria",
+ "AS",
+ "SY"
+ ],
+ [
+ "Eswatini",
+ "AF",
+ "SZ"
+ ],
+ [
+ "Turks and Caicos Islands",
+ "NA",
+ "TC"
+ ],
+ [
+ "Chad",
+ "AF",
+ "TD"
+ ],
+ [
+ "French Southern Territories",
+ "AN",
+ "TF"
+ ],
+ [
+ "Togo",
+ "AF",
+ "TG"
+ ],
+ [
+ "Thailand",
+ "AS",
+ "TH"
+ ],
+ [
+ "Tajikistan",
+ "AS",
+ "TJ"
+ ],
+ [
+ "Tokelau",
+ "OC",
+ "TK"
+ ],
+ [
+ "Timor Leste",
+ "OC",
+ "TL"
+ ],
+ [
+ "Turkmenistan",
+ "AS",
+ "TM"
+ ],
+ [
+ "Tunisia",
+ "AF",
+ "TN"
+ ],
+ [
+ "Tonga",
+ "OC",
+ "TO"
+ ],
+ [
+ "Turkey",
+ "AS",
+ "TR"
+ ],
+ [
+ "Trinidad and Tobago",
+ "NA",
+ "TT"
+ ],
+ [
+ "Tuvalu",
+ "OC",
+ "TV"
+ ],
+ [
+ "Taiwan",
+ "AS",
+ "TW"
+ ],
+ [
+ "Tanzania",
+ "AF",
+ "TZ"
+ ],
+ [
+ "Ukraine",
+ "EU",
+ "UA"
+ ],
+ [
+ "Uganda",
+ "AF",
+ "UG"
+ ],
+ [
+ "United States Minor Outlying Islands",
+ "OC",
+ "UM"
+ ],
+ [
+ "United States",
+ "NA",
+ "US"
+ ],
+ [
+ "Uruguay",
+ "SA",
+ "UY"
+ ],
+ [
+ "Uzbekistan",
+ "AS",
+ "UZ"
+ ],
+ [
+ "Vatican",
+ "EU",
+ "VA"
+ ],
+ [
+ "Saint Vincent and the Grenadines",
+ "NA",
+ "VC"
+ ],
+ [
+ "Venezuela",
+ "SA",
+ "VE"
+ ],
+ [
+ "British Virgin Islands",
+ "NA",
+ "VG"
+ ],
+ [
+ "U.S. Virgin Islands",
+ "NA",
+ "VI"
+ ],
+ [
+ "Vietnam",
+ "AS",
+ "VN"
+ ],
+ [
+ "Vanuatu",
+ "OC",
+ "VU"
+ ],
+ [
+ "Wallis and Futuna",
+ "OC",
+ "WF"
+ ],
+ [
+ "Samoa",
+ "OC",
+ "WS"
+ ],
+ [
+ "Yemen",
+ "AS",
+ "YE"
+ ],
+ [
+ "Mayotte",
+ "AF",
+ "YT"
+ ],
+ [
+ "South Africa",
+ "AF",
+ "ZA"
+ ],
+ [
+ "Zambia",
+ "AF",
+ "ZM"
+ ],
+ [
+ "Zimbabwe",
+ "AF",
+ "ZW"
+ ],
+ [
+ "Serbia and Montenegro",
+ "EU",
+ "CS"
+ ],
+ [
+ "Netherlands Antilles",
+ "NA",
+ "AN"
+ ]
+]
\ No newline at end of file
diff --git a/ProjectMakoto/Assets/Dev.pdn b/ProjectMakoto/Assets/Dev.pdn
new file mode 100644
index 00000000..16757841
Binary files /dev/null and b/ProjectMakoto/Assets/Dev.pdn differ
diff --git a/ProjectMakoto/Assets/Dev.png b/ProjectMakoto/Assets/Dev.png
new file mode 100644
index 00000000..3053b23b
Binary files /dev/null and b/ProjectMakoto/Assets/Dev.png differ
diff --git a/ProjectMakoto/Assets/DevSmall.png b/ProjectMakoto/Assets/DevSmall.png
new file mode 100644
index 00000000..ddf062f8
Binary files /dev/null and b/ProjectMakoto/Assets/DevSmall.png differ
diff --git a/ProjectMakoto/Assets/DiscordMessages.html b/ProjectMakoto/Assets/DiscordMessages.html
new file mode 100644
index 00000000..ffd91544
--- /dev/null
+++ b/ProjectMakoto/Assets/DiscordMessages.html
@@ -0,0 +1,136 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ messages deleted in on .
+ In this file, the content of messages is modified in order to properly format the messages. Want to view the raw messages? Click here.
+ Automatically generated by at .
+
+
\ No newline at end of file
diff --git a/ProjectMakoto/Assets/Emojis/Editing Files/Channel.pdn b/ProjectMakoto/Assets/Emojis/Editing Files/Channel.pdn
new file mode 100644
index 00000000..21242f1a
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Editing Files/Channel.pdn differ
diff --git a/ProjectMakoto/Assets/Emojis/Editing Files/CheckboxTickedBlue.pdn b/ProjectMakoto/Assets/Emojis/Editing Files/CheckboxTickedBlue.pdn
new file mode 100644
index 00000000..abf7b0b1
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Editing Files/CheckboxTickedBlue.pdn differ
diff --git a/ProjectMakoto/Assets/Emojis/Editing Files/CheckboxUntickedBlue.pdn b/ProjectMakoto/Assets/Emojis/Editing Files/CheckboxUntickedBlue.pdn
new file mode 100644
index 00000000..c3892f10
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Editing Files/CheckboxUntickedBlue.pdn differ
diff --git a/ProjectMakoto/Assets/Emojis/Editing Files/Guild.pdn b/ProjectMakoto/Assets/Emojis/Editing Files/Guild.pdn
new file mode 100644
index 00000000..591a83f2
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Editing Files/Guild.pdn differ
diff --git a/ProjectMakoto/Assets/Emojis/Editing Files/Invite.pdn b/ProjectMakoto/Assets/Emojis/Editing Files/Invite.pdn
new file mode 100644
index 00000000..eb24dd16
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Editing Files/Invite.pdn differ
diff --git a/ProjectMakoto/Assets/Emojis/Editing Files/Message.pdn b/ProjectMakoto/Assets/Emojis/Editing Files/Message.pdn
new file mode 100644
index 00000000..01a3f292
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Editing Files/Message.pdn differ
diff --git a/ProjectMakoto/Assets/Emojis/Editing Files/MessageCommand.pdn b/ProjectMakoto/Assets/Emojis/Editing Files/MessageCommand.pdn
new file mode 100644
index 00000000..3c4772ff
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Editing Files/MessageCommand.pdn differ
diff --git a/ProjectMakoto/Assets/Emojis/Editing Files/PillOff.pdn b/ProjectMakoto/Assets/Emojis/Editing Files/PillOff.pdn
new file mode 100644
index 00000000..0ce1cd81
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Editing Files/PillOff.pdn differ
diff --git a/ProjectMakoto/Assets/Emojis/Editing Files/PillOn.pdn b/ProjectMakoto/Assets/Emojis/Editing Files/PillOn.pdn
new file mode 100644
index 00000000..34a73f24
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Editing Files/PillOn.pdn differ
diff --git a/ProjectMakoto/Assets/Emojis/Editing Files/PrefixCommandDisabled.pdn b/ProjectMakoto/Assets/Emojis/Editing Files/PrefixCommandDisabled.pdn
new file mode 100644
index 00000000..f55061ea
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Editing Files/PrefixCommandDisabled.pdn differ
diff --git a/ProjectMakoto/Assets/Emojis/Editing Files/PrefixCommandEnabled.pdn b/ProjectMakoto/Assets/Emojis/Editing Files/PrefixCommandEnabled.pdn
new file mode 100644
index 00000000..c15e234b
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Editing Files/PrefixCommandEnabled.pdn differ
diff --git a/ProjectMakoto/Assets/Emojis/Editing Files/SlashCommand.pdn b/ProjectMakoto/Assets/Emojis/Editing Files/SlashCommand.pdn
new file mode 100644
index 00000000..7c60ecde
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Editing Files/SlashCommand.pdn differ
diff --git a/ProjectMakoto/Assets/Emojis/Editing Files/User.pdn b/ProjectMakoto/Assets/Emojis/Editing Files/User.pdn
new file mode 100644
index 00000000..115b9cbb
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Editing Files/User.pdn differ
diff --git a/ProjectMakoto/Assets/Emojis/Editing Files/UserCommand.pdn b/ProjectMakoto/Assets/Emojis/Editing Files/UserCommand.pdn
new file mode 100644
index 00000000..2c3d09a2
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Editing Files/UserCommand.pdn differ
diff --git a/ProjectMakoto/Assets/Emojis/Editing Files/VoiceStateUser.pdn b/ProjectMakoto/Assets/Emojis/Editing Files/VoiceStateUser.pdn
new file mode 100644
index 00000000..1c4e6640
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Editing Files/VoiceStateUser.pdn differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/Channel.png b/ProjectMakoto/Assets/Emojis/Upload/Channel.png
new file mode 100644
index 00000000..fdeb6c72
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/Channel.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/CheckboxTicked.png b/ProjectMakoto/Assets/Emojis/Upload/CheckboxTicked.png
new file mode 100644
index 00000000..a6840538
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/CheckboxTicked.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/CheckboxUnticked.png b/ProjectMakoto/Assets/Emojis/Upload/CheckboxUnticked.png
new file mode 100644
index 00000000..0056abf9
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/CheckboxUnticked.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/DisabledPause.png b/ProjectMakoto/Assets/Emojis/Upload/DisabledPause.png
new file mode 100644
index 00000000..a41ea426
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/DisabledPause.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/DisabledPlay.png b/ProjectMakoto/Assets/Emojis/Upload/DisabledPlay.png
new file mode 100644
index 00000000..71eaa69d
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/DisabledPlay.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/DisabledRepeat.png b/ProjectMakoto/Assets/Emojis/Upload/DisabledRepeat.png
new file mode 100644
index 00000000..67646fe8
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/DisabledRepeat.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/DisabledShuffle.png b/ProjectMakoto/Assets/Emojis/Upload/DisabledShuffle.png
new file mode 100644
index 00000000..88c6b254
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/DisabledShuffle.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/Dot.png b/ProjectMakoto/Assets/Emojis/Upload/Dot.png
new file mode 100644
index 00000000..e45f7bdb
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/Dot.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/Error.png b/ProjectMakoto/Assets/Emojis/Upload/Error.png
new file mode 100644
index 00000000..f2cdf9de
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/Error.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/Guild.png b/ProjectMakoto/Assets/Emojis/Upload/Guild.png
new file mode 100644
index 00000000..d91d4a51
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/Guild.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/In.png b/ProjectMakoto/Assets/Emojis/Upload/In.png
new file mode 100644
index 00000000..93d34040
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/In.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/Invite.png b/ProjectMakoto/Assets/Emojis/Upload/Invite.png
new file mode 100644
index 00000000..a21d35d8
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/Invite.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/Loading.gif b/ProjectMakoto/Assets/Emojis/Upload/Loading.gif
new file mode 100644
index 00000000..3136e2f2
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/Loading.gif differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/Message.png b/ProjectMakoto/Assets/Emojis/Upload/Message.png
new file mode 100644
index 00000000..30295870
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/Message.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/MessageCommand.png b/ProjectMakoto/Assets/Emojis/Upload/MessageCommand.png
new file mode 100644
index 00000000..a6c56fa7
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/MessageCommand.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/Paused.gif b/ProjectMakoto/Assets/Emojis/Upload/Paused.gif
new file mode 100644
index 00000000..05769c74
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/Paused.gif differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/PillOff.png b/ProjectMakoto/Assets/Emojis/Upload/PillOff.png
new file mode 100644
index 00000000..7018420a
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/PillOff.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/PillOn.png b/ProjectMakoto/Assets/Emojis/Upload/PillOn.png
new file mode 100644
index 00000000..ae5e68e0
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/PillOn.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/PrefixCommandDisabled.png b/ProjectMakoto/Assets/Emojis/Upload/PrefixCommandDisabled.png
new file mode 100644
index 00000000..c8278222
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/PrefixCommandDisabled.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/PrefixCommandEnabled.png b/ProjectMakoto/Assets/Emojis/Upload/PrefixCommandEnabled.png
new file mode 100644
index 00000000..5727db49
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/PrefixCommandEnabled.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/QuestionMark.png b/ProjectMakoto/Assets/Emojis/Upload/QuestionMark.png
new file mode 100644
index 00000000..251b93e8
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/QuestionMark.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/SlashCommand.png b/ProjectMakoto/Assets/Emojis/Upload/SlashCommand.png
new file mode 100644
index 00000000..c721ef8d
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/SlashCommand.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/Soundcloud.png b/ProjectMakoto/Assets/Emojis/Upload/Soundcloud.png
new file mode 100644
index 00000000..3b301b87
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/Soundcloud.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/Spotify.png b/ProjectMakoto/Assets/Emojis/Upload/Spotify.png
new file mode 100644
index 00000000..648b27b3
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/Spotify.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/User.png b/ProjectMakoto/Assets/Emojis/Upload/User.png
new file mode 100644
index 00000000..2a7f6534
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/User.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/UserCommand.png b/ProjectMakoto/Assets/Emojis/Upload/UserCommand.png
new file mode 100644
index 00000000..d5bbd50b
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/UserCommand.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/VoiceState.png b/ProjectMakoto/Assets/Emojis/Upload/VoiceState.png
new file mode 100644
index 00000000..8f26d0f6
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/VoiceState.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/YouTube.png b/ProjectMakoto/Assets/Emojis/Upload/YouTube.png
new file mode 100644
index 00000000..b772efb0
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/YouTube.png differ
diff --git a/ProjectMakoto/Assets/Emojis/Upload/abuseipdb.png b/ProjectMakoto/Assets/Emojis/Upload/abuseipdb.png
new file mode 100644
index 00000000..d7323c1f
Binary files /dev/null and b/ProjectMakoto/Assets/Emojis/Upload/abuseipdb.png differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/BanRemoved.pdn b/ProjectMakoto/Assets/Icons/Editing Files/BanRemoved.pdn
new file mode 100644
index 00000000..d2151683
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/BanRemoved.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/ChannelAdded.pdn b/ProjectMakoto/Assets/Icons/Editing Files/ChannelAdded.pdn
new file mode 100644
index 00000000..1bf3097b
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/ChannelAdded.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/ChannelRemoved.pdn b/ProjectMakoto/Assets/Icons/Editing Files/ChannelRemoved.pdn
new file mode 100644
index 00000000..5e4cf571
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/ChannelRemoved.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/ChannelUpdated.pdn b/ProjectMakoto/Assets/Icons/Editing Files/ChannelUpdated.pdn
new file mode 100644
index 00000000..6deeb161
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/ChannelUpdated.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/GuildUpdated.pdn b/ProjectMakoto/Assets/Icons/Editing Files/GuildUpdated.pdn
new file mode 100644
index 00000000..a9b378fa
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/GuildUpdated.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/InviteAdded.pdn b/ProjectMakoto/Assets/Icons/Editing Files/InviteAdded.pdn
new file mode 100644
index 00000000..e62c1c22
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/InviteAdded.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/InviteRemoved.pdn b/ProjectMakoto/Assets/Icons/Editing Files/InviteRemoved.pdn
new file mode 100644
index 00000000..5c981f81
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/InviteRemoved.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/MessageRemoved.pdn b/ProjectMakoto/Assets/Icons/Editing Files/MessageRemoved.pdn
new file mode 100644
index 00000000..6077178d
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/MessageRemoved.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/MessageUpdated.pdn b/ProjectMakoto/Assets/Icons/Editing Files/MessageUpdated.pdn
new file mode 100644
index 00000000..929dd242
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/MessageUpdated.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/UserAdded.pdn b/ProjectMakoto/Assets/Icons/Editing Files/UserAdded.pdn
new file mode 100644
index 00000000..a19f24cf
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/UserAdded.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/UserBanned.pdn b/ProjectMakoto/Assets/Icons/Editing Files/UserBanned.pdn
new file mode 100644
index 00000000..3838e844
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/UserBanned.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/UserKicked.pdn b/ProjectMakoto/Assets/Icons/Editing Files/UserKicked.pdn
new file mode 100644
index 00000000..610eec89
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/UserKicked.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/UserRemoved.pdn b/ProjectMakoto/Assets/Icons/Editing Files/UserRemoved.pdn
new file mode 100644
index 00000000..8eb1a69f
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/UserRemoved.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/UserUpdated.pdn b/ProjectMakoto/Assets/Icons/Editing Files/UserUpdated.pdn
new file mode 100644
index 00000000..a4e65455
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/UserUpdated.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/UserWarned.pdn b/ProjectMakoto/Assets/Icons/Editing Files/UserWarned.pdn
new file mode 100644
index 00000000..c64ae41e
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/UserWarned.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/VoiceStateUserJoined.pdn b/ProjectMakoto/Assets/Icons/Editing Files/VoiceStateUserJoined.pdn
new file mode 100644
index 00000000..f2eb1dba
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/VoiceStateUserJoined.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/VoiceStateUserLeft.pdn b/ProjectMakoto/Assets/Icons/Editing Files/VoiceStateUserLeft.pdn
new file mode 100644
index 00000000..c4f8015f
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/VoiceStateUserLeft.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Editing Files/VoiceStateUserUpdated.pdn b/ProjectMakoto/Assets/Icons/Editing Files/VoiceStateUserUpdated.pdn
new file mode 100644
index 00000000..263e0c82
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Editing Files/VoiceStateUserUpdated.pdn differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/BanRemoved.png b/ProjectMakoto/Assets/Icons/Upload/BanRemoved.png
new file mode 100644
index 00000000..cf9c9ac1
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/BanRemoved.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/ChannelAdded.png b/ProjectMakoto/Assets/Icons/Upload/ChannelAdded.png
new file mode 100644
index 00000000..52649f30
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/ChannelAdded.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/ChannelRemoved.png b/ProjectMakoto/Assets/Icons/Upload/ChannelRemoved.png
new file mode 100644
index 00000000..c72a03a3
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/ChannelRemoved.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/ChannelUpdated.png b/ProjectMakoto/Assets/Icons/Upload/ChannelUpdated.png
new file mode 100644
index 00000000..d518cc79
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/ChannelUpdated.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/CheckMark Icon.png b/ProjectMakoto/Assets/Icons/Upload/CheckMark Icon.png
new file mode 100644
index 00000000..77b23624
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/CheckMark Icon.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/Error Icon.png b/ProjectMakoto/Assets/Icons/Upload/Error Icon.png
new file mode 100644
index 00000000..f0846ec7
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/Error Icon.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/GuildUpdated.png b/ProjectMakoto/Assets/Icons/Upload/GuildUpdated.png
new file mode 100644
index 00000000..d3d60f98
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/GuildUpdated.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/InviteAdded.png b/ProjectMakoto/Assets/Icons/Upload/InviteAdded.png
new file mode 100644
index 00000000..777d4d76
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/InviteAdded.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/InviteRemoved.png b/ProjectMakoto/Assets/Icons/Upload/InviteRemoved.png
new file mode 100644
index 00000000..6f915441
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/InviteRemoved.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/MessageRemoved.png b/ProjectMakoto/Assets/Icons/Upload/MessageRemoved.png
new file mode 100644
index 00000000..252f9a17
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/MessageRemoved.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/MessageUpdated.png b/ProjectMakoto/Assets/Icons/Upload/MessageUpdated.png
new file mode 100644
index 00000000..a280a7d6
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/MessageUpdated.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/UserAdded.png b/ProjectMakoto/Assets/Icons/Upload/UserAdded.png
new file mode 100644
index 00000000..ef6c163c
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/UserAdded.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/UserBanned.png b/ProjectMakoto/Assets/Icons/Upload/UserBanned.png
new file mode 100644
index 00000000..a1e6cafc
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/UserBanned.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/UserKicked.png b/ProjectMakoto/Assets/Icons/Upload/UserKicked.png
new file mode 100644
index 00000000..262c09b6
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/UserKicked.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/UserRemoved.png b/ProjectMakoto/Assets/Icons/Upload/UserRemoved.png
new file mode 100644
index 00000000..f415d01f
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/UserRemoved.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/UserUpdated.png b/ProjectMakoto/Assets/Icons/Upload/UserUpdated.png
new file mode 100644
index 00000000..37c00c20
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/UserUpdated.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/UserWarned.png b/ProjectMakoto/Assets/Icons/Upload/UserWarned.png
new file mode 100644
index 00000000..82e9e99c
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/UserWarned.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/VoiceStateUserJoined.png b/ProjectMakoto/Assets/Icons/Upload/VoiceStateUserJoined.png
new file mode 100644
index 00000000..64f7cd12
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/VoiceStateUserJoined.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/VoiceStateUserLeft.png b/ProjectMakoto/Assets/Icons/Upload/VoiceStateUserLeft.png
new file mode 100644
index 00000000..cc7013eb
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/VoiceStateUserLeft.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/VoiceStateUserUpdated.png b/ProjectMakoto/Assets/Icons/Upload/VoiceStateUserUpdated.png
new file mode 100644
index 00000000..212d01fb
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/VoiceStateUserUpdated.png differ
diff --git a/ProjectMakoto/Assets/Icons/Upload/Warning.png b/ProjectMakoto/Assets/Icons/Upload/Warning.png
new file mode 100644
index 00000000..24c549b4
Binary files /dev/null and b/ProjectMakoto/Assets/Icons/Upload/Warning.png differ
diff --git a/ProjectMakoto/Assets/Languages.json b/ProjectMakoto/Assets/Languages.json
new file mode 100644
index 00000000..ae7bb6e0
--- /dev/null
+++ b/ProjectMakoto/Assets/Languages.json
@@ -0,0 +1,422 @@
+[
+ [
+ "auto",
+ "Auto Detect"
+ ],
+ [
+ "en",
+ "English"
+ ],
+ [
+ "de",
+ "German"
+ ],
+ [
+ "af",
+ "Afrikaans"
+ ],
+ [
+ "sq",
+ "Albanian"
+ ],
+ [
+ "am",
+ "Amharic"
+ ],
+ [
+ "ar",
+ "Arabic"
+ ],
+ [
+ "hy",
+ "Armenian"
+ ],
+ [
+ "az",
+ "Azerbaijani"
+ ],
+ [
+ "eu",
+ "Basque"
+ ],
+ [
+ "be",
+ "Belarusian"
+ ],
+ [
+ "bn",
+ "Bengali"
+ ],
+ [
+ "bs",
+ "Bosnian"
+ ],
+ [
+ "bg",
+ "Bulgarian"
+ ],
+ [
+ "ca",
+ "Catalan"
+ ],
+ [
+ "ceb",
+ "Cebuano"
+ ],
+ [
+ "ny",
+ "Chichewa"
+ ],
+ [
+ "zh-cn",
+ "Chinese Simplified"
+ ],
+ [
+ "zh-tw",
+ "Chinese Traditional"
+ ],
+ [
+ "co",
+ "Corsican"
+ ],
+ [
+ "hr",
+ "Croatian"
+ ],
+ [
+ "cs",
+ "Czech"
+ ],
+ [
+ "da",
+ "Danish"
+ ],
+ [
+ "nl",
+ "Dutch"
+ ],
+ [
+ "eo",
+ "Esperanto"
+ ],
+ [
+ "et",
+ "Estonian"
+ ],
+ [
+ "tl",
+ "Filipino"
+ ],
+ [
+ "fi",
+ "Finnish"
+ ],
+ [
+ "fr",
+ "French"
+ ],
+ [
+ "fy",
+ "Frisian"
+ ],
+ [
+ "gl",
+ "Galician"
+ ],
+ [
+ "ka",
+ "Georgian"
+ ],
+ [
+ "el",
+ "Greek"
+ ],
+ [
+ "gu",
+ "Gujarati"
+ ],
+ [
+ "ht",
+ "Haitian Creole"
+ ],
+ [
+ "ha",
+ "Hausa"
+ ],
+ [
+ "haw",
+ "Hawaiian"
+ ],
+ [
+ "iw",
+ "Hebrew"
+ ],
+ [
+ "hi",
+ "Hindi"
+ ],
+ [
+ "hmn",
+ "Hmong"
+ ],
+ [
+ "hu",
+ "Hungarian"
+ ],
+ [
+ "is",
+ "Icelandic"
+ ],
+ [
+ "ig",
+ "Igbo"
+ ],
+ [
+ "id",
+ "Indonesian"
+ ],
+ [
+ "ga",
+ "Irish"
+ ],
+ [
+ "it",
+ "Italian"
+ ],
+ [
+ "ja",
+ "Japanese"
+ ],
+ [
+ "jw",
+ "Javanese"
+ ],
+ [
+ "kn",
+ "Kannada"
+ ],
+ [
+ "kk",
+ "Kazakh"
+ ],
+ [
+ "km",
+ "Khmer"
+ ],
+ [
+ "ko",
+ "Korean"
+ ],
+ [
+ "ku",
+ "Kurdish (Kurmanji)"
+ ],
+ [
+ "ky",
+ "Kyrgyz"
+ ],
+ [
+ "lo",
+ "Lao"
+ ],
+ [
+ "la",
+ "Latin"
+ ],
+ [
+ "lv",
+ "Latvian"
+ ],
+ [
+ "lt",
+ "Lithuanian"
+ ],
+ [
+ "lb",
+ "Luxembourgish"
+ ],
+ [
+ "mk",
+ "Macedonian"
+ ],
+ [
+ "mg",
+ "Malagasy"
+ ],
+ [
+ "ms",
+ "Malay"
+ ],
+ [
+ "ml",
+ "Malayalam"
+ ],
+ [
+ "mt",
+ "Maltese"
+ ],
+ [
+ "mi",
+ "Maori"
+ ],
+ [
+ "mr",
+ "Marathi"
+ ],
+ [
+ "mn",
+ "Mongolian"
+ ],
+ [
+ "my",
+ "Myanmar (Burmese)"
+ ],
+ [
+ "ne",
+ "Nepali"
+ ],
+ [
+ "no",
+ "Norwegian"
+ ],
+ [
+ "ps",
+ "Pashto"
+ ],
+ [
+ "fa",
+ "Persian"
+ ],
+ [
+ "pl",
+ "Polish"
+ ],
+ [
+ "pt",
+ "Portuguese"
+ ],
+ [
+ "ma",
+ "Punjabi"
+ ],
+ [
+ "ro",
+ "Romanian"
+ ],
+ [
+ "ru",
+ "Russian"
+ ],
+ [
+ "sm",
+ "Samoan"
+ ],
+ [
+ "gd",
+ "Scots Gaelic"
+ ],
+ [
+ "sr",
+ "Serbian"
+ ],
+ [
+ "st",
+ "Sesotho"
+ ],
+ [
+ "sn",
+ "Shona"
+ ],
+ [
+ "sd",
+ "Sindhi"
+ ],
+ [
+ "si",
+ "Sinhala"
+ ],
+ [
+ "sk",
+ "Slovak"
+ ],
+ [
+ "sl",
+ "Slovenian"
+ ],
+ [
+ "so",
+ "Somali"
+ ],
+ [
+ "es",
+ "Spanish"
+ ],
+ [
+ "su",
+ "Sundanese"
+ ],
+ [
+ "sw",
+ "Swahili"
+ ],
+ [
+ "sv",
+ "Swedish"
+ ],
+ [
+ "tg",
+ "Tajik"
+ ],
+ [
+ "ta",
+ "Tamil"
+ ],
+ [
+ "te",
+ "Telugu"
+ ],
+ [
+ "th",
+ "Thai"
+ ],
+ [
+ "tr",
+ "Turkish"
+ ],
+ [
+ "uk",
+ "Ukrainian"
+ ],
+ [
+ "ur",
+ "Urdu"
+ ],
+ [
+ "uz",
+ "Uzbek"
+ ],
+ [
+ "vi",
+ "Vietnamese"
+ ],
+ [
+ "cy",
+ "Welsh"
+ ],
+ [
+ "xh",
+ "Xhosa"
+ ],
+ [
+ "yi",
+ "Yiddish"
+ ],
+ [
+ "yo",
+ "Yoruba"
+ ],
+ [
+ "zu",
+ "Zulu"
+ ]
+]
\ No newline at end of file
diff --git a/ProjectMakoto/Assets/Original.png b/ProjectMakoto/Assets/Original.png
new file mode 100644
index 00000000..b9339e21
Binary files /dev/null and b/ProjectMakoto/Assets/Original.png differ
diff --git a/ProjectMakoto/Assets/Pre.png b/ProjectMakoto/Assets/Pre.png
new file mode 100644
index 00000000..b1e33eae
Binary files /dev/null and b/ProjectMakoto/Assets/Pre.png differ
diff --git a/ProjectMakoto/Assets/PreSmall.png b/ProjectMakoto/Assets/PreSmall.png
new file mode 100644
index 00000000..e5eeab40
Binary files /dev/null and b/ProjectMakoto/Assets/PreSmall.png differ
diff --git a/ProjectMakoto/Assets/Prod.png b/ProjectMakoto/Assets/Prod.png
new file mode 100644
index 00000000..71be3a76
Binary files /dev/null and b/ProjectMakoto/Assets/Prod.png differ
diff --git a/ProjectMakoto/Assets/ProdSmall.png b/ProjectMakoto/Assets/ProdSmall.png
new file mode 100644
index 00000000..041b38f6
Binary files /dev/null and b/ProjectMakoto/Assets/ProdSmall.png differ
diff --git a/ProjectMakoto/Bot.cs b/ProjectMakoto/Bot.cs
new file mode 100644
index 00000000..9dcf4ae0
--- /dev/null
+++ b/ProjectMakoto/Bot.cs
@@ -0,0 +1,558 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+using Octokit;
+using GenHTTP.Engine;
+using GenHTTP.Modules.IO;
+using GenHTTP.Modules.Practices;
+using GenHTTP.Api.Infrastructure;
+using GenHTTP.Modules.StaticWebsites;
+using Serilog;
+using Microsoft.Extensions.Logging;
+using Serilog.Events;
+using Serilog.Core;
+using ProjectMakoto.Entities.LoggingEnrichers;
+using Status = ProjectMakoto.Entities.Status;
+using Microsoft.CodeAnalysis;
+using GenHTTP.Engine.Internal;
+
+namespace ProjectMakoto;
+
+public sealed class Bot
+{
+ #region Clients
+
+ internal DatabaseClient DatabaseClient { get; set; }
+
+ public DiscordShardedClient DiscordClient { get; internal set; }
+
+ public ThreadJoinClient ThreadJoinClient { get; internal set; }
+ public AbuseIpDbClient AbuseIpDbClient { get; internal set; }
+ public MonitorClient MonitorClient { get; internal set; }
+ public ChartGeneration ChartsClient { get; set; }
+ public TokenInvalidatorRepository TokenInvalidator { get; internal set; }
+ public OfficialPluginRepository OfficialPlugins { get; internal set; }
+ internal GitHubClient GithubClient { get; set; }
+
+ internal IServerHost WebServer { get; set; }
+
+ #endregion Clients
+
+ #region Plugins
+ public IReadOnlyDictionary Plugins => this._Plugins.AsReadOnly();
+ internal Dictionary _Plugins { get; set; } = [];
+
+ public IReadOnlyDictionary> PluginCommandModules => this._PluginCommandModules.AsReadOnly();
+ internal Dictionary> _PluginCommandModules { get; set; } = new();
+
+ public IReadOnlyList CommandModules => this._CommandModules.AsReadOnly();
+ internal List _CommandModules { get; set; } = new();
+ #endregion
+
+ #region Util
+
+ public Translations LoadedTranslations { get; set; }
+
+ public CountryCodes CountryCodes { get; internal set; }
+ public LanguageCodes LanguageCodes { get; internal set; }
+ internal IReadOnlyList ProfanityList { get; set; }
+
+ internal BumpReminderHandler BumpReminder { get; set; }
+ internal ExperienceHandler ExperienceHandler { get; set; }
+ public TaskWatcher Watcher { get; internal set; } = new();
+
+ internal DatabaseDictionary PhishingHosts { get; set; }
+ internal DatabaseDictionary SubmittedHosts { get; set; }
+
+ #endregion Util
+
+
+ #region Bans
+
+ internal DatabaseList objectedUsers { get; set; }
+ internal DatabaseDictionary bannedUsers { get; set; }
+ internal DatabaseDictionary bannedGuilds { get; set; }
+
+ internal DatabaseDictionary globalBans { get; set; }
+ internal SelfFillingDatabaseDictionary globalNotes { get; set; }
+
+ #endregion Bans
+
+ public Status status = new();
+ public SelfFillingDatabaseDictionary Guilds { get; internal set; } = null;
+ public SelfFillingDatabaseDictionary Users { get; internal set; } = null;
+
+ internal string RawFetchedPrivacyPolicy = "";
+ internal string Prefix { get; private set; } = ";;";
+
+ internal ILoggerFactory msLoggerFactory;
+ internal Microsoft.Extensions.Logging.ILogger msLogger;
+ internal LoggingLevelSwitch loggingLevel;
+
+ internal async Task Init(string[] args)
+ {
+ var sink = new LogsSink(this);
+
+ loggingLevel = new LoggingLevelSwitch();
+
+ var loggingTemplate = "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff}] [{Level:u3}] {Message:lj}{NewLine}{Exception}{ExceptionData:j}{BadRequestException:j}";
+
+ Log.Logger = new LoggerConfiguration()
+ .MinimumLevel.ControlledBy(this.loggingLevel)
+ .WriteTo.Console(outputTemplate: loggingTemplate)
+ .WriteTo.File($"logs/{DateTime.UtcNow.Ticks}.log", LogEventLevel.Debug, outputTemplate: loggingTemplate, retainedFileTimeLimit: TimeSpan.FromDays(7))
+ .WriteTo.Sink(sink)
+ .Enrich.With()
+ .Enrich.With()
+ .CreateLogger();
+
+ this.msLoggerFactory = new LoggerFactory().AddSerilog();
+ this.msLogger = msLoggerFactory.CreateLogger("ms");
+
+ ScheduledTaskExtensions.TaskStarted += this.TaskStarted;
+ UniversalExtensions.AttachLogger(msLogger);
+
+ RenderAsciiArt();
+
+ if (args.Contains("--verbose"))
+ this.loggingLevel.MinimumLevel = LogEventLevel.Verbose;
+ else if (args.Contains("--debug"))
+ this.loggingLevel.MinimumLevel = LogEventLevel.Debug;
+
+ Log.Debug("Environment Details\n\n" +
+ "Dotnet Version: {Version}\n" +
+ "OS & Version: {OSVersion}\n\n" +
+ "OS 64x: {Is64BitOperatingSystem}\n" +
+ "Process 64x: {Is64BitProcess}\n\n" +
+ "MachineName: {MachineName}\n" +
+ "UserName: {UserName}\n" +
+ "UserDomain: {UserDomainName}\n\n" +
+ "Current Directory: {CurrentDirectory}\n" +
+ "Commandline: {Commandline}\n",
+ Environment.Version,
+ Environment.OSVersion,
+ Environment.Is64BitOperatingSystem,
+ Environment.Is64BitProcess,
+ Environment.MachineName,
+ Environment.UserName,
+ Environment.UserDomainName,
+ Environment.CurrentDirectory,
+ Regex.Replace(Environment.CommandLine, @"(--token \S*)", ""));
+
+ if (args.Contains("--build-manifests"))
+ {
+ await ManifestBuilder.BuildPluginManifests(this, args);
+ return;
+ }
+
+ this.status.RunningVersion = (File.Exists("LatestGitPush.cfg") ? await File.ReadAllLinesAsync("LatestGitPush.cfg") : new string[] { "Development-Build" })[0].Trim();
+ Log.Information("Starting up Makoto {RunningVersion}..\n", this.status.RunningVersion);
+
+ var loadDatabase = Task.Run(async () =>
+ {
+ try
+ {
+ await Util.Initializers.ConfigLoader.Load(this);
+ this.ThreadJoinClient = new ThreadJoinClient();
+ this.MonitorClient = new MonitorClient(this);
+ this.AbuseIpDbClient = new AbuseIpDbClient(this);
+ this.TokenInvalidator = new TokenInvalidatorRepository(this);
+ this.OfficialPlugins = new OfficialPluginRepository(this);
+ this.ChartsClient = new ChartGeneration(this);
+ this.GithubClient = new GitHubClient(new ProductHeaderValue("ProjectMakoto", this.status.RunningVersion))
+ {
+ Credentials = new Credentials(this.status.LoadedConfig.Secrets.Github.Token)
+ };
+
+ await Task.WhenAll(Util.Initializers.ListLoader.Load(this),
+ Util.Initializers.TranslationLoader.Load(this),
+ Util.Initializers.DependencyLoader.Load(this),
+ Task.Run(() =>
+ {
+ UniversalExtensions.LoadAllReferencedAssemblies(AppDomain.CurrentDomain);
+ }));
+
+ Util.Initializers.CommandCompiler.AssemblyReferences = AppDomain.CurrentDomain.GetAssemblies()
+ .Where(x => !x.IsDynamic && !x.Location.IsNullOrWhiteSpace())
+ .Select(x => MetadataReference.CreateFromFile(x.Location))
+ .ToList();
+
+ await Util.Initializers.PluginLoader.LoadPlugins(this);
+ _ = await DatabaseClient.InitializeDatabase(this);
+ _ = BasePlugin.RaiseDatabaseInitialized(this);
+
+ _ = Directory.CreateDirectory("WebServer");
+
+ this.WebServer = await Host.Create()
+ .Port(this.status.LoadedConfig.WebServer.Port)
+ .Console()
+ .Defaults(
+ compression: true,
+ secureUpgrade: false,
+ strictTransport: false,
+ clientCaching: true,
+ rangeSupport: false,
+ preventSniffing: false)
+ .Handler(StaticWebsite.From(ResourceTree.FromDirectory("WebServer")))
+ .StartAsync();
+
+ this.objectedUsers = new(this.DatabaseClient, "objected_users", "id", false);
+
+ this.PhishingHosts = new(this.DatabaseClient, "scam_urls", "url", this.DatabaseClient.mainDatabaseConnection, (id) =>
+ {
+ return new PhishingUrlEntry(this, id);
+ });
+
+ this.SubmittedHosts = new(this.DatabaseClient, "active_url_submissions", "messageid", this.DatabaseClient.mainDatabaseConnection, (id) =>
+ {
+ return new SubmittedUrlEntry(this, id);
+ });
+
+ this.Users = new(this.DatabaseClient, "users", "userid", this.DatabaseClient.mainDatabaseConnection, (id) =>
+ {
+ return new Entities.User(this, id);
+ });
+
+ this.Guilds = new(this.DatabaseClient, "guilds", "serverid", this.DatabaseClient.mainDatabaseConnection, (id) =>
+ {
+ return new Entities.Guild(this, id);
+ });
+
+ this.globalNotes = new(this.DatabaseClient, "globalnotes", "id", this.DatabaseClient.mainDatabaseConnection, (id) =>
+ {
+ return new Entities.GlobalNote(this, id);
+ });
+
+ this.bannedUsers = new(this.DatabaseClient, "banned_users", "id", this.DatabaseClient.mainDatabaseConnection, (id) =>
+ {
+ return new BanDetails(this, "banned_users", id);
+ });
+
+ this.bannedGuilds = new(this.DatabaseClient, "banned_guilds", "id", this.DatabaseClient.mainDatabaseConnection, (id) =>
+ {
+ return new BanDetails(this, "banned_guilds", id);
+ });
+
+ this.globalBans = new(this.DatabaseClient, "globalbans", "id", this.DatabaseClient.mainDatabaseConnection, (id) =>
+ {
+ return new BanDetails(this, "globalbans", id);
+ });
+
+ this.BumpReminder = new(this);
+ }
+ catch (Exception ex)
+ {
+ Log.Fatal(ex, "An exception occurred while initializing data");
+ await Task.Delay(5000);
+ Environment.Exit((int)ExitCodes.FailedDatabaseLogin);
+ }
+
+ _ = new PhishingUrlHandler(this).UpdatePhishingUrlDatabase();
+ }).Add(this).IsVital();
+
+ await loadDatabase.Task.WaitAsync(TimeSpan.FromSeconds(600));
+
+ var logInToDiscord = Task.Run(async () =>
+ {
+ _ = Task.Delay(60000).ContinueWith(t =>
+ {
+ if (!this.status.DiscordInitialized)
+ {
+ Log.Error("An exception occurred while trying to log into discord: {0}", "The log in took longer than 60 seconds");
+ Environment.FailFast("An exception occurred while trying to log into discord: The log in took longer than 60 seconds");
+ return;
+ }
+ });
+
+ await Util.Initializers.DisCatSharpExtensionsLoader.Load(this);
+
+ Log.Information("Connecting and authenticating with Discord..");
+ await this.DiscordClient.StartAsync();
+ await Task.Delay(2000);
+ Log.Information("Connected and authenticated with Discord as {User}.", this.DiscordClient.CurrentUser.GetUsernameWithIdentifier());
+
+ this.status.DiscordInitialized = true;
+ await BasePlugin.RaiseConnected(this);
+
+ await Util.Initializers.PostLoginTaskLoader.Load(this);
+
+ foreach (var plugin in this.Plugins)
+ _ = plugin.Value.PostLoginInternalInit().Add(this);
+
+ //foreach (var guild in this.DiscordClient.GetGuilds().Values)
+ // await this.DiscordClient.GetShard(guild.Id).BulkOverwriteGuildApplicationCommandsAsync(guild.Id, Array.Empty()).ConfigureAwait(false);
+
+ //await this.DiscordClient.GetFirstShard().BulkOverwriteGlobalApplicationCommandsAsync(Array.Empty()).ConfigureAwait(false);
+
+ _ = Task.Run(async () =>
+ {
+ if (this.status.LoadedConfig.DontModify.LastStartedVersion == this.status.RunningVersion)
+ return;
+
+ this.status.LoadedConfig.DontModify.LastStartedVersion = this.status.RunningVersion;
+ this.status.LoadedConfig.Save();
+
+ var channel = await this.DiscordClient.GetFirstShard().GetChannelAsync(this.status.LoadedConfig.Channels.GithubLog);
+ _ = await channel.SendMessageAsync(new DiscordEmbedBuilder
+ {
+ Color = EmbedColors.Success,
+ Title = $"Successfully updated to `{this.status.RunningVersion}`."
+ });
+ });
+
+ _ = Task.Run(async () =>
+ {
+ try
+ {
+ this.status.TeamOwner = this.DiscordClient.CurrentApplication.Team.Owner.Id;
+ Log.Information("Set {TeamOwner} as owner of the bot", this.status.TeamOwner);
+
+ this.status._TeamMembers.AddRange(this.DiscordClient.CurrentApplication.Team.Members.Select(x => x.User.Id));
+ Log.Information("Added {Count} users to administrator list", this.status.TeamMembers.Count);
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex, "An exception occurred trying to add team members to administrator list. Is the current bot registered in a team?");
+ }
+
+ try
+ {
+ if (this.DiscordClient.CurrentApplication.PrivacyPolicyUrl.IsNullOrWhiteSpace())
+ throw new Exception("No privacy policy was defined.");
+
+ this.RawFetchedPrivacyPolicy = await new HttpClient().GetStringAsync(this.DiscordClient.CurrentApplication.PrivacyPolicyUrl);
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex, "An exception occurred while trying to fetch the privacy policy");
+ }
+ });
+
+ _ = this.ProcessDeletionRequests().Add(this);
+ }).Add(this).IsVital();
+
+ while (!loadDatabase.Task.IsCompleted || !logInToDiscord.Task.IsCompleted)
+ await Task.Delay(100);
+
+ if (!loadDatabase.Task.IsCompletedSuccessfully)
+ {
+ Log.Fatal("An uncaught exception occurred while initializing the database.", loadDatabase.Task.Exception);
+ await Task.Delay(1000);
+ Environment.Exit((int)ExitCodes.FailedDatabaseLoad);
+ }
+
+ if (!logInToDiscord.Task.IsCompletedSuccessfully)
+ {
+ Log.Fatal("An uncaught exception occurred while initializing the discord client.", logInToDiscord.Task.Exception);
+ await Task.Delay(1000);
+ Environment.Exit((int)ExitCodes.FailedDiscordLogin);
+ }
+
+ AppDomain.CurrentDomain.ProcessExit += delegate
+ {
+ this.ExitApplication(true).Wait();
+ };
+
+ Console.CancelKeyPress += delegate
+ {
+ Log.Information("Exiting, please wait..");
+ this.ExitApplication().Wait();
+ };
+
+
+ _ = Task.Run(async () =>
+ {
+ while (true)
+ {
+ if (File.Exists("updated"))
+ {
+ File.Delete("updated");
+ await this.ExitApplication();
+ return;
+ }
+
+ await Task.Delay(1000);
+ }
+ }).Add(this).IsVital();
+
+ await Task.Delay(-1);
+ }
+
+ private static void RenderAsciiArt()
+ {
+ try
+ {
+ var ASCII = File.ReadAllText("Assets/ASCII.txt");
+ Console.WriteLine();
+ foreach (var b in ASCII)
+ {
+ switch (b)
+ {
+ case 'g':
+ Console.ForegroundColor = ConsoleColor.DarkGray;
+ break;
+ case 'b':
+ Console.ForegroundColor = ConsoleColor.Blue;
+ break;
+ case 'r':
+ Console.ForegroundColor = ConsoleColor.White;
+ break;
+ case 'p':
+ Console.ForegroundColor = ConsoleColor.DarkBlue;
+ break;
+ default:
+ Console.Write(b);
+ break;
+ }
+ }
+ Console.WriteLine("\n\n");
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex, "Failed to render ASCII art");
+ }
+
+ Console.ResetColor();
+ }
+
+ internal Task GetPrefix(DiscordMessage message)
+ {
+ return Task.Run(() =>
+ {
+ //if (IsDev)
+ // if (!_status.TeamMembers.Any(x => x == message.Author.Id))
+ // return -1;
+
+ var currentPrefix = this.Guilds.TryGetValue(message.GuildId ?? 0, out var guild) ? guild.PrefixSettings.Prefix : this.Prefix;
+
+ var CommandStart = -1;
+
+ if (!(guild?.PrefixSettings.PrefixDisabled ?? false))
+ CommandStart = CommandsNextUtilities.GetStringPrefixLength(message, currentPrefix);
+
+ if (CommandStart == -1)
+ CommandStart = CommandsNextUtilities.GetMentionPrefixLength(message, this.DiscordClient.CurrentUser);
+
+ return CommandStart;
+ });
+ }
+ bool ExitCalled = false;
+
+ internal async Task ExitApplication(bool Immediate = false)
+ {
+ _ = Task.Delay(Immediate ? TimeSpan.FromSeconds(10) : TimeSpan.FromMinutes(5)).ContinueWith(async x =>
+ {
+ if (x.IsCompletedSuccessfully)
+ {
+ Environment.Exit((int)ExitCodes.ExitTasksTimeout); // Fail-Safe in case the shutdown tasks lock up
+ await Task.Delay(5000);
+ Environment.FailFast(null);
+ }
+ });
+
+ if (this.DatabaseClient.Disposed || this.ExitCalled) // When the Database Client has been disposed, the Exit Call has already been made.
+ return;
+
+ this.ExitCalled = true;
+
+ Log.Information("Preparing to shut down Makoto..");
+
+ _ = await this.WebServer.StopAsync();
+
+ foreach (var b in this.Plugins)
+ {
+ try
+ {
+ Log.Information("Shutting down '{0}'..", b.Value.Name);
+ await b.Value.Shutdown();
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex, "Failed to shutdown", b.Value.Name);
+ }
+ }
+
+ if (this.status.DiscordInitialized && !Immediate)
+ {
+ try
+ {
+ Stopwatch sw = new();
+ sw.Start();
+
+ if (!this.status.DiscordCommandsRegistered)
+ Log.Warning("Startup is incomplete. Waiting for Startup to finish to shutdown..");
+
+ while (!this.status.DiscordCommandsRegistered && sw.ElapsedMilliseconds < TimeSpan.FromMinutes(5).TotalMilliseconds)
+ await Task.Delay(500);
+
+ await Util.Initializers.SyncTasks.ExecuteSyncTasks(this, this.DiscordClient);
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex, "Failed to run sync tasks");
+ }
+
+ try
+ {
+ Log.Information("Closing Discord Client..");
+
+ await this.DiscordClient.UpdateStatusAsync(userStatus: UserStatus.Offline);
+ await this.DiscordClient.StopAsync();
+
+ Log.Debug("Closed Discord Client.");
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex, "Failed to close Discord Client gracefully.");
+ }
+ }
+
+ await Task.Delay(500);
+ Log.Information("Goodbye!");
+
+ await Task.Delay(500);
+ Environment.Exit(0);
+ await Task.Delay(10000);
+ Environment.FailFast("Failed to exit");
+ }
+
+ private async Task ProcessDeletionRequests()
+ {
+ _ = new Func(async () =>
+ {
+ _ = this.ProcessDeletionRequests().Add(this);
+ }).CreateScheduledTask(DateTime.UtcNow.AddHours(24));
+
+ lock (this.Users)
+ {
+ foreach (var b in this.Users)
+ {
+ if ((b.Value?.Data?.DeletionRequested ?? false) && b.Value?.Data?.DeletionRequestDate.GetTimespanUntil() < TimeSpan.Zero)
+ {
+ Log.Information("Deleting profile of '{Key}'", b.Key);
+
+ _ = this.Users.Remove(b.Key);
+ this.objectedUsers.Add(b.Key);
+ foreach (var c in this.DiscordClient.GetGuilds().Where(x => x.Value.OwnerId == b.Key))
+ {
+ try
+ { Log.Information("Leaving guild '{guild}'..", c.Key); _ = c.Value.LeaveAsync().Add(this); }
+ catch { }
+ }
+ }
+ }
+ }
+ }
+
+ internal Task GuildDownloadCompleted(DiscordClient sender, GuildDownloadCompletedEventArgs e)
+ => Util.Initializers.SyncTasks.GuildDownloadCompleted(this, sender, e);
+
+ internal void TaskStarted(object? sender, Xorog.UniversalExtensions.EventArgs.ScheduledTaskStartedEventArgs e)
+ => this.Watcher.TaskStarted(this, sender, e);
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/AutocompleteProviders.cs b/ProjectMakoto/Commands/AutocompleteProviders.cs
new file mode 100644
index 00000000..d3e515f9
--- /dev/null
+++ b/ProjectMakoto/Commands/AutocompleteProviders.cs
@@ -0,0 +1,84 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProjectMakoto.Commands;
+public class AutocompleteProviders
+{
+ public sealed class HelpAutoComplete : IAutocompleteProvider
+ {
+ private static readonly string[] separator = new string[] { "-", "_" };
+
+ public async Task> Provider(AutocompleteContext ctx)
+ {
+ try
+ {
+ var bot = ((Bot)ctx.Services.GetService(typeof(Bot)));
+
+ var filteredCommands = bot.DiscordClient.GetShard(ctx.Guild).GetCommandList(bot)
+ .Where(x => x.Name.Contains(ctx.FocusedOption.Value.ToString(), StringComparison.InvariantCultureIgnoreCase))
+ .Where(x => !x.DefaultMemberPermissions.HasValue || ctx.Member.Permissions.HasPermission(x.DefaultMemberPermissions.Value))
+ .Where(x => x.Type == ApplicationCommandType.ChatInput)
+ .Take(25);
+
+ var options = filteredCommands
+ .Select(x => new DiscordApplicationCommandAutocompleteChoice(string.Join("-", x.Name.Split(separator, StringSplitOptions.None)
+ .Select(x => x.FirstLetterToUpper())), x.Name))
+ .ToList();
+ return options.AsEnumerable();
+ }
+ catch (Exception)
+ {
+ return new List().AsEnumerable();
+ }
+ }
+ }
+
+ public sealed class ReportTranslationAutoComplete : IAutocompleteProvider
+ {
+ public async Task> Provider(AutocompleteContext ctx)
+ {
+ try
+ {
+ switch ((ReportTranslationType)Enum.Parse(typeof(ReportTranslationType), ctx.Options.First(x => x.Name == "affected_type").RawValue))
+ {
+ case ReportTranslationType.Miscellaneous:
+ return new List();
+ case ReportTranslationType.Command:
+ return await new HelpAutoComplete().Provider(ctx);
+ case ReportTranslationType.Event:
+ {
+ var filteredTypes = Assembly.GetAssembly(this.GetType()).GetTypes()
+ .Where(t => String.Equals(t.Namespace, "ProjectMakoto.Events", StringComparison.Ordinal))
+ .Where(t => !t.Name.StartsWith('<'))
+ .Where(x => x.Name.Contains(ctx.FocusedOption.Value.ToString(), StringComparison.InvariantCultureIgnoreCase))
+ .Take(25);
+
+ var options = filteredTypes
+ .Select(x => new DiscordApplicationCommandAutocompleteChoice(x.Name.Replace("Events", ""), x.FullName))
+ .ToList();
+
+ return options;
+ }
+ default:
+ return new List();
+ }
+ }
+ catch (Exception)
+ {
+ return new List();
+ }
+ }
+ }
+}
diff --git a/ProjectMakoto/Commands/BaseCommand.cs b/ProjectMakoto/Commands/BaseCommand.cs
new file mode 100644
index 00000000..285ad09b
--- /dev/null
+++ b/ProjectMakoto/Commands/BaseCommand.cs
@@ -0,0 +1,1714 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+using DisCatSharp.Extensions.TwoFactorCommands.Enums;
+
+namespace ProjectMakoto.Commands;
+
+public abstract class BaseCommand
+{
+ public SharedCommandContext ctx { private get; set; }
+ public Translations t { get; set; }
+
+ #region Execution
+ public virtual async Task BeforeExecution(SharedCommandContext ctx)
+ {
+ return true;
+ }
+
+ public abstract Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments = null);
+
+ public async Task TransferCommand(SharedCommandContext ctx, Dictionary arguments = null)
+ {
+ this.t = ctx.Bot.LoadedTranslations;
+ this.ctx = ctx;
+
+ ctx.Transferred = true;
+
+ if (await this.BasePreExecutionCheck())
+ await this.ExecuteCommand(this.ctx, arguments).Add(ctx.Bot, this.ctx);
+ }
+
+ public async Task ExecuteCommand(CommandContext ctx, Bot _bot, Dictionary arguments = null)
+ {
+ this.ctx = new SharedCommandContext(this, ctx, _bot);
+ this.t = _bot.LoadedTranslations;
+
+ if (await this.BasePreExecutionCheck())
+ await this.ExecuteCommand(this.ctx, arguments).Add(_bot, this.ctx);
+ }
+
+ public async Task ExecuteCommand(InteractionContext ctx, Bot _bot, Dictionary arguments = null, bool Ephemeral = true, bool InitiateInteraction = true, bool InteractionInitiated = false)
+ {
+ this.ctx = new SharedCommandContext(this, ctx, _bot);
+ this.t = _bot.LoadedTranslations;
+
+ await Task.Run(async () =>
+ {
+ if (InitiateInteraction)
+ await ctx.CreateResponseAsync(InteractionResponseType.DeferredChannelMessageWithSource, new DiscordInteractionResponseBuilder()
+ {
+ IsEphemeral = Ephemeral
+ });
+
+ this.ctx.RespondedToInitial = InitiateInteraction;
+
+ if (InteractionInitiated)
+ this.ctx.RespondedToInitial = true;
+
+ if (await this.BasePreExecutionCheck())
+ await this.ExecuteCommand(this.ctx, arguments).Add(_bot, this.ctx);
+ }).Add(_bot, this.ctx);
+ }
+
+ public async Task ExecuteCommandWith2FA(InteractionContext ctx, Bot _bot, Dictionary arguments = null)
+ {
+ this.ctx = new SharedCommandContext(this, ctx, _bot);
+ this.t = _bot.LoadedTranslations;
+
+ await Task.Run(async () =>
+ {
+ this.ctx.RespondedToInitial = false;
+
+ if (!this.ctx.Bot.status.LoadedConfig.IsDev)
+ if (!ctx.Client.CheckTwoFactorEnrollmentFor(ctx.User.Id))
+ {
+ _ = ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().AddEmbed(new DiscordEmbedBuilder()
+ {
+ Description = "`Please enroll in Two Factor Authentication via 'Enroll2FA'.`"
+ }.AsError(this.ctx)).AsEphemeral());
+ return;
+ }
+ else
+ {
+ if (_bot.Users[ctx.User.Id].LastSuccessful2FA.GetTimespanSince() > TimeSpan.FromMinutes(3))
+ {
+ this.ctx.RespondedToInitial = true;
+ var tfa = await ctx.RequestTwoFactorAsync();
+
+ if (tfa.Result is TwoFactorResult.ValidCode or TwoFactorResult.InvalidCode)
+ await this.SwitchToEvent(tfa.ComponentInteraction);
+
+ if (tfa.Result != TwoFactorResult.ValidCode)
+ {
+ _ = this.RespondOrEdit(new DiscordMessageBuilder().WithContent("Invalid Code."));
+ return;
+ }
+ _bot.Users[ctx.User.Id].LastSuccessful2FA = DateTime.UtcNow;
+ }
+ }
+
+ if (!this.ctx.RespondedToInitial)
+ await ctx.CreateResponseAsync(InteractionResponseType.DeferredChannelMessageWithSource, new DiscordInteractionResponseBuilder()
+ {
+ IsEphemeral = true
+ });
+
+ if (await this.BasePreExecutionCheck())
+ await this.ExecuteCommand(this.ctx, arguments).Add(_bot, this.ctx);
+ }).Add(_bot, this.ctx);
+ }
+
+ public async Task ExecuteCommand(ContextMenuContext ctx, Bot _bot, Dictionary arguments = null, bool Ephemeral = true, bool InitiateInteraction = true, bool InteractionInitiated = false)
+ {
+ this.ctx = new SharedCommandContext(this, ctx, _bot);
+ this.t = _bot.LoadedTranslations;
+
+ await Task.Run(async () =>
+ {
+ if (InitiateInteraction)
+ await ctx.CreateResponseAsync(InteractionResponseType.DeferredChannelMessageWithSource, new DiscordInteractionResponseBuilder()
+ {
+ IsEphemeral = Ephemeral
+ });
+
+ this.ctx.RespondedToInitial = InitiateInteraction;
+
+ if (InteractionInitiated)
+ this.ctx.RespondedToInitial = true;
+
+ if (await this.BasePreExecutionCheck())
+ await this.ExecuteCommand(this.ctx, arguments).Add(_bot, this.ctx);
+ }).Add(_bot, this.ctx);
+ }
+
+ public async Task ExecuteCommand(ComponentInteractionCreateEventArgs ctx, DiscordClient client, string commandName, Bot _bot, Dictionary arguments = null, bool Ephemeral = true, bool InitiateInteraction = true, bool InteractionInitiated = false)
+ {
+ this.ctx = new SharedCommandContext(this, ctx, client, commandName, _bot);
+ this.t = _bot.LoadedTranslations;
+
+ await Task.Run(async () =>
+ {
+ if (InitiateInteraction)
+ await ctx.Interaction.CreateResponseAsync(InteractionResponseType.DeferredChannelMessageWithSource, new DiscordInteractionResponseBuilder()
+ {
+ IsEphemeral = Ephemeral
+ });
+
+ this.ctx.RespondedToInitial = InitiateInteraction;
+
+ if (InteractionInitiated)
+ this.ctx.RespondedToInitial = true;
+
+ if (await this.BasePreExecutionCheck())
+ await this.ExecuteCommand(this.ctx, arguments).Add(_bot, this.ctx);
+ }).Add(_bot, ctx);
+ }
+
+ private async Task BasePreExecutionCheck()
+ {
+ if (this.t is null)
+ {
+ Log.Warning($"The translation were not set before the BasePreExecutionCheck()!");
+ this.t = this.ctx.Bot.LoadedTranslations;
+ }
+
+ if (this.ctx.Bot.Users.ContainsKey(this.ctx.User.Id) && !this.ctx.User.Locale.IsNullOrWhiteSpace() && this.ctx.DbUser.CurrentLocale != this.ctx.User.Locale)
+ {
+ this.ctx.DbUser.CurrentLocale = this.ctx.User.Locale;
+ Log.Debug("Updated language for User '{User}' to '{Locale}'", this.ctx.User.Id, this.ctx.User.Locale);
+ }
+
+ if (this.ctx.Bot.status.LoadedConfig.Discord.DisabledCommands.Contains(this.ctx.ParentCommandName))
+ {
+ this.SendDisabledCommandError(this.ctx.ParentCommandName);
+ return false;
+ }
+
+ if (this.ctx.Bot.status.LoadedConfig.Discord.DisabledCommands.Contains(this.ctx.CommandName))
+ {
+ this.SendDisabledCommandError(this.ctx.CommandName);
+ return false;
+ }
+
+ if (!this.ctx.Channel.IsPrivate)
+ {
+ if (this.ctx.Bot.Guilds.ContainsKey(this.ctx.Guild.Id) && !this.ctx.Guild.PreferredLocale.IsNullOrWhiteSpace() && this.ctx.Bot.Guilds[this.ctx.Guild.Id].CurrentLocale != this.ctx.Guild.PreferredLocale)
+ {
+ this.ctx.Bot.Guilds[this.ctx.Guild.Id].CurrentLocale = this.ctx.Guild.PreferredLocale;
+ Log.Debug("Updated language for Guild '{Guild}' to '{Locale}'", this.ctx.Guild.Id, this.ctx.Guild.PreferredLocale);
+ }
+
+ if (!(await this.CheckOwnPermissions(Permissions.SendMessages)))
+ return false;
+
+ if (!(await this.CheckOwnPermissions(Permissions.EmbedLinks)))
+ return false;
+
+ if (!(await this.CheckOwnPermissions(Permissions.AddReactions)))
+ return false;
+
+ if (!(await this.CheckOwnPermissions(Permissions.AccessChannels)))
+ return false;
+
+ if (!(await this.CheckOwnPermissions(Permissions.AttachFiles)))
+ return false;
+
+ if (!(await this.CheckOwnPermissions(Permissions.ManageMessages)))
+ return false;
+
+ if (!(await this.BeforeExecution(this.ctx)))
+ return false;
+ }
+
+ if ((this.ctx.Bot.objectedUsers.Contains(this.ctx.User.Id) || this.ctx.DbUser.Data.DeletionRequested) && this.ctx.CommandName != "data" && this.ctx.CommandName != "delete")
+ {
+ this.SendDataError();
+ return false;
+ }
+
+ if (this.ctx.Bot.bannedUsers.TryGetValue(this.ctx.User.Id, out var blacklistedUserDetails))
+ {
+ this.SendUserBanError(blacklistedUserDetails);
+ return false;
+ }
+
+ if (this.ctx.Bot.bannedGuilds.TryGetValue(this.ctx.Guild?.Id ?? 0, out var blacklistedGuildDetails))
+ {
+ this.SendGuildBanError(blacklistedGuildDetails);
+ return false;
+ }
+
+
+ return !this.ctx.User.IsBot;
+ }
+ #endregion
+
+ public async Task SwitchToEvent(ComponentInteractionCreateEventArgs e)
+ {
+ await e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredChannelMessageWithSource, new DiscordInteractionResponseBuilder()
+ {
+ IsEphemeral = true
+ });
+ this.ctx.RespondedToInitial = true;
+ this.ctx.OriginalComponentInteractionCreateEventArgs = e;
+ this.ctx.CommandType = Enums.CommandType.Event;
+ }
+
+ #region RespondOrEdit
+ public Task RespondOrEdit(DiscordEmbed embed)
+ => this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed));
+
+ public Task RespondOrEdit(DiscordEmbedBuilder embed)
+ => this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.Build()));
+
+ public Task RespondOrEdit(string content)
+ => this.RespondOrEdit(new DiscordMessageBuilder().WithContent(content));
+
+ public async Task RespondOrEdit(DiscordMessageBuilder discordMessageBuilder)
+ {
+ switch (this.ctx.CommandType)
+ {
+ case Enums.CommandType.ApplicationCommand:
+ {
+ DiscordWebhookBuilder discordWebhookBuilder = new();
+
+ var files = new Dictionary();
+
+ foreach (var b in discordMessageBuilder.Files)
+ files.Add(b.Filename, b.Stream);
+
+ _ = discordWebhookBuilder.AddComponents(discordMessageBuilder.Components);
+ _ = discordWebhookBuilder.AddEmbeds(discordMessageBuilder.Embeds);
+ _ = discordWebhookBuilder.AddFiles(files);
+ discordWebhookBuilder.Content = discordMessageBuilder.Content;
+
+ var msg = await this.ctx.OriginalInteractionContext.EditResponseAsync(discordWebhookBuilder);
+ this.ctx.ResponseMessage = msg;
+ return msg;
+ }
+
+ case Enums.CommandType.ContextMenu:
+ {
+ DiscordWebhookBuilder discordWebhookBuilder = new();
+
+ var files = new Dictionary();
+
+ foreach (var b in discordMessageBuilder.Files)
+ files.Add(b.Filename, b.Stream);
+
+ _ = discordWebhookBuilder.AddComponents(discordMessageBuilder.Components);
+ _ = discordWebhookBuilder.AddEmbeds(discordMessageBuilder.Embeds);
+ _ = discordWebhookBuilder.AddFiles(files);
+ discordWebhookBuilder.Content = discordMessageBuilder.Content;
+
+ var msg = await this.ctx.OriginalContextMenuContext.EditResponseAsync(discordWebhookBuilder);
+ this.ctx.ResponseMessage = msg;
+ return msg;
+ }
+
+ case Enums.CommandType.Event:
+ {
+ DiscordWebhookBuilder discordWebhookBuilder = new();
+
+ var files = new Dictionary();
+
+ foreach (var b in discordMessageBuilder.Files)
+ files.Add(b.Filename, b.Stream);
+
+ _ = discordWebhookBuilder.AddComponents(discordMessageBuilder.Components);
+ _ = discordWebhookBuilder.AddEmbeds(discordMessageBuilder.Embeds);
+ _ = discordWebhookBuilder.AddFiles(files);
+ discordWebhookBuilder.Content = discordMessageBuilder.Content;
+
+ var msg = await this.ctx.OriginalComponentInteractionCreateEventArgs.Interaction.EditOriginalResponseAsync(discordWebhookBuilder);
+ this.ctx.ResponseMessage = msg;
+ return msg;
+ }
+
+ case Enums.CommandType.PrefixCommand:
+ case Enums.CommandType.Custom:
+ {
+ if (this.ctx.ResponseMessage is not null)
+ {
+ if ((discordMessageBuilder.Files?.Count ?? 0) > 0)
+ _ = discordMessageBuilder.KeepAttachments(false);
+
+ _ = await this.ctx.ResponseMessage.ModifyAsync(discordMessageBuilder);
+ this.ctx.ResponseMessage = await this.ctx.ResponseMessage.Refetch();
+
+ return this.ctx.ResponseMessage;
+ }
+
+ var msg = await this.ctx.Channel.SendMessageAsync(discordMessageBuilder);
+
+ this.ctx.ResponseMessage = msg;
+
+ return msg;
+ }
+ }
+
+ throw new NotImplementedException();
+ }
+ #endregion
+
+ #region GetString
+ TVar[] GetDefaultVars()
+ => new TVar[]
+ {
+ new("CurrentCommand", this.ctx.Prefix + this.ctx.CommandName, false),
+ new("Bot", this.ctx.CurrentUser.Mention, false),
+ new("BotName", this.ctx.Client.CurrentApplication.Name, false),
+ new("FullBot", this.ctx.CurrentUser.GetUsernameWithIdentifier(), false),
+ new("BotDisplayName", this.ctx.CurrentUser.GetUsernameWithIdentifier(), false),
+ new("User", this.ctx.User.Mention, false),
+ new("UserName", this.ctx.User.GetUsername(), false),
+ new("FullUser", this.ctx.User.GetUsernameWithIdentifier(), false),
+ new("UserDisplayName", this.ctx.Member?.DisplayName ?? this.ctx.User.GetUsername(), false),
+ };
+
+ public string GetString(SingleTranslationKey key)
+ => this.GetString(key, false, Array.Empty());
+
+ public string GetString(SingleTranslationKey key, params TVar[] vars)
+ => this.GetString(key, false, vars);
+
+ public string GetString(SingleTranslationKey key, bool Code = false, params TVar[] vars)
+ => key.Get(this.ctx.DbUser).Build(Code, vars.Concat(this.GetDefaultVars()).ToArray());
+
+
+
+ public string GetString(MultiTranslationKey key)
+ => this.GetString(key, false, false, Array.Empty());
+
+ public string GetString(MultiTranslationKey key, params TVar[] vars)
+ => this.GetString(key, false, false, vars);
+
+ public string GetString(MultiTranslationKey key, bool Code = false, params TVar[] vars)
+ => this.GetString(key, Code, false, vars);
+
+ public string GetString(MultiTranslationKey key, bool Code = false, bool UseBoldMarker = false, params TVar[] vars)
+ => key.Get(this.ctx.DbUser).Build(Code, UseBoldMarker, vars.Concat(this.GetDefaultVars()).ToArray());
+
+
+
+ public string GetGuildString(SingleTranslationKey key)
+ => this.GetGuildString(key, false, Array.Empty());
+
+ public string GetGuildString(SingleTranslationKey key, params TVar[] vars)
+ => this.GetGuildString(key, false, vars);
+
+ public string GetGuildString(SingleTranslationKey key, bool Code = false, params TVar[] vars)
+ => key.Get(this.ctx.DbGuild).Build(Code, vars.Concat(this.GetDefaultVars()).ToArray());
+
+
+
+ public string GetGuildString(MultiTranslationKey key)
+ => this.GetGuildString(key, false, false, Array.Empty());
+
+ public string GetGuildString(MultiTranslationKey key, params TVar[] vars)
+ => this.GetGuildString(key, false, false, vars);
+
+ public string GetGuildString(MultiTranslationKey key, bool Code = false, params TVar[] vars)
+ => this.GetGuildString(key, Code, false, vars);
+
+ public string GetGuildString(MultiTranslationKey key, bool Code = false, bool UseBoldMarker = false, params TVar[] vars)
+ => key.Get(this.ctx.DbGuild).Build(Code, UseBoldMarker, vars.Concat(this.GetDefaultVars()).ToArray());
+ #endregion
+
+ #region Selections
+ public async Task> PromptRoleSelection(RolePromptConfiguration configuration = null, TimeSpan? timeOutOverride = null)
+ {
+ configuration ??= new();
+ timeOutOverride ??= TimeSpan.FromSeconds(120);
+
+ var CreateNewButton = new DiscordButtonComponent(ButtonStyle.Secondary, Guid.NewGuid().ToString(), this.GetString(this.t.Commands.Common.Prompts.CreateRoleForMe), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("➕")));
+ var DisableButton = new DiscordButtonComponent(ButtonStyle.Secondary, Guid.NewGuid().ToString(), configuration.DisableOption ?? this.GetString(this.t.Commands.Common.Prompts.Disable), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("❌")));
+ var EveryoneButton = new DiscordButtonComponent(ButtonStyle.Secondary, Guid.NewGuid().ToString(), this.GetString(this.t.Commands.Common.Prompts.SelectEveryone), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👥")));
+ var ConfirmSelectionButton = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), this.GetString(this.t.Commands.Common.Prompts.ConfirmSelection), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("✅")));
+
+
+ var SelectionInteractionId = Guid.NewGuid().ToString();
+
+ DiscordRole FinalSelection = null;
+
+ var Selected = "";
+
+ var FinishedSelection = false;
+ var ExceptionOccurred = false;
+ Exception ThrownException = null;
+
+ async Task RefreshMessage()
+ {
+ var dropdown = new DiscordRoleSelectComponent(this.GetString(this.t.Commands.Common.Prompts.SelectARole), SelectionInteractionId, 1, 1, false);
+ var builder = new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder(this.ctx.ResponseMessage.Embeds[0]).AsAwaitingInput(this.ctx)).AddComponents(dropdown).WithContent(this.ctx.ResponseMessage.Content);
+
+ if (Selected.IsNullOrWhiteSpace())
+ _ = ConfirmSelectionButton.Disable();
+ else
+ _ = ConfirmSelectionButton.Enable();
+
+ List components = new();
+
+ if (!configuration.CreateRoleOption.IsNullOrWhiteSpace())
+ components.Add(CreateNewButton);
+
+ if (!configuration.DisableOption.IsNullOrWhiteSpace())
+ components.Add(DisableButton);
+
+ if (configuration.IncludeEveryone)
+ components.Add(EveryoneButton);
+
+ if (components.Count != 0)
+ _ = builder.AddComponents(components);
+
+ _ = builder.AddComponents(MessageComponents.GetCancelButton(this.ctx.DbUser, this.ctx.Bot), ConfirmSelectionButton);
+
+ _ = await this.RespondOrEdit(builder);
+ }
+
+ _ = RefreshMessage();
+
+ Stopwatch sw = new();
+ sw.Start();
+
+ async Task RunInteraction(DiscordClient s, ComponentInteractionCreateEventArgs e)
+ {
+ _ = Task.Run(async () =>
+ {
+ try
+ {
+ if (e.Message?.Id == this.ctx.ResponseMessage.Id && e.User.Id == this.ctx.User.Id)
+ {
+ sw.Restart();
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (e.GetCustomId() == SelectionInteractionId)
+ {
+ Selected = e.Values[0];
+
+ try
+ {
+ var role = this.ctx.Guild.GetRole(Convert.ToUInt64(Selected));
+
+ if (role.IsManaged || this.ctx.Member.GetRoleHighestPosition() <= role.Position)
+ {
+ Selected = "";
+ _ = e.Interaction.CreateFollowupMessageAsync(new DiscordFollowupMessageBuilder().AsEphemeral().WithContent($"❌ {this.GetString(this.t.Commands.Common.Prompts.SelectedRoleUnavailable, true)}"));
+ }
+ }
+ catch { }
+
+ await RefreshMessage();
+ }
+ if (e.GetCustomId() == DisableButton.CustomId)
+ {
+ FinalSelection = null;
+ FinishedSelection = true;
+ }
+ if (e.GetCustomId() == CreateNewButton.CustomId)
+ {
+ FinalSelection = await this.ctx.Guild.CreateRoleAsync(configuration.CreateRoleOption);
+ FinishedSelection = true;
+ }
+ if (e.GetCustomId() == EveryoneButton.CustomId)
+ {
+ FinalSelection = this.ctx.Guild.EveryoneRole;
+ FinishedSelection = true;
+ }
+ else if (e.GetCustomId() == ConfirmSelectionButton.CustomId)
+ {
+ this.ctx.Client.ComponentInteractionCreated -= RunInteraction;
+
+ FinalSelection = this.ctx.Guild.GetRole(Convert.ToUInt64(Selected));
+ FinishedSelection = true;
+ }
+ else if (e.GetCustomId() == MessageComponents.GetCancelButton(this.ctx.DbUser, this.ctx.Bot).CustomId)
+ throw new CancelException();
+ }
+ }
+ catch (Exception ex)
+ {
+ ThrownException = ex;
+ ExceptionOccurred = true;
+ FinishedSelection = true;
+ }
+ });
+ }
+
+ this.ctx.Client.ComponentInteractionCreated += RunInteraction;
+
+ while (!FinishedSelection && sw.Elapsed <= timeOutOverride)
+ {
+ await Task.Delay(100);
+ }
+
+ this.ctx.Client.ComponentInteractionCreated -= RunInteraction;
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(this.ctx.ResponseMessage.Embeds[0]).WithContent(this.ctx.ResponseMessage.Content));
+
+ if (ExceptionOccurred)
+ return new InteractionResult(ThrownException);
+
+ return sw.Elapsed >= timeOutOverride
+ ? new InteractionResult(new TimedOutException())
+ : new InteractionResult(FinalSelection);
+ }
+
+ public Task> PromptChannelSelection(ChannelType? channelType = null, ChannelPromptConfiguration configuration = null, TimeSpan? timeOutOverride = null)
+ => this.PromptChannelSelection(((channelType is null || !channelType.HasValue) ? null : new ChannelType[] { channelType.Value }), configuration, timeOutOverride);
+
+ public async Task> PromptChannelSelection(ChannelType[]? channelTypes = null, ChannelPromptConfiguration configuration = null, TimeSpan? timeOutOverride = null)
+ {
+ configuration ??= new();
+ timeOutOverride ??= TimeSpan.FromSeconds(120);
+
+ List FetchedChannels = new();
+
+ var CreateNewButton = new DiscordButtonComponent(ButtonStyle.Secondary, Guid.NewGuid().ToString(), this.GetString(this.t.Commands.Common.Prompts.CreateChannelForMe), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("➕")));
+ var DisableButton = new DiscordButtonComponent(ButtonStyle.Secondary, Guid.NewGuid().ToString(), configuration.DisableOption ?? this.GetString(this.t.Commands.Common.Prompts.Disable), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("❌")));
+ var ConfirmSelectionButton = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), this.GetString(this.t.Commands.Common.Prompts.ConfirmSelection), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("✅")));
+
+ var SelectionInteractionId = Guid.NewGuid().ToString();
+
+ DiscordChannel FinalSelection = null;
+
+ var Selected = "";
+
+ var FinishedSelection = false;
+ var ExceptionOccurred = false;
+ Exception ThrownException = null;
+
+ async Task RefreshMessage()
+ {
+ var dropdown = new DiscordChannelSelectComponent(this.GetString(this.t.Commands.Common.Prompts.SelectAChannel), channelTypes, SelectionInteractionId);
+ var builder = new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder(this.ctx.ResponseMessage.Embeds[0]).AsAwaitingInput(this.ctx)).AddComponents(dropdown).WithContent(this.ctx.ResponseMessage.Content);
+
+ if (Selected.IsNullOrWhiteSpace())
+ _ = ConfirmSelectionButton.Disable();
+ else
+ _ = ConfirmSelectionButton.Enable();
+
+ List components = new();
+
+ if (configuration.CreateChannelOption is not null)
+ components.Add(CreateNewButton);
+
+ if (!configuration.DisableOption.IsNullOrWhiteSpace())
+ components.Add(DisableButton);
+
+ if (components.Count > 0)
+ _ = builder.AddComponents(components);
+
+ _ = builder.AddComponents(MessageComponents.GetCancelButton(this.ctx.DbUser, this.ctx.Bot), ConfirmSelectionButton);
+
+ _ = await this.RespondOrEdit(builder);
+ }
+
+ _ = RefreshMessage();
+
+ Stopwatch sw = new();
+ sw.Start();
+
+ async Task RunInteraction(DiscordClient s, ComponentInteractionCreateEventArgs e)
+ {
+ _ = Task.Run(async () =>
+ {
+ try
+ {
+ if (e.Message?.Id == this.ctx.ResponseMessage.Id && e.User.Id == this.ctx.User.Id)
+ {
+ sw.Restart();
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (e.GetCustomId() == SelectionInteractionId)
+ {
+ Selected = e.Values.First();
+ FetchedChannels = FetchedChannels.Select(x => new DiscordStringSelectComponentOption(x.Label, x.Value, x.Description, (x.Value == Selected), x.Emoji)).ToList();
+
+ await RefreshMessage();
+ }
+ else if (e.GetCustomId() == CreateNewButton.CustomId)
+ {
+ FinalSelection = await this.ctx.Guild.CreateChannelAsync(configuration.CreateChannelOption.Name, configuration.CreateChannelOption.ChannelType);
+ FinishedSelection = true;
+ }
+ else if (e.GetCustomId() == DisableButton.CustomId)
+ {
+ FinalSelection = null;
+ FinishedSelection = true;
+ }
+ else if (e.GetCustomId() == ConfirmSelectionButton.CustomId)
+ {
+ this.ctx.Client.ComponentInteractionCreated -= RunInteraction;
+
+ FinalSelection = this.ctx.Guild.GetChannel(Convert.ToUInt64(Selected));
+ FinishedSelection = true;
+ }
+ else if (e.GetCustomId() == MessageComponents.GetCancelButton(this.ctx.DbUser, this.ctx.Bot).CustomId)
+ throw new CancelException();
+ }
+ }
+ catch (Exception ex)
+ {
+ ThrownException = ex;
+ ExceptionOccurred = true;
+ FinishedSelection = true;
+ }
+ });
+ }
+
+ this.ctx.Client.ComponentInteractionCreated += RunInteraction;
+
+ while (!FinishedSelection && sw.Elapsed <= timeOutOverride)
+ {
+ await Task.Delay(100);
+ }
+
+ this.ctx.Client.ComponentInteractionCreated -= RunInteraction;
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(this.ctx.ResponseMessage.Embeds[0]).WithContent(this.ctx.ResponseMessage.Content));
+
+ if (ExceptionOccurred)
+ return new InteractionResult(ThrownException);
+
+ return sw.Elapsed >= timeOutOverride
+ ? new InteractionResult(new TimedOutException())
+ : new InteractionResult(FinalSelection);
+ }
+
+ public async Task> PromptCustomSelection(IEnumerable options, string? CustomPlaceHolder = null, TimeSpan? timeOutOverride = null)
+ {
+ timeOutOverride ??= TimeSpan.FromSeconds(120);
+ CustomPlaceHolder ??= this.GetString(this.t.Commands.Common.Prompts.SelectAnOption);
+
+ var ConfirmSelectionButton = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), this.GetString(this.t.Commands.Common.Prompts.ConfirmSelection), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("✅")));
+
+ var PrevPageButton = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(this.t.Common.PreviousPage), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("◀")));
+ var NextPageButton = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(this.t.Common.NextPage), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("▶")));
+
+ var CurrentPage = 0;
+ var SelectionInteractionId = Guid.NewGuid().ToString();
+
+ string FinalSelection = null;
+
+ var Selected = options.FirstOrDefault(x => x.Default, null)?.Value ?? "";
+
+ var FinishedSelection = false;
+ var ExceptionOccurred = false;
+ Exception ThrownException = null;
+
+ while (!Selected.IsNullOrWhiteSpace() && !options.Skip(CurrentPage * 25).Take(25).Any(x => x.Value == Selected))
+ {
+ if (!options.Skip(CurrentPage * 25).Take(25).Any())
+ {
+ CurrentPage = 0;
+ break;
+ }
+
+ CurrentPage++;
+ }
+
+ async Task RefreshMessage()
+ {
+ var dropdown = new DiscordStringSelectComponent(CustomPlaceHolder, options.Skip(CurrentPage * 25).Take(25).Select(x => new DiscordStringSelectComponentOption(x.Label, x.Value, x.Description, (x.Value == Selected), x.Emoji)), SelectionInteractionId);
+ var builder = new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder(this.ctx.ResponseMessage.Embeds[0]).AsAwaitingInput(this.ctx)).AddComponents(dropdown).WithContent(this.ctx.ResponseMessage.Content);
+
+ _ = NextPageButton.SetState(options.Skip(CurrentPage * 25).Count() <= 25);
+ _ = PrevPageButton.SetState(CurrentPage == 0);
+ _ = builder.AddComponents(PrevPageButton, NextPageButton);
+
+ if (Selected.IsNullOrWhiteSpace())
+ _ = ConfirmSelectionButton.Disable();
+ else
+ _ = ConfirmSelectionButton.Enable();
+
+ _ = builder.AddComponents(MessageComponents.GetCancelButton(this.ctx.DbUser, this.ctx.Bot), ConfirmSelectionButton);
+
+ _ = await this.RespondOrEdit(builder);
+ }
+
+ _ = RefreshMessage();
+
+ Stopwatch sw = new();
+ sw.Start();
+
+ async Task RunInteraction(DiscordClient s, ComponentInteractionCreateEventArgs e)
+ {
+ _ = Task.Run(async () =>
+ {
+ try
+ {
+ if (e.Message?.Id == this.ctx.ResponseMessage.Id && e.User.Id == this.ctx.User.Id)
+ {
+ sw.Restart();
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (e.GetCustomId() == SelectionInteractionId)
+ {
+ Selected = e.Values.First();
+ await RefreshMessage();
+ }
+ else if (e.GetCustomId() == ConfirmSelectionButton.CustomId)
+ {
+ this.ctx.Client.ComponentInteractionCreated -= RunInteraction;
+
+ FinalSelection = Selected;
+
+ FinishedSelection = true;
+ }
+ else if (e.GetCustomId() == PrevPageButton.CustomId)
+ {
+ CurrentPage--;
+ await RefreshMessage();
+ }
+ else if (e.GetCustomId() == NextPageButton.CustomId)
+ {
+ CurrentPage++;
+ await RefreshMessage();
+ }
+ else if (e.GetCustomId() == MessageComponents.GetCancelButton(this.ctx.DbUser, this.ctx.Bot).CustomId)
+ throw new CancelException();
+ }
+ }
+ catch (Exception ex)
+ {
+ ThrownException = ex;
+ ExceptionOccurred = true;
+ FinishedSelection = true;
+ }
+ });
+ }
+
+ this.ctx.Client.ComponentInteractionCreated += RunInteraction;
+
+ while (!FinishedSelection && sw.Elapsed <= timeOutOverride)
+ {
+ await Task.Delay(100);
+ }
+
+ this.ctx.Client.ComponentInteractionCreated -= RunInteraction;
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(this.ctx.ResponseMessage.Embeds[0]).WithContent(this.ctx.ResponseMessage.Content));
+
+ if (ExceptionOccurred)
+ return new InteractionResult(ThrownException);
+
+ return sw.Elapsed >= timeOutOverride
+ ? new InteractionResult(new TimedOutException())
+ : new InteractionResult(FinalSelection);
+ }
+ #endregion
+
+ #region Modals
+ public Task> PromptModalWithRetry(DiscordInteraction interaction, DiscordInteractionModalBuilder builder, bool ResetToOriginalEmbed = false, TimeSpan? timeOutOverride = null)
+ => this.PromptModalWithRetry(interaction, builder, null, ResetToOriginalEmbed, timeOutOverride);
+
+ public async Task> PromptModalWithRetry(DiscordInteraction interaction, DiscordInteractionModalBuilder builder, DiscordEmbedBuilder customEmbed = null, bool ResetToOriginalEmbed = false, TimeSpan? timeOutOverride = null, bool open = true)
+ {
+ timeOutOverride ??= TimeSpan.FromMinutes(15);
+
+ var oriEmbed = this.ctx.ResponseMessage.Embeds[0];
+
+ var ReOpen = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(this.t.Commands.Common.Prompts.ReOpenModal), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🔄")));
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(customEmbed ?? new DiscordEmbedBuilder
+ {
+ Description = this.GetString(this.t.Commands.Common.Prompts.WaitingForModalResponse, true)
+ }.AsAwaitingInput(this.ctx)).AddComponents(new List { ReOpen, MessageComponents.GetCancelButton(this.ctx.DbUser, this.ctx.Bot) }));
+
+ ComponentInteractionCreateEventArgs FinishedInteraction = null;
+
+ var FinishedSelection = false;
+ var ExceptionOccurred = false;
+ var Cancelled = false;
+ Exception ThrownException = null;
+
+ if (open)
+ await interaction.CreateInteractionModalResponseAsync(builder);
+
+ this.ctx.Client.ComponentInteractionCreated += RunInteraction;
+
+ async Task RunInteraction(DiscordClient s, ComponentInteractionCreateEventArgs e)
+ {
+ _ = Task.Run(async () =>
+ {
+ try
+ {
+ if (e.Message?.Id == this.ctx.ResponseMessage.Id && e.User.Id == this.ctx.User.Id)
+ {
+ if (e.GetCustomId() == builder.CustomId)
+ {
+ this.ctx.Client.ComponentInteractionCreated -= RunInteraction;
+
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ FinishedInteraction = e;
+ FinishedSelection = true;
+ }
+ else if (e.GetCustomId() == ReOpen.CustomId)
+ {
+ await e.Interaction.CreateInteractionModalResponseAsync(builder);
+ }
+ else if (e.GetCustomId() == MessageComponents.GetCancelButton(this.ctx.DbUser, this.ctx.Bot).CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ throw new CancelException();
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ ThrownException = ex;
+ ExceptionOccurred = true;
+ FinishedSelection = true;
+ }
+ }).Add(this.ctx.Bot, this.ctx);
+ }
+
+ var TimeoutSeconds = (int)(timeOutOverride.Value.TotalSeconds * 2);
+
+ while (!FinishedSelection && !ExceptionOccurred && !Cancelled && TimeoutSeconds >= 0)
+ {
+ await Task.Delay(500);
+ TimeoutSeconds--;
+ }
+
+ this.ctx.Client.ComponentInteractionCreated -= RunInteraction;
+
+ if (ResetToOriginalEmbed)
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(oriEmbed));
+
+ if (ExceptionOccurred)
+ return new InteractionResult(ThrownException);
+
+ return TimeoutSeconds <= 0
+ ? new InteractionResult(new TimeoutException())
+ : new InteractionResult(FinishedInteraction);
+ }
+
+
+ public async Task> PromptForTimeSpan(TimeSpan? MaxTime = null, TimeSpan? MinTime = null, TimeSpan? DefaultTime = null, bool ResetToOriginalEmbed = true, TimeSpan? timeOutOverride = null)
+ {
+ MinTime ??= TimeSpan.Zero;
+ MaxTime ??= TimeSpan.FromDays(356);
+ DefaultTime ??= TimeSpan.FromSeconds(30);
+ timeOutOverride ??= TimeSpan.FromSeconds(300);
+
+ if (DefaultTime > MaxTime)
+ DefaultTime = MaxTime;
+
+ if (DefaultTime < MinTime)
+ DefaultTime = MinTime;
+
+ var originalEmbed = ResetToOriginalEmbed ? this.ctx.ResponseMessage.Embeds : null;
+
+ var removeSeconds = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), "10s", false, "➖".UnicodeToEmoji().ToComponent());
+ var removeSecond = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), "1s", false, "➖".UnicodeToEmoji().ToComponent());
+ var addSecond = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), "1s", false, "➕".UnicodeToEmoji().ToComponent());
+ var addSeconds = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), "10s", false, "➕".UnicodeToEmoji().ToComponent());
+
+ var removeMinutes = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), "10m", false, "➖".UnicodeToEmoji().ToComponent());
+ var removeMinute = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), "1m", false, "➖".UnicodeToEmoji().ToComponent());
+ var addMinute = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), "1m", false, "➕".UnicodeToEmoji().ToComponent());
+ var addMinutes = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), "10m", false, "➕".UnicodeToEmoji().ToComponent());
+
+ var removeHours = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), "10h", false, "➖".UnicodeToEmoji().ToComponent());
+ var removeHour = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), "1h", false, "➖".UnicodeToEmoji().ToComponent());
+ var addHour = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), "1h", false, "➕".UnicodeToEmoji().ToComponent());
+ var addHours = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), "10h", false, "➕".UnicodeToEmoji().ToComponent());
+
+ var removeDays = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), "10d", false, "➖".UnicodeToEmoji().ToComponent());
+ var removeDay = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), "1d", false, "➖".UnicodeToEmoji().ToComponent());
+ var addDay = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), "1d", false, "➕".UnicodeToEmoji().ToComponent());
+ var addDays = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), "10d", false, "➕".UnicodeToEmoji().ToComponent());
+
+ var setExact = new DiscordButtonComponent(ButtonStyle.Secondary, Guid.NewGuid().ToString(), this.GetString(this.t.Commands.Common.Prompts.ManuallyDefineTimespan), false, "🕒".UnicodeToEmoji().ToComponent());
+ var confirmSelection = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), this.GetString(this.t.Commands.Common.Prompts.ConfirmSelection), false, "✅".UnicodeToEmoji().ToComponent());
+
+ var previousSuccessSelected = DefaultTime!.Value;
+ var currentSelectedTime = DefaultTime!.Value;
+
+ Task UpdateMessage()
+ {
+ if (currentSelectedTime > MaxTime || MinTime > currentSelectedTime)
+ currentSelectedTime = previousSuccessSelected;
+
+ previousSuccessSelected = currentSelectedTime;
+
+ foreach (var button in new List()
+ {
+ removeSeconds, removeSecond, addSecond, addSeconds,
+ removeMinutes, removeMinute, addMinute, addMinutes,
+ removeHours, removeHour, addHour, addHours,
+ removeDays, removeDay, addDay, addDays
+ })
+ _ = button.Enable();
+
+ if (currentSelectedTime - TimeSpan.FromSeconds(10) < MinTime)
+ _ = removeSeconds.Disable();
+
+ if (currentSelectedTime - TimeSpan.FromSeconds(1) < MinTime)
+ _ = removeSecond.Disable();
+
+ if (currentSelectedTime - TimeSpan.FromMinutes(10) < MinTime)
+ _ = removeMinutes.Disable();
+
+ if (currentSelectedTime - TimeSpan.FromMinutes(1) < MinTime)
+ _ = removeMinute.Disable();
+
+ if (currentSelectedTime - TimeSpan.FromHours(10) < MinTime)
+ _ = removeHours.Disable();
+
+ if (currentSelectedTime - TimeSpan.FromHours(1) < MinTime)
+ _ = removeHour.Disable();
+
+ if (currentSelectedTime - TimeSpan.FromDays(10) < MinTime)
+ _ = removeDays.Disable();
+
+ if (currentSelectedTime - TimeSpan.FromDays(1) < MinTime)
+ _ = removeDay.Disable();
+
+ if (currentSelectedTime + TimeSpan.FromSeconds(10) > MaxTime)
+ _ = addSeconds.Disable();
+
+ if (currentSelectedTime + TimeSpan.FromSeconds(1) > MaxTime)
+ _ = addSecond.Disable();
+
+ if (currentSelectedTime + TimeSpan.FromMinutes(10) > MaxTime)
+ _ = addMinutes.Disable();
+
+ if (currentSelectedTime + TimeSpan.FromMinutes(1) > MaxTime)
+ _ = addMinute.Disable();
+
+ if (currentSelectedTime + TimeSpan.FromHours(10) > MaxTime)
+ _ = addHours.Disable();
+
+ if (currentSelectedTime + TimeSpan.FromHours(1) > MaxTime)
+ _ = addHour.Disable();
+
+ if (currentSelectedTime + TimeSpan.FromDays(10) > MaxTime)
+ _ = addDays.Disable();
+
+ if (currentSelectedTime + TimeSpan.FromDays(1) > MaxTime)
+ _ = addDay.Disable();
+
+ var embed = new DiscordEmbedBuilder()
+ .WithDescription($"`{this.GetString(this.t.Commands.Common.Prompts.CurrentTimespan)}`: `{currentSelectedTime.GetHumanReadable(TimeFormat.Days, TranslationUtil.GetTranslatedHumanReadableConfig(this.ctx.DbUser, this.ctx.Bot, true))}`")
+ .AsAwaitingInput(this.ctx);
+
+
+
+ return this.RespondOrEdit(new DiscordMessageBuilder()
+ .AddEmbed(embed)
+ .AddComponents(removeSeconds, removeSecond, addSecond, addSeconds)
+ .AddComponents(removeMinutes, removeMinute, addMinute, addMinutes)
+ .AddComponents(removeHours, removeHour, addHour, addHours)
+ .AddComponents(removeDays, removeDay, addDay, addDays)
+ .AddComponents(setExact, MessageComponents.GetCancelButton(this.ctx.DbUser, this.ctx.Bot), confirmSelection));
+ }
+ await UpdateMessage();
+
+ var Finished = false;
+ var Cancelled = false;
+ var timeOut = Stopwatch.StartNew();
+
+ async Task Interaction(DiscordClient sender, ComponentInteractionCreateEventArgs e)
+ {
+ _ = Task.Run(async () =>
+ {
+ if (e.Message?.Id == this.ctx.ResponseMessage?.Id)
+ {
+ timeOut.Restart();
+
+ if (e.Id == removeSecond.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Subtract(TimeSpan.FromSeconds(1));
+ await UpdateMessage();
+ }
+ else if (e.Id == removeSeconds.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Subtract(TimeSpan.FromSeconds(10));
+ await UpdateMessage();
+ }
+ else if (e.Id == addSecond.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Add(TimeSpan.FromSeconds(1));
+ await UpdateMessage();
+ }
+ else if (e.Id == addSeconds.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Add(TimeSpan.FromSeconds(10));
+ await UpdateMessage();
+ }
+ else if (e.Id == removeMinute.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Subtract(TimeSpan.FromMinutes(1));
+ await UpdateMessage();
+ }
+ else if (e.Id == removeMinutes.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Subtract(TimeSpan.FromMinutes(10));
+ await UpdateMessage();
+ }
+ else if (e.Id == addMinute.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Add(TimeSpan.FromMinutes(1));
+ await UpdateMessage();
+ }
+ else if (e.Id == addMinutes.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Add(TimeSpan.FromMinutes(10));
+ await UpdateMessage();
+ }
+ else if (e.Id == removeHour.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Subtract(TimeSpan.FromHours(1));
+ await UpdateMessage();
+ }
+ else if (e.Id == removeHours.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Subtract(TimeSpan.FromHours(10));
+ await UpdateMessage();
+ }
+ else if (e.Id == addHour.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Add(TimeSpan.FromHours(1));
+ await UpdateMessage();
+ }
+ else if (e.Id == addHours.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Add(TimeSpan.FromHours(10));
+ await UpdateMessage();
+ }
+ else if (e.Id == removeDay.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Subtract(TimeSpan.FromDays(1));
+ await UpdateMessage();
+ }
+ else if (e.Id == removeDays.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Subtract(TimeSpan.FromDays(10));
+ await UpdateMessage();
+ }
+ else if (e.Id == addDay.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Add(TimeSpan.FromDays(1));
+ await UpdateMessage();
+ }
+ else if (e.Id == addDays.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Add(TimeSpan.FromDays(10));
+ await UpdateMessage();
+ }
+ else if (e.Id == confirmSelection.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ Finished = true;
+ }
+ else if (e.Id == MessageComponents.CancelButtonId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ Cancelled = true;
+ }
+ else if (e.Id == setExact.CustomId)
+ {
+
+ var modal = new DiscordInteractionModalBuilder().WithTitle(this.GetString(this.t.Commands.Common.Prompts.SelectATimeSpan)).WithCustomId(Guid.NewGuid().ToString());
+
+ if (MaxTime.Value.TotalDays >= 1)
+ _ = modal.AddTextComponent(new DiscordTextComponent(TextComponentStyle.Small, "days", this.GetString(this.t.Commands.Common.Prompts.TimespanDays)
+ .Build(new TVar("Max", ((int)MaxTime.Value.TotalDays))), "0", 1, 3, true, $"{currentSelectedTime.Days}"));
+
+ if (MaxTime.Value.TotalHours >= 1)
+ _ = modal.AddTextComponent(new DiscordTextComponent(TextComponentStyle.Small, "hours", this.GetString(this.t.Commands.Common.Prompts.TimespanHours)
+ .Build(new TVar("Max", (MaxTime.Value.TotalHours >= 24 ? "23" : $"{((int)MaxTime.Value.TotalHours)}"))), "0", 1, 2, true, $"{currentSelectedTime.Hours}"));
+
+ if (MaxTime.Value.TotalMinutes >= 1)
+ _ = modal.AddTextComponent(new DiscordTextComponent(TextComponentStyle.Small, "minutes", this.GetString(this.t.Commands.Common.Prompts.TimespanMinutes)
+ .Build(new TVar("Max", (MaxTime.Value.TotalMinutes >= 60 ? "59" : $"{((int)MaxTime.Value.TotalMinutes)}"))), $"0", 1, 2, true, $"{currentSelectedTime.Minutes}"));
+
+ _ = modal.AddTextComponent(new DiscordTextComponent(TextComponentStyle.Small, "seconds", this.GetString(this.t.Commands.Common.Prompts.TimespanSeconds)
+ .Build(new TVar("Max", 59)), "0", 1, 2, true, $"{currentSelectedTime.Seconds}"));
+
+ var ModalResult = await this.PromptModalWithRetry(e.Interaction, modal, true, timeOutOverride.Value.Subtract(timeOut.Elapsed));
+
+ if (!ModalResult.Failed)
+ {
+ try
+ {
+ var Response = ModalResult.Result;
+ var modalLength = TimeSpan.FromSeconds(0);
+
+ if ((Response.Interaction.Data.Components.Any(x => x.CustomId == "seconds") && !Response.Interaction.Data.Components.First(x => x.CustomId == "seconds").Value.IsDigitsOnly()) ||
+ (Response.Interaction.Data.Components.Any(x => x.CustomId == "minutes") && !Response.Interaction.Data.Components.First(x => x.CustomId == "minutes").Value.IsDigitsOnly()) ||
+ (Response.Interaction.Data.Components.Any(x => x.CustomId == "hours") && !Response.Interaction.Data.Components.First(x => x.CustomId == "hours").Value.IsDigitsOnly()) ||
+ (Response.Interaction.Data.Components.Any(x => x.CustomId == "days") && !Response.Interaction.Data.Components.First(x => x.CustomId == "days").Value.IsDigitsOnly()))
+ throw new InvalidOperationException("Invalid TimeSpan");
+ var seconds = Response.Interaction.Data.Components.Any(x => x.CustomId == "seconds") ? Convert.ToDouble(Convert.ToUInt32(Response.Interaction.Data.Components.First(x => x.CustomId == "seconds").Value)) : 0;
+ var minutes = Response.Interaction.Data.Components.Any(x => x.CustomId == "minutes") ? Convert.ToDouble(Convert.ToUInt32(Response.Interaction.Data.Components.First(x => x.CustomId == "minutes").Value)) : 0;
+ var hours = Response.Interaction.Data.Components.Any(x => x.CustomId == "hours") ? Convert.ToDouble(Convert.ToUInt32(Response.Interaction.Data.Components.First(x => x.CustomId == "hours").Value)) : 0;
+ var days = Response.Interaction.Data.Components.Any(x => x.CustomId == "days") ? Convert.ToDouble(Convert.ToUInt32(Response.Interaction.Data.Components.First(x => x.CustomId == "days").Value)) : 0;
+ modalLength = modalLength.Add(TimeSpan.FromSeconds(seconds));
+ modalLength = modalLength.Add(TimeSpan.FromMinutes(minutes));
+ modalLength = modalLength.Add(TimeSpan.FromHours(hours));
+ modalLength = modalLength.Add(TimeSpan.FromDays(days));
+
+ currentSelectedTime = modalLength;
+ }
+ catch { }
+ }
+
+ await UpdateMessage();
+ }
+ }
+ }).Add(this.ctx.Bot, this.ctx);
+ }
+
+ this.ctx.Client.ComponentInteractionCreated += Interaction;
+
+ while (!Finished && !Cancelled && timeOut.ElapsedMilliseconds < timeOutOverride.Value.TotalMilliseconds)
+ await Task.Delay(1000);
+
+ this.ctx.Client.ComponentInteractionCreated -= Interaction;
+
+ if (!Finished && !Cancelled && timeOut.ElapsedMilliseconds < timeOutOverride.Value.TotalMilliseconds)
+ return new InteractionResult(new TimedOutException());
+
+ if (Cancelled)
+ return new InteractionResult(new CancelException());
+
+ if (ResetToOriginalEmbed)
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().AddEmbeds(originalEmbed));
+
+ return currentSelectedTime > MaxTime || currentSelectedTime < MinTime
+ ? new InteractionResult(new InvalidOperationException("Invalid TimeSpan"))
+ : new InteractionResult(currentSelectedTime);
+ }
+
+ public async Task> PromptModalForDateTime(DateTime? defaultTime = null, bool ResetToOriginalEmbed = true, TimeSpan? timeOutOverride = null)
+ {
+ timeOutOverride ??= TimeSpan.FromMinutes(2);
+ defaultTime ??= DateTime.UtcNow;
+
+ var originalEmbed = ResetToOriginalEmbed ? this.ctx.ResponseMessage.Embeds : null;
+
+ var removeMinutes = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), "10m", false, "➖".UnicodeToEmoji().ToComponent());
+ var removeMinute = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), "1m", false, "➖".UnicodeToEmoji().ToComponent());
+ var addMinute = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), "1m", false, "➕".UnicodeToEmoji().ToComponent());
+ var addMinutes = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), "10m", false, "➕".UnicodeToEmoji().ToComponent());
+
+ var removeHours = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), "10h", false, "➖".UnicodeToEmoji().ToComponent());
+ var removeHour = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), "1h", false, "➖".UnicodeToEmoji().ToComponent());
+ var addHour = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), "1h", false, "➕".UnicodeToEmoji().ToComponent());
+ var addHours = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), "10h", false, "➕".UnicodeToEmoji().ToComponent());
+
+ var removeDays = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), "10d", false, "➖".UnicodeToEmoji().ToComponent());
+ var removeDay = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), "1d", false, "➖".UnicodeToEmoji().ToComponent());
+ var addDay = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), "1d", false, "➕".UnicodeToEmoji().ToComponent());
+ var addDays = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), "10d", false, "➕".UnicodeToEmoji().ToComponent());
+
+ var setExact = new DiscordButtonComponent(ButtonStyle.Secondary, Guid.NewGuid().ToString(), this.GetString(this.t.Commands.Common.Prompts.ManuallyDefineDateTime), false, "🕒".UnicodeToEmoji().ToComponent());
+ var changeTimezone = new DiscordButtonComponent(ButtonStyle.Secondary, Guid.NewGuid().ToString(), this.GetString(this.t.Commands.Common.Prompts.SelectTimezone), false, "🌐".UnicodeToEmoji().ToComponent());
+ var confirmSelection = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), this.GetString(this.t.Commands.Common.Prompts.ConfirmSelection), false, "✅".UnicodeToEmoji().ToComponent());
+
+ var currentSelectedTime = defaultTime!.Value;
+
+ Task UpdateMessage()
+ {
+ var embed = new DiscordEmbedBuilder()
+ .WithDescription($"`{this.GetString(this.t.Commands.Common.Prompts.CurrentDateTime)}`: {currentSelectedTime.ToTimestamp()} ({currentSelectedTime.ToTimestamp(TimestampFormat.LongDateTime)})")
+ .AsAwaitingInput(this.ctx);
+
+ return this.RespondOrEdit(new DiscordMessageBuilder()
+ .AddEmbed(embed)
+ .AddComponents(removeMinutes, removeMinute, addMinute, addMinutes)
+ .AddComponents(removeHours, removeHour, addHour, addHours)
+ .AddComponents(removeDays, removeDay, addDay, addDays)
+ .AddComponents(changeTimezone, setExact)
+ .AddComponents(MessageComponents.GetCancelButton(this.ctx.DbUser, this.ctx.Bot), confirmSelection));
+ }
+ await UpdateMessage();
+
+ var Finished = false;
+ var Cancelled = false;
+ var timeOut = Stopwatch.StartNew();
+
+ async Task Interaction(DiscordClient sender, ComponentInteractionCreateEventArgs e)
+ {
+ _ = Task.Run(async () =>
+ {
+ if (e.Message?.Id == this.ctx.ResponseMessage?.Id)
+ {
+ timeOut.Restart();
+
+ if (e.Id == removeMinute.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Subtract(TimeSpan.FromMinutes(1));
+ }
+ else if (e.Id == removeMinutes.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Subtract(TimeSpan.FromMinutes(10));
+ }
+ else if (e.Id == addMinute.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Add(TimeSpan.FromMinutes(1));
+ }
+ else if (e.Id == addMinutes.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Add(TimeSpan.FromMinutes(10));
+ }
+ else if (e.Id == removeHour.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Subtract(TimeSpan.FromHours(1));
+ }
+ else if (e.Id == removeHours.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Subtract(TimeSpan.FromHours(10));
+ }
+ else if (e.Id == addHour.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Add(TimeSpan.FromHours(1));
+ }
+ else if (e.Id == addHours.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Add(TimeSpan.FromHours(10));
+ }
+ else if (e.Id == removeDay.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Subtract(TimeSpan.FromDays(1));
+ }
+ else if (e.Id == removeDays.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Subtract(TimeSpan.FromDays(10));
+ }
+ else if (e.Id == addDay.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Add(TimeSpan.FromDays(1));
+ }
+ else if (e.Id == addDays.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ currentSelectedTime = currentSelectedTime.Add(TimeSpan.FromDays(10));
+ }
+ else if (e.Id == confirmSelection.CustomId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ Finished = true;
+ return;
+ }
+ else if (e.Id == MessageComponents.CancelButtonId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ Cancelled = true;
+ return;
+ }
+ else if (e.Id == changeTimezone.CustomId)
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(this.t.Commands.Common.Prompts.SelectTimezonePrompt, true)).AsAwaitingInput(this.ctx));
+
+ var promptResult = await this.PromptCustomSelection(TimeZoneInfo.GetSystemTimeZones()
+ .Select(x => new DiscordStringSelectComponentOption(x.DisplayName, x.Id, null, x.Id == (this.ctx.DbUser.Timezone ?? "UTC"))), null, timeOutOverride.Value.Subtract(timeOut.Elapsed));
+
+ if (promptResult.Failed)
+ {
+ await UpdateMessage();
+ return;
+ }
+
+ this.ctx.DbUser.Timezone = promptResult.Result;
+ }
+ else if (e.Id == setExact.CustomId)
+ {
+ var modalInteraction = e.Interaction;
+
+ if (this.ctx.DbUser.Timezone.IsNullOrWhiteSpace() || !TimeZoneInfo.GetSystemTimeZones().Any(x => x.Id == this.ctx.DbUser.Timezone))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(this.GetString(this.t.Commands.Common.Prompts.SelectTimezonePrompt, true)).AsAwaitingInput(this.ctx));
+
+ var promptResult = await this.PromptCustomSelection(TimeZoneInfo.GetSystemTimeZones()
+ .Select(x => new DiscordStringSelectComponentOption(x.DisplayName, x.Id, null, x.Id == (this.ctx.DbUser.Timezone ?? "UTC"))), null, timeOutOverride.Value.Subtract(timeOut.Elapsed));
+
+ if (promptResult.Failed)
+ {
+ await UpdateMessage();
+ return;
+ }
+
+ this.ctx.DbUser.Timezone = promptResult.Result;
+ modalInteraction = null;
+ }
+
+ var userTimezone = TimeZoneInfo.FindSystemTimeZoneById(this.ctx.DbUser.Timezone);
+ var userTime = TimeZoneInfo.ConvertTimeFromUtc(currentSelectedTime, userTimezone);
+
+ var modal = new DiscordInteractionModalBuilder().WithTitle(this.GetString(this.t.Commands.Common.Prompts.SelectADateTime)).WithCustomId(Guid.NewGuid().ToString());
+
+ _ = modal.AddTextComponent(new DiscordTextComponent(TextComponentStyle.Small, "minute", this.GetString(this.t.Commands.Common.Prompts.DateTimeMinute), this.GetString(this.t.Commands.Common.Prompts.DateTimeMinute), 1, 2, true, $"{userTime.Minute}"));
+ _ = modal.AddTextComponent(new DiscordTextComponent(TextComponentStyle.Small, "hour", this.GetString(this.t.Commands.Common.Prompts.DateTimeHour), this.GetString(this.t.Commands.Common.Prompts.DateTimeHour), 1, 2, true, $"{userTime.Hour}"));
+ _ = modal.AddTextComponent(new DiscordTextComponent(TextComponentStyle.Small, "day", this.GetString(this.t.Commands.Common.Prompts.DateTimeDay), this.GetString(this.t.Commands.Common.Prompts.DateTimeDay), 1, 2, true, $"{userTime.Day}"));
+ _ = modal.AddTextComponent(new DiscordTextComponent(TextComponentStyle.Small, "month", this.GetString(this.t.Commands.Common.Prompts.DateTimeMonth), this.GetString(this.t.Commands.Common.Prompts.DateTimeMonth), 1, 2, true, $"{userTime.Month}"));
+ _ = modal.AddTextComponent(new DiscordTextComponent(TextComponentStyle.Small, "year", this.GetString(this.t.Commands.Common.Prompts.DateTimeYear), this.GetString(this.t.Commands.Common.Prompts.DateTimeYear), 1, 4, true, $"{userTime.Year}"));
+
+ var ModalResult = await this.PromptModalWithRetry(modalInteraction, modal, null, false, timeOutOverride.Value.Subtract(timeOut.Elapsed), modalInteraction != null);
+
+ if (ModalResult.Errored)
+ {
+ await UpdateMessage();
+ return;
+ }
+
+ InteractionCreateEventArgs Response = ModalResult.Result;
+
+ DateTime dateTime;
+
+ try
+ {
+ if ((Response.Interaction.Data.Components.Any(x => x.CustomId == "hour") && !Response.Interaction.Data.Components.First(x => x.CustomId == "hour").Value.IsDigitsOnly()) ||
+ (Response.Interaction.Data.Components.Any(x => x.CustomId == "minute") && !Response.Interaction.Data.Components.First(x => x.CustomId == "minute").Value.IsDigitsOnly()) ||
+ (Response.Interaction.Data.Components.Any(x => x.CustomId == "day") && !Response.Interaction.Data.Components.First(x => x.CustomId == "day").Value.IsDigitsOnly()) ||
+ (Response.Interaction.Data.Components.Any(x => x.CustomId == "month") && !Response.Interaction.Data.Components.First(x => x.CustomId == "month").Value.IsDigitsOnly()) ||
+ (Response.Interaction.Data.Components.Any(x => x.CustomId == "year") && !Response.Interaction.Data.Components.First(x => x.CustomId == "year").Value.IsDigitsOnly()))
+ throw new ArgumentException("Invalid date time");
+
+ var hour = Convert.ToInt32(Response.Interaction.GetModalValueByCustomId("hour"));
+ var minute = Convert.ToInt32(Response.Interaction.GetModalValueByCustomId("minute"));
+ var day = Convert.ToInt32(Response.Interaction.GetModalValueByCustomId("day"));
+ var month = Convert.ToInt32(Response.Interaction.GetModalValueByCustomId("month"));
+ var year = Convert.ToInt32(Response.Interaction.GetModalValueByCustomId("year"));
+
+ dateTime = TimeZoneInfo.ConvertTimeToUtc(new DateTime(year, month, day, hour, minute, 0, DateTimeKind.Unspecified), userTimezone);
+ }
+ catch (Exception)
+ {
+ await UpdateMessage();
+ return;
+ }
+
+ currentSelectedTime = dateTime;
+ }
+ else
+ { return; }
+
+ await UpdateMessage();
+ }
+ }).Add(this.ctx.Bot, this.ctx);
+ }
+
+ this.ctx.Client.ComponentInteractionCreated += Interaction;
+
+ while (!Finished && !Cancelled && timeOut.ElapsedMilliseconds < timeOutOverride.Value.TotalMilliseconds)
+ await Task.Delay(1000);
+
+ this.ctx.Client.ComponentInteractionCreated -= Interaction;
+
+ if (!Finished && !Cancelled && timeOut.ElapsedMilliseconds < timeOutOverride.Value.TotalMilliseconds)
+ return new InteractionResult(new TimedOutException());
+
+ if (Cancelled)
+ return new InteractionResult(new CancelException());
+
+ if (ResetToOriginalEmbed)
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().AddEmbeds(originalEmbed));
+
+ return new InteractionResult(currentSelectedTime);
+ }
+ #endregion
+
+ public async Task<(Stream stream, int fileSize)> PromptForFileUpload(TimeSpan? timeOutOverride = null)
+ {
+ timeOutOverride ??= TimeSpan.FromMinutes(15);
+
+ if (this.ctx.DbUser.PendingUserUpload is not null)
+ {
+ if (this.ctx.DbUser.PendingUserUpload.TimeOut.GetTotalSecondsUntil() > 0 && !this.ctx.DbUser.PendingUserUpload.InteractionHandled)
+ {
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
+ {
+ Description = $"`An upload interaction is already taking place. Please finish it beforehand.`",
+ }.AsError(this.ctx)));
+
+ throw new AlreadyAppliedException("");
+ }
+
+ this.ctx.DbUser.PendingUserUpload = null;
+ }
+
+ this.ctx.DbUser.PendingUserUpload = new UserUpload
+ {
+ TimeOut = DateTime.UtcNow.Add(timeOutOverride.Value)
+ };
+
+ while (this.ctx.DbUser.PendingUserUpload is not null && !this.ctx.DbUser.PendingUserUpload.InteractionHandled && this.ctx.DbUser.PendingUserUpload.TimeOut.GetTotalSecondsUntil() > 0)
+ {
+ await Task.Delay(500);
+ }
+
+ if (!this.ctx.DbUser.PendingUserUpload?.InteractionHandled ?? true)
+ throw new ArgumentException("");
+
+ var size = this.ctx.DbUser.PendingUserUpload.FileSize;
+ var stream = this.ctx.DbUser.PendingUserUpload.UploadedData;
+
+ this.ctx.DbUser.PendingUserUpload = null;
+ return (stream, size);
+ }
+
+ #region FinishInteraction
+ public void ModifyToTimedOut(bool Delete = false)
+ {
+ _ = this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder(this.ctx.ResponseMessage.Embeds[0]).WithFooter(this.ctx.ResponseMessage.Embeds[0]?.Footer?.Text + $" • {this.GetString(this.t.Commands.Common.InteractionTimeout)}").WithColor(DiscordColor.Gray)));
+
+ if (Delete)
+ _ = Task.Delay(5000).ContinueWith(_ =>
+ {
+ if (!this.ctx.ResponseMessage?.Flags.Value.HasMessageFlag(MessageFlags.Ephemeral) ?? false)
+ _ = this.ctx.ResponseMessage.DeleteAsync();
+ });
+ }
+
+ public void DeleteOrInvalidate()
+ {
+ switch (this.ctx.CommandType)
+ {
+ case Enums.CommandType.ContextMenu:
+ {
+ _ = this.ctx.OriginalContextMenuContext.DeleteResponseAsync();
+ break;
+ }
+ case Enums.CommandType.Event:
+ {
+ _ = this.ctx.OriginalComponentInteractionCreateEventArgs.Interaction.DeleteOriginalResponseAsync();
+ break;
+ }
+ case Enums.CommandType.ApplicationCommand:
+ {
+ _ = this.ctx.OriginalInteractionContext.DeleteResponseAsync();
+ break;
+ }
+ default:
+ {
+ _ = this.ctx.ResponseMessage?.DeleteAsync();
+ break;
+ }
+ }
+ }
+ #endregion
+
+ #region Checks
+ public async Task CheckVoiceState()
+ {
+ if (this.ctx.Member.VoiceState is null)
+ {
+ this.SendVoiceStateError();
+ return false;
+ }
+
+ return true;
+ }
+
+ public async Task CheckMaintenance()
+ {
+ if (!this.ctx.User.IsMaintenance(this.ctx.Bot.status))
+ {
+ this.SendMaintenanceError();
+ return false;
+ }
+
+ return true;
+ }
+
+ public async Task CheckBotOwner()
+ {
+ if (!this.ctx.User.IsMaintenance(this.ctx.Bot.status))
+ {
+ this.SendBotOwnerError();
+ return false;
+ }
+
+ return true;
+ }
+
+ public async Task CheckAdmin()
+ {
+ if (!this.ctx.Member.IsAdmin(this.ctx.Bot.status))
+ {
+ this.SendAdminError();
+ return false;
+ }
+
+ return true;
+ }
+
+ public async Task CheckPermissions(Permissions perms)
+ {
+ if (!this.ctx.Member.Permissions.HasPermission(perms))
+ {
+ this.SendPermissionError(perms);
+ return false;
+ }
+
+ return true;
+ }
+
+ public async Task CheckOwnPermissions(Permissions perms)
+ {
+ if (!this.ctx.CurrentMember.Permissions.HasPermission(perms))
+ {
+ this.SendOwnPermissionError(perms);
+ return false;
+ }
+
+ return true;
+ }
+
+ public async Task CheckSource(Enums.CommandType commandType)
+ {
+ if (this.ctx.CommandType != commandType)
+ {
+ this.SendSourceError(commandType);
+ return false;
+ }
+
+ return true;
+ }
+ #endregion
+
+ #region ErrorTemplates
+
+ public void SendDisabledCommandError(string disabledCommand)
+ => _ = this.RespondOrEdit(new DiscordEmbedBuilder()
+ {
+ Description = this.GetString(this.t.Commands.Common.Errors.CommandDisabled, true, new TVar("Command", disabledCommand))
+ }.AsError(this.ctx));
+
+ public void SendNoMemberError()
+ => _ = this.RespondOrEdit(new DiscordEmbedBuilder()
+ {
+ Description = this.GetString(this.t.Commands.Common.Errors.NoMember)
+ }.AsError(this.ctx));
+
+ public void SendMaintenanceError()
+ => _ = this.RespondOrEdit(new DiscordEmbedBuilder()
+ {
+ Description = this.GetString(this.t.Commands.Common.Errors.Generic).Build(true, new TVar("Required", $"{this.ctx.CurrentUser.GetUsername()} Staff"))
+ }.AsError(this.ctx));
+
+ public void SendBotOwnerError()
+ => _ = this.RespondOrEdit(new DiscordEmbedBuilder()
+ {
+ Description = this.GetString(this.t.Commands.Common.Errors.Generic).Build(true, new TVar("Required", $"<@{this.ctx.Bot.status.TeamOwner}>", false)),
+ }.AsError(this.ctx));
+
+ public void SendAdminError()
+ => _ = this.RespondOrEdit(new DiscordEmbedBuilder()
+ {
+ Description = this.GetString(this.t.Commands.Common.Errors.Generic).Build(true, new TVar("Required", "Administrator")),
+ }.AsError(this.ctx));
+
+ public void SendPermissionError(Permissions perms)
+ => _ = this.RespondOrEdit(new DiscordEmbedBuilder()
+ {
+ Description = this.GetString(this.t.Commands.Common.Errors.Generic).Build(true, new TVar("Required", perms.ToTranslatedPermissionString(this.ctx.DbUser, this.ctx.Bot))),
+ }.AsError(this.ctx));
+
+ public void SendVoiceStateError()
+ => _ = this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
+ {
+ Description = this.GetString(this.t.Commands.Common.Errors.VoiceChannel).Build(true),
+ }.AsError(this.ctx)));
+
+ public void SendUserBanError(BanDetails entry)
+ => _ = this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
+ {
+ Description = this.t.Commands.Common.Errors.UserBan.t["en"].Build(true, new TVar("Reason", entry.Reason)),
+ }.AsError(this.ctx)));
+
+ public void SendGuildBanError(BanDetails entry)
+ => _ = this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
+ {
+ Description = this.GetString(this.t.Commands.Common.Errors.GuildBan, true, new TVar("Reason", entry.Reason)),
+ }.AsError(this.ctx)));
+
+ public void SendSourceError(Enums.CommandType commandType)
+ => _ = commandType switch
+ {
+ Enums.CommandType.ApplicationCommand => this.RespondOrEdit(new DiscordEmbedBuilder()
+ {
+ Description = this.GetString(this.t.Commands.Common.Errors.ExclusiveApp).Build(true),
+ }.AsError(this.ctx)),
+ Enums.CommandType.PrefixCommand => this.RespondOrEdit(new DiscordEmbedBuilder()
+ {
+ Description = this.GetString(this.t.Commands.Common.Errors.ExclusivePrefix).Build(true)
+ }.AsError(this.ctx)),
+ _ => throw new ArgumentException("Invalid Source defined."),
+ };
+
+ public void SendDataError()
+ => _ = this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
+ {
+ Description = this.GetString(this.t.Commands.Common.Errors.Data, true, new TVar("Command", $"{this.ctx.Prefix}data delete")),
+ }.AsError(this.ctx)));
+
+ public void SendDmError()
+ => _ = this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
+ {
+ Description = $"📩 {this.GetString(this.t.Commands.Common.Errors.DirectMessage, true)}",
+ ImageUrl = (this.ctx.User.Presence.ClientStatus.Mobile.HasValue ? "https://cdn.discordapp.com/attachments/1005430437952356423/1144961395515998238/34rhz83ghtzu3ght.gif" : "https://cdn.discordapp.com/attachments/1005430437952356423/1144964670197862400/et2grtzu2ghrzi52.gif")
+ }.AsError(this.ctx)));
+
+ public void SendDmRedirect()
+ => _ = this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder
+ {
+ Description = $"📩 {this.GetString(this.t.Commands.Common.DirectMessageRedirect, true)}",
+ }.AsSuccess(this.ctx)));
+
+ public void SendOwnPermissionError(Permissions perms)
+ {
+ if (perms is Permissions.AccessChannels or Permissions.SendMessages or Permissions.EmbedLinks)
+ return;
+
+ _ = this.RespondOrEdit(new DiscordEmbedBuilder()
+ {
+ Description = this.GetString(this.t.Commands.Common.Errors.BotPermissions, true, new TVar("Required", perms.ToTranslatedPermissionString(this.ctx.DbUser, this.ctx.Bot)))
+ }.AsError(this.ctx));
+ }
+
+ public void SendSyntaxError()
+ {
+ if (this.ctx.CommandType != Enums.CommandType.PrefixCommand)
+ throw new ArgumentException("Syntax Error can only be generated for Prefix Commands.");
+
+ var ctx = this.ctx.OriginalCommandContext;
+
+ var embed = new DiscordEmbedBuilder
+ {
+ Description = $"**`{ctx.Prefix}{ctx.Command.Name}{(ctx.RawArgumentString != "" ? $" {ctx.RawArgumentString.SanitizeForCode().Replace("\\", "")}" : "")}` is not a valid way of using this command.**\nUse it like this instead: `{ctx.Prefix}{ctx.Command.GenerateUsage()}`\n\nArguments wrapped in `[]` are optional while arguments wrapped in `<>` are required.\n**Do not include the brackets when using commands, they're merely an indicator for requirement.**",
+ }.AsError(this.ctx);
+
+ _ = this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed).WithContent(this.ctx.User.Mention));
+ }
+ #endregion
+}
diff --git a/ProjectMakoto/Commands/Commands.cs b/ProjectMakoto/Commands/Commands.cs
new file mode 100644
index 00000000..71c299aa
--- /dev/null
+++ b/ProjectMakoto/Commands/Commands.cs
@@ -0,0 +1,199 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands;
+internal static class Commands
+{
+ public static List GetList() => [
+ new MakotoModule("Utility", [
+ new MakotoCommand("help", "Sends you a list of all available commands, their usage and their description.", typeof(HelpCommand),
+ new MakotoCommandOverload(typeof(string), "command", "The command to show help for", false)
+ .WithAutoComplete(typeof(AutocompleteProviders.HelpAutoComplete))),
+
+ new MakotoCommand("user-info", "Displays information the bot knows about you or the mentioned user.", typeof(UserInfoCommand),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "The User", false))
+ .WithAliases("userinfo"),
+
+ new MakotoCommand("guild-info", "Displays information this or the mentioned guild.", typeof(GuildInfoCommand),
+ new MakotoCommandOverload(typeof(string), "guild", "The Guild", false))
+ .WithAliases("guildinfo"),
+
+ new MakotoCommand("reminders", "Allows you to manage your reminders.", typeof(RemindersCommand)),
+
+ new MakotoCommand("avatar", "Displays your or the mentioned user's avatar as an embedded image.", typeof(AvatarCommand),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "The User", false))
+ .WithAliases("pfp"),
+
+ new MakotoCommand("banner", "Displays your or the mentioned user's banner as an embedded image.", typeof(BannerCommand),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "The User", false)),
+
+ new MakotoCommand("rank", "Shows your or the mentioned user's rank and rank progress.", typeof(RankCommand),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "The User", false))
+ .WithAliases("level", "lvl"),
+
+ new MakotoCommand("leaderboard", "Displays the current experience rankings on this server.", typeof(LeaderboardCommand),
+ new MakotoCommandOverload(typeof(int), "amount", "The amount of rankings to show", false)
+ .WithMinimumValue(3)
+ .WithMaximumValue(50)),
+
+ new MakotoCommand("report-host", "Allows you to contribute a new malicious host to our database.", typeof(ReportHostCommand),
+ new MakotoCommandOverload(typeof(string), "url", "The host", UseRemainingString: true)),
+
+ new MakotoCommand("report-translation", "Allows you to report missing, invalid or incorrect translations in Makoto.", typeof(ReportTranslationCommand),
+ new MakotoCommandOverload(typeof(ReportTranslationType), "affected_type", "The type of module that is affected"),
+ new MakotoCommandOverload(typeof(string), "component", "The affected component")
+ .WithAutoComplete(typeof(AutocompleteProviders.ReportTranslationAutoComplete)),
+ new MakotoCommandOverload(typeof(ReportTranslationReason), "report_type", "What type of issue you're reporting"),
+ new MakotoCommandOverload(typeof(string), "additional_information", "Any additional information you can give us", false, true)),
+
+ new MakotoCommand("upload", "Upload a file to the bot. Only use when instructed to.", typeof(UploadCommand),
+ new MakotoCommandOverload(typeof(DiscordAttachment), "file", "The file you want to upload.")),
+
+ new MakotoCommand("urban-dictionary", "Look up a term on Urban Dictionary.", typeof(UrbanDictionaryCommand),
+ new MakotoCommandOverload(typeof(string), "term", "The term you want to look up.", UseRemainingString: true)),
+
+ new MakotoCommand("data", "Allows you to request or manage your user data.",
+ new MakotoCommand("request", "Allows you to request your user data.", typeof(Data.RequestCommand)),
+ new MakotoCommand("delete", "Allows you to delete your user data and stop Makoto from further processing of your user data.", typeof(Data.DeleteCommand)),
+ new MakotoCommand("policy", "Allows you to view how Makoto processes your data.", typeof(Data.InfoCommand))),
+
+ new MakotoCommand("language", "Change the language Makoto uses.", typeof(LanguageCommand)),
+
+ new MakotoCommand("credits", "Allows you to view who contributed the bot.", typeof(CreditsCommand)),
+
+ new MakotoCommand("vcc", "Allows you to modify your own voice channel.",
+ new MakotoCommand("open", "Opens your channel so new users can freely join.", typeof(VcCreator.OpenCommand)),
+ new MakotoCommand("close", "Closes your channel. You have to invite people for them to join.", typeof(VcCreator.CloseCommand)),
+ new MakotoCommand("name", "Changes the name of your channel.", typeof(VcCreator.NameCommand),
+ new MakotoCommandOverload(typeof(string), "name", "The name", false, UseRemainingString: true)),
+ new MakotoCommand("limit", "Changes the user limit of your channel.", typeof(VcCreator.LimitCommand),
+ new MakotoCommandOverload(typeof(int), "limit", "The limit", false)
+ .WithMaximumValue(99)
+ .WithMinimumValue(0)),
+ new MakotoCommand("invite", "Invites a new person to your channel.", typeof(VcCreator.InviteCommand),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "User")),
+ new MakotoCommand("kick", "Kicks person from your channel.", typeof(VcCreator.KickCommand),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "User")),
+ new MakotoCommand("ban", "Bans person from your channel.", typeof(VcCreator.BanCommand),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "User")),
+ new MakotoCommand("unban", "Unbans person from your channel.", typeof(VcCreator.UnbanCommand),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "User")),
+ new MakotoCommand("change-owner", "Sets a new person to be the owner of your channel.", typeof(VcCreator.ChangeOwnerCommand),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "User"))),
+
+ new MakotoCommand(ApplicationCommandType.Message, "Steal Emojis", "Steals all emojis and stickers of a message. Reply to a message to select it.", typeof(EmojiStealerCommand), "emoji")
+ .WithAliases("emojis", "emote", "steal", "grab", "sticker", "stickers"),
+ ]).WithPriority(999),
+
+ new MakotoModule("Moderation", [
+ new MakotoCommand("purge", "Deletes the specified amount of messages.", typeof(PurgeCommand),
+ new MakotoCommandOverload(typeof(int), "number", "1-2000")
+ .WithMinimumValue(1)
+ .WithMaximumValue(2000),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "Only delete messages by this user", false))
+ .WithRequiredPermissions(Permissions.ManageMessages),
+
+ new MakotoCommand("guild-purge", "Scans all channels and deletes the specified user's messages.", typeof(GuildPurgeCommand),
+ new MakotoCommandOverload(typeof(int), "number", "1-2000")
+ .WithMinimumValue(1)
+ .WithMaximumValue(2000),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "Only delete messages by this user"))
+ .WithRequiredPermissions(Permissions.ManageMessages | Permissions.ManageChannels),
+
+ new MakotoCommand("clearbackup", "Clears the stored roles and nickname of a user.", typeof(ClearBackupCommand),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "Only delete messages by this user"))
+ .WithRequiredPermissions(Permissions.ManageRoles),
+
+ new MakotoCommand("timeout", "Sets the specified user into a timeout.", typeof(TimeoutCommand),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "The user"),
+ new MakotoCommandOverload(typeof(string), "duration", "The duration", false),
+ new MakotoCommandOverload(typeof(string), "reason", "The reason", false, true))
+ .WithRequiredPermissions(Permissions.ModerateMembers),
+
+ new MakotoCommand("remove-timeout", "Removes a timeout from the specified user.", typeof(RemoveTimeoutCommand),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "The user"))
+ .WithRequiredPermissions(Permissions.ModerateMembers),
+
+ new MakotoCommand("kick", "Kicks the specified user.", typeof(KickCommand),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "The user"),
+ new MakotoCommandOverload(typeof(string), "reason", "The reason", false, true))
+ .WithRequiredPermissions(Permissions.KickMembers),
+
+ new MakotoCommand("ban", "Bans the specified user.", typeof(BanCommand),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "The user"),
+ new MakotoCommandOverload(typeof(int), "days", "Days of messages to delete")
+ .WithMinimumValue(0)
+ .WithMaximumValue(7),
+ new MakotoCommandOverload(typeof(string), "reason", "The reason", false, true))
+ .WithRequiredPermissions(Permissions.BanMembers),
+
+ new MakotoCommand("softban", "Soft bans the specified user.", typeof(SoftBanCommand),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "The user"),
+ new MakotoCommandOverload(typeof(int), "days", "Days of messages to delete")
+ .WithMinimumValue(0)
+ .WithMaximumValue(7),
+ new MakotoCommandOverload(typeof(string), "reason", "The reason", false, true))
+ .WithRequiredPermissions(Permissions.BanMembers),
+
+ new MakotoCommand("unban", "Unbans the specified user.", typeof(UnbanCommand),
+ new MakotoCommandOverload(typeof(DiscordUser), "user", "The user"))
+ .WithRequiredPermissions(Permissions.BanMembers),
+
+ new MakotoCommand("follow", "Allows you to follow an announcement channel from our support server.", typeof(FollowUpdatesCommand),
+ new MakotoCommandOverload(typeof(FollowChannel), "channel", "The channel"))
+ .WithRequiredPermissions(Permissions.ManageWebhooks),
+
+ new MakotoCommand("moveall", "Move all users in your Voice Channel to another Voice Channel.", typeof(MoveAllCommand),
+ new MakotoCommandOverload(typeof(DiscordChannel), "channel", "The channel to move to.")
+ .WithChannelType(ChannelType.Voice))
+ .WithRequiredPermissions(Permissions.MoveMembers),
+
+ new MakotoCommand("movehere", "Move all users from another Voice Channel to your Voice Channel.", typeof(MoveHereCommand),
+ new MakotoCommandOverload(typeof(DiscordChannel), "channel", "The channel to move from.")
+ .WithChannelType(ChannelType.Voice))
+ .WithRequiredPermissions(Permissions.MoveMembers),
+
+ new MakotoCommand("customembed", "Create an embedded message", typeof(CustomEmbedCommand))
+ .WithRequiredPermissions(Permissions.EmbedLinks | Permissions.ManageChannels),
+
+ new MakotoCommand("override-bump-time", "Allows fixing of the last bump in case Disboard did not properly post a message.", typeof(ManualBumpCommand))
+ .WithRequiredPermissions(Permissions.ManageChannels),
+ ]).WithPriority(995),
+
+ new MakotoModule("Configuration", [
+ new MakotoCommand("config", "Allows you to configure Makoto.",
+ new MakotoCommand("join", "Allows you to review and change settings in the event somebody joins the server.", typeof(Configuration.JoinCommand)),
+ new MakotoCommand("experience", "Allows you to review and change settings related to experience.", typeof(Configuration.ExperienceCommand)),
+ new MakotoCommand("levelrewards", "Allows you to review, add and change Level Rewards.", typeof(Configuration.LevelRewardsCommand)),
+ new MakotoCommand("phishing", "Allows you to review and change settings related to phishing link protection.", typeof(Configuration.PhishingCommand)),
+ new MakotoCommand("bumpreminder", "Allows you to review, set up and change settings related to the Bump Reminder.", typeof(Configuration.BumpReminderCommand)),
+ new MakotoCommand("actionlog", "Allows you to review and change settings related to the actionlog.", typeof(Configuration.ActionLogCommand)),
+ new MakotoCommand("autocrosspost", "Allows you to review and change settings related to automatic crossposting.", typeof(Configuration.AutoCrosspostCommand)),
+ new MakotoCommand("reactionroles", "Allows you to review and change settings related to Reaction Roles.", typeof(ReactionRolesCommand.ConfigCommand)),
+ new MakotoCommand("invoiceprivacy", "Allows you to review and change settings related to In-Voice Text Channel Privacy.", typeof(Configuration.InVoicePrivacyCommand)),
+ new MakotoCommand("invitetracker", "Allows you to review and change settings related to Invite Tracking.", typeof(Configuration.InviteTrackerCommand)),
+ new MakotoCommand("namenormalizer", "Allows you to review and change settings related to automatic name normalization.", typeof(Configuration.NameNormalizerCommand)),
+ new MakotoCommand("autounarchive", "Allows you to review and change settings related to automatic thread unarchiving.", typeof(Configuration.AutoUnarchiveCommand)),
+ new MakotoCommand("embedmessages", "Allows you to review and change settings related to automatic message embedding.", typeof(Configuration.EmbedMessageCommand)),
+ new MakotoCommand("tokendetection", "Allows you to review and change settings related to automatic token invalidation.", typeof(Configuration.TokenDetectionCommand)),
+ new MakotoCommand("invitenotes", "Allows you to add notes to invite codes.", typeof(Configuration.InviteNotesCommand)),
+ new MakotoCommand("vccreator", "Allows you to review and change settings related to the Voice Channel Creator.", typeof(Configuration.VcCreatorCommand)),
+ new MakotoCommand("guild-language", "Allows you to review and change settings related to the guild's selected language.", typeof(Configuration.GuildLanguageCommand)),
+ new MakotoCommand("guild-prefix", "Allows you to review and change settings related to the guild's prefix.", typeof(Configuration.PrefixCommand)))
+ .WithRequiredPermissions(Permissions.Administrator),
+
+ new MakotoCommand(ApplicationCommandType.Message, "Add a Reaction Role", "Allows you to add a reaction role to a message directly.", typeof(ReactionRolesCommand.AddCommand))
+ .WithRequiredPermissions(Permissions.Administrator),
+ new MakotoCommand(ApplicationCommandType.Message, "Remove a Reaction Role", "Allows you to remove a specific reaction role from a message directly.", typeof(ReactionRolesCommand.RemoveCommand))
+ .WithRequiredPermissions(Permissions.Administrator),
+ new MakotoCommand(ApplicationCommandType.Message, "Remove all Reaction Roles", "Allows you to remove all reaction roles from a message directly.", typeof(ReactionRolesCommand.RemoveAllCommand))
+ .WithRequiredPermissions(Permissions.Administrator),
+ ]).WithPriority(994),
+ ];
+}
diff --git a/ProjectMakoto/Commands/Configuration/ActionLogCommand.cs b/ProjectMakoto/Commands/Configuration/ActionLogCommand.cs
new file mode 100644
index 00000000..addcd05d
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/ActionLogCommand.cs
@@ -0,0 +1,200 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class ActionLogCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ var CommandKey = ctx.Bot.LoadedTranslations.Commands.Config.ActionLog;
+
+ if (!ctx.Guild.Channels.ContainsKey(ctx.DbGuild.ActionLog.Channel))
+ ctx.DbGuild.ActionLog.Channel = 0;
+
+ if (ctx.DbGuild.ActionLog.Channel == 0)
+ return $"❌ {CommandKey.ActionlogDisabled.Get(ctx.DbUser).Build(true)}";
+
+ var pad = TranslationUtil.CalculatePadding(ctx.DbUser, CommandKey.InviteModifications, CommandKey.VoiceChannelUpdates, CommandKey.ChannelModifications, CommandKey.ServerModifications, CommandKey.BanUpdates,
+ CommandKey.RoleUpdates, CommandKey.MessageModifications, CommandKey.MessageModifications, CommandKey.UserProfileUpdates, CommandKey.UserRoleUpdates, CommandKey.UserStateUpdates,
+ CommandKey.AttemptGatheringMoreDetails, CommandKey.ActionLogChannel);
+
+ return $"{EmojiTemplates.GetChannel(ctx.Bot)} `{CommandKey.ActionLogChannel.Get(ctx.DbUser).PadRight(pad)}` : <#{ctx.DbGuild.ActionLog.Channel}>\n\n" +
+ $"⚠ `{CommandKey.AttemptGatheringMoreDetails.Get(ctx.DbUser).PadRight(pad)}` : {ctx.DbGuild.ActionLog.AttemptGettingMoreDetails.ToEmote(ctx.Bot)}\n" +
+ $"{EmojiTemplates.GetUser(ctx.Bot)} `{CommandKey.UserStateUpdates.Get(ctx.DbUser).PadRight(pad)}` : {ctx.DbGuild.ActionLog.MembersModified.ToEmote(ctx.Bot)}\n" +
+ $"{EmojiTemplates.GetUser(ctx.Bot)} `{CommandKey.UserRoleUpdates.Get(ctx.DbUser).PadRight(pad)}` : {ctx.DbGuild.ActionLog.MemberModified.ToEmote(ctx.Bot)}\n" +
+ $"{EmojiTemplates.GetUser(ctx.Bot)} `{CommandKey.UserProfileUpdates.Get(ctx.DbUser).PadRight(pad)}` : {ctx.DbGuild.ActionLog.MemberProfileModified.ToEmote(ctx.Bot)}\n" +
+ $"{EmojiTemplates.GetMessage(ctx.Bot)} `{CommandKey.MessageDeletions.Get(ctx.DbUser).PadRight(pad)}` : {ctx.DbGuild.ActionLog.MessageDeleted.ToEmote(ctx.Bot)}\n" +
+ $"{EmojiTemplates.GetMessage(ctx.Bot)} `{CommandKey.MessageModifications.Get(ctx.DbUser).PadRight(pad)}` : {ctx.DbGuild.ActionLog.MessageModified.ToEmote(ctx.Bot)}\n" +
+ $"{EmojiTemplates.GetUser(ctx.Bot)} `{CommandKey.RoleUpdates.Get(ctx.DbUser).PadRight(pad)}` : {ctx.DbGuild.ActionLog.RolesModified.ToEmote(ctx.Bot)}\n" +
+ $"{EmojiTemplates.GetUser(ctx.Bot)} `{CommandKey.BanUpdates.Get(ctx.DbUser).PadRight(pad)}` : {ctx.DbGuild.ActionLog.BanlistModified.ToEmote(ctx.Bot)}\n" +
+ $"{EmojiTemplates.GetGuild(ctx.Bot)} `{CommandKey.ServerModifications.Get(ctx.DbUser).PadRight(pad)}` : {ctx.DbGuild.ActionLog.GuildModified.ToEmote(ctx.Bot)}\n" +
+ $"{EmojiTemplates.GetChannel(ctx.Bot)} `{CommandKey.ChannelModifications.Get(ctx.DbUser).PadRight(pad)}` : {ctx.DbGuild.ActionLog.ChannelsModified.ToEmote(ctx.Bot)}\n" +
+ $"{EmojiTemplates.GetVoiceState(ctx.Bot)} `{CommandKey.VoiceChannelUpdates.Get(ctx.DbUser).PadRight(pad)}` : {ctx.DbGuild.ActionLog.VoiceStateUpdated.ToEmote(ctx.Bot)}\n" +
+ $"{EmojiTemplates.GetInvite(ctx.Bot)} `{CommandKey.InviteModifications.Get(ctx.DbUser).PadRight(pad)}` : {ctx.DbGuild.ActionLog.InvitesModified.ToEmote(ctx.Bot)}";
+ }
+
+ var CommandKey = this.t.Commands.Config.ActionLog;
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ var embed = new DiscordEmbedBuilder
+ {
+ Description = GetCurrentConfiguration(ctx)
+ }.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+
+ var Disable = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), this.GetString(CommandKey.DisableActionLogButton), (ctx.DbGuild.ActionLog.Channel == 0), new DiscordComponentEmoji(DiscordEmoji.FromUnicode("✖")));
+ var ChangeChannel = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), $"{(ctx.DbGuild.ActionLog.Channel == 0 ? this.GetString(CommandKey.SetChannelButton) : this.GetString(CommandKey.ChangeChannelButton))}", false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("💬")));
+ var ChangeFilter = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeFilterButton), (ctx.DbGuild.ActionLog.Channel == 0), new DiscordComponentEmoji(DiscordEmoji.FromUnicode("📣")));
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed)
+ .AddComponents(new List
+ {
+ { Disable }
+ })
+ .AddComponents(new List
+ {
+ { ChangeChannel },
+ { ChangeFilter }
+ }).AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var Button = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (Button.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ _ = Button.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (Button.GetCustomId() == Disable.CustomId)
+ {
+ ctx.DbGuild.ActionLog.Channel = 0;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == ChangeChannel.CustomId)
+ {
+ var ChannelResult = await this.PromptChannelSelection(ChannelType.Text, new ChannelPromptConfiguration
+ {
+ CreateChannelOption = new()
+ {
+ Name = "actionlog",
+ ChannelType = ChannelType.Text
+ }
+ });
+
+ if (ChannelResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ChannelResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (ChannelResult.Failed)
+ {
+ if (ChannelResult.Exception.GetType() == typeof(NullReferenceException))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(this.t.Commands.Common.Errors.NoChannels, true)));
+ await Task.Delay(3000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ throw ChannelResult.Exception;
+ }
+
+ await ChannelResult.Result.ModifyAsync(x => x.PermissionOverwrites = new List
+ {
+ new(ctx.Guild.EveryoneRole) { Denied = Permissions.All },
+ new(ctx.Member) { Allowed = Permissions.All },
+ });
+
+ ctx.DbGuild.ActionLog.Channel = ChannelResult.Result.Id;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == ChangeFilter.CustomId)
+ {
+ try
+ {
+ var Selections = new List
+ {
+ new(this.GetString(CommandKey.AttemptGatheringMoreDetails), "attempt_further_detail", this.GetString(CommandKey.OptionInaccurate), ctx.DbGuild.ActionLog.AttemptGettingMoreDetails, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("⚠"))),
+ new(this.GetString(CommandKey.UserStateUpdates), "log_members_modified", null, ctx.DbGuild.ActionLog.MembersModified, new DiscordComponentEmoji(EmojiTemplates.GetUser(ctx.Bot))),
+ new(this.GetString(CommandKey.UserRoleUpdates), "log_member_modified", null, ctx.DbGuild.ActionLog.MemberModified, new DiscordComponentEmoji(EmojiTemplates.GetUser(ctx.Bot))),
+ new(this.GetString(CommandKey.UserProfileUpdates), "log_memberprofile_modified", null, ctx.DbGuild.ActionLog.MemberProfileModified, new DiscordComponentEmoji(EmojiTemplates.GetUser(ctx.Bot))),
+ new(this.GetString(CommandKey.MessageDeletions), "log_message_deleted", null, ctx.DbGuild.ActionLog.MessageDeleted, new DiscordComponentEmoji(EmojiTemplates.GetMessage(ctx.Bot))),
+ new(this.GetString(CommandKey.MessageModifications), "log_message_updated", null, ctx.DbGuild.ActionLog.MessageModified, new DiscordComponentEmoji(EmojiTemplates.GetMessage(ctx.Bot))),
+ new(this.GetString(CommandKey.RoleUpdates), "log_roles_modified", null, ctx.DbGuild.ActionLog.RolesModified, new DiscordComponentEmoji(EmojiTemplates.GetUser(ctx.Bot))),
+ new(this.GetString(CommandKey.BanUpdates), "log_banlist_modified", null, ctx.DbGuild.ActionLog.BanlistModified, new DiscordComponentEmoji(EmojiTemplates.GetUser(ctx.Bot))),
+ new(this.GetString(CommandKey.ServerModifications), "log_guild_modified", null, ctx.DbGuild.ActionLog.GuildModified, new DiscordComponentEmoji(EmojiTemplates.GetGuild(ctx.Bot))),
+ new(this.GetString(CommandKey.ChannelModifications), "log_channels_modified", null, ctx.DbGuild.ActionLog.ChannelsModified, new DiscordComponentEmoji(EmojiTemplates.GetChannel(ctx.Bot))),
+ new(this.GetString(CommandKey.VoiceChannelUpdates), "log_voice_state", null, ctx.DbGuild.ActionLog.VoiceStateUpdated, new DiscordComponentEmoji(EmojiTemplates.GetVoiceState(ctx.Bot))),
+ new(this.GetString(CommandKey.InviteModifications), "log_invites_modified", null, ctx.DbGuild.ActionLog.InvitesModified, new DiscordComponentEmoji(EmojiTemplates.GetInvite(ctx.Bot))),
+ };
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed).AddComponents(new DiscordStringSelectComponent(this.GetString(CommandKey.NoOptions), Selections, Guid.NewGuid().ToString(), 0, Selections.Count, false)));
+
+ var e = await ctx.Client.GetInteractivity().WaitForSelectAsync(ctx.ResponseMessage, x => x.User.Id == ctx.User.Id, ComponentType.StringSelect, TimeSpan.FromMinutes(2));
+
+ if (e.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ _ = e.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ var selected = e.Result.Values.ToList();
+
+ ctx.DbGuild.ActionLog.AttemptGettingMoreDetails = selected.Contains("attempt_further_detail");
+
+ ctx.DbGuild.ActionLog.MembersModified = selected.Contains("log_members_modified");
+ ctx.DbGuild.ActionLog.MemberModified = selected.Contains("log_member_modified");
+ ctx.DbGuild.ActionLog.MemberProfileModified = selected.Contains("log_memberprofile_modified");
+ ctx.DbGuild.ActionLog.MessageDeleted = selected.Contains("log_message_deleted");
+ ctx.DbGuild.ActionLog.MessageModified = selected.Contains("log_message_updated");
+ ctx.DbGuild.ActionLog.RolesModified = selected.Contains("log_roles_modified");
+ ctx.DbGuild.ActionLog.BanlistModified = selected.Contains("log_banlist_modified");
+ ctx.DbGuild.ActionLog.GuildModified = selected.Contains("log_guild_modified");
+ ctx.DbGuild.ActionLog.ChannelsModified = selected.Contains("log_channels_modified");
+ ctx.DbGuild.ActionLog.VoiceStateUpdated = selected.Contains("log_voice_state");
+ ctx.DbGuild.ActionLog.InvitesModified = selected.Contains("log_invites_modified");
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ catch (ArgumentException)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ }
+ else if (Button.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/AutoCrosspostCommand.cs b/ProjectMakoto/Commands/Configuration/AutoCrosspostCommand.cs
new file mode 100644
index 00000000..0bd21aa6
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/AutoCrosspostCommand.cs
@@ -0,0 +1,226 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class AutoCrosspostCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.AutoCrosspost;
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ foreach (var b in ctx.DbGuild.Crosspost.CrosspostChannels.ToList())
+ if (!ctx.Guild.Channels.ContainsKey(b))
+ ctx.DbGuild.Crosspost.CrosspostChannels = ctx.DbGuild.Crosspost.CrosspostChannels.Remove(x => x.ToString(), b);
+
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ var CommandKey = ctx.Bot.LoadedTranslations.Commands.Config.AutoCrosspost;
+
+ var pad = TranslationUtil.CalculatePadding(ctx.DbUser, CommandKey.ExcludeBots, CommandKey.DelayBeforePosting);
+
+ return $"🤖 `{CommandKey.ExcludeBots.Get(ctx.DbUser).PadRight(pad)}`: {ctx.DbGuild.Crosspost.ExcludeBots.ToEmote(ctx.Bot)}\n" +
+ $"🕒 `{CommandKey.DelayBeforePosting.Get(ctx.DbUser).PadRight(pad)}`: `{TimeSpan.FromSeconds(ctx.DbGuild.Crosspost.DelayBeforePosting).GetHumanReadable()}`\n\n" +
+ $"{(ctx.DbGuild.Crosspost.CrosspostChannels.Length != 0 ? string.Join("\n\n", ctx.DbGuild.Crosspost.CrosspostChannels.Where(x => ctx.Guild.Channels.ContainsKey(x)).Select(x => $"<#{x}> `[#{ctx.Guild.GetChannel(x).Name}]`")) : CommandKey.NoCrosspostChannels.Get(ctx.DbUser).Build(true))}";
+ }
+
+ var embed = new DiscordEmbedBuilder()
+ {
+ Description = GetCurrentConfiguration(ctx)
+ }.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+
+ var SetDelayButton = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.SetDelayButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🕒")));
+ var ExcludeBots = new DiscordButtonComponent((ctx.DbGuild.Crosspost.ExcludeBots ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleExcludeBotsButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🤖")));
+ var AddButton = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.AddChannelButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("➕")));
+ var RemoveButton = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), this.GetString(CommandKey.RemoveChannelButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("✖")));
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed)
+ .AddComponents(new List
+ {
+ ExcludeBots,
+ SetDelayButton
+ })
+ .AddComponents(new List
+ {
+ AddButton,
+ RemoveButton
+ }).AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var Button = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (Button.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ if (Button.GetCustomId() == ExcludeBots.CustomId)
+ {
+ _ = Button.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ ctx.DbGuild.Crosspost.ExcludeBots = !ctx.DbGuild.Crosspost.ExcludeBots;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == SetDelayButton.CustomId)
+ {
+ _ = Button.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ var ModalResult = await this.PromptForTimeSpan(TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(ctx.DbGuild.Crosspost.DelayBeforePosting), false);
+
+ if (ModalResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ModalResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (ModalResult.Errored)
+ {
+ if (ModalResult.Exception.GetType() == typeof(InvalidOperationException))
+ {
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.WithDescription(this.GetString(CommandKey.DurationLimit, true)).AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (ModalResult.Exception.GetType() == typeof(ArgumentException))
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ throw ModalResult.Exception;
+ }
+
+ ctx.DbGuild.Crosspost.DelayBeforePosting = Convert.ToInt32(ModalResult.Result.TotalSeconds);
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == AddButton.CustomId)
+ {
+ _ = Button.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (ctx.DbGuild.Crosspost.CrosspostChannels.Length >= 20)
+ {
+ embed.Description = this.GetString(CommandKey.ChannelLimit, true, new TVar("Invite", ctx.Bot.status.DevelopmentServerInvite));
+ embed = embed.AsError(ctx, this.GetString(CommandKey.Title));
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed));
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ var ChannelResult = await this.PromptChannelSelection(ChannelType.News);
+
+ if (ChannelResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ChannelResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (ChannelResult.Failed)
+ {
+ if (ChannelResult.Exception.GetType() == typeof(NullReferenceException))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(this.t.Commands.Common.Errors.NoChannels, true)));
+ await Task.Delay(3000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ throw ChannelResult.Exception;
+ }
+
+ if (ChannelResult.Result.Type != ChannelType.News)
+ {
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.WithDescription(this.GetString(this.t.Commands.Common.Errors.NoChannels, true)).AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ if (ctx.DbGuild.Crosspost.CrosspostChannels.Length >= 50)
+ {
+ _ = await this.RespondOrEdit(embed.WithDescription(this.GetString(CommandKey.ChannelLimit, true, new TVar("Invite", ctx.Bot.status.DevelopmentServerInvite))).AsError(ctx, this.GetString(CommandKey.Title)));
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ if (!ctx.DbGuild.Crosspost.CrosspostChannels.Contains(ChannelResult.Result.Id))
+ ctx.DbGuild.Crosspost.CrosspostChannels = ctx.DbGuild.Crosspost.CrosspostChannels.Add(ChannelResult.Result.Id);
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+
+ }
+ else if (Button.GetCustomId() == RemoveButton.CustomId)
+ {
+ _ = Button.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (ctx.DbGuild.Crosspost.CrosspostChannels.Length == 0)
+ {
+ _ = await this.RespondOrEdit(embed.WithDescription(this.GetString(CommandKey.NoCrosspostChannels, true)).AsError(ctx, this.GetString(CommandKey.Title)));
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ var ChannelResult = await this.PromptCustomSelection(ctx.DbGuild.Crosspost.CrosspostChannels
+ .Where(x => ctx.Guild.Channels.ContainsKey(x))
+ .Select(x => new DiscordStringSelectComponentOption($"#{ctx.Guild.GetChannel(x).Name} ({x})", x.ToString(), $"{(ctx.Guild.GetChannel(x).Parent is not null ? $"{ctx.Guild.GetChannel(x).Parent.Name}" : "")}")).ToList());
+
+ if (ChannelResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ChannelResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (ChannelResult.Errored)
+ {
+ throw ChannelResult.Exception;
+ }
+
+ var ChannelToRemove = Convert.ToUInt64(ChannelResult.Result);
+
+ if (ctx.DbGuild.Crosspost.CrosspostChannels.Contains(ChannelToRemove))
+ ctx.DbGuild.Crosspost.CrosspostChannels = ctx.DbGuild.Crosspost.CrosspostChannels.Remove(x => x.ToString(), ChannelToRemove);
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/AutoUnarchiveCommand.cs b/ProjectMakoto/Commands/Configuration/AutoUnarchiveCommand.cs
new file mode 100644
index 00000000..31e8b076
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/AutoUnarchiveCommand.cs
@@ -0,0 +1,130 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class AutoUnarchiveCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.AutoUnarchive;
+
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ foreach (var b in ctx.DbGuild.AutoUnarchiveThreads.ToList())
+ {
+ if (!ctx.Guild.Channels.ContainsKey(b))
+ ctx.DbGuild.AutoUnarchiveThreads = ctx.DbGuild.AutoUnarchiveThreads.Remove(x => x.ToString(), b);
+ }
+
+ return $"{(ctx.DbGuild.AutoUnarchiveThreads.Length != 0 ? string.Join("\n", ctx.DbGuild.AutoUnarchiveThreads.Select(x => $"{ctx.Guild.GetChannel(x).Mention} [`#{ctx.Guild.GetChannel(x).Name}`] (`{x}`)")) : ctx.Bot.LoadedTranslations.Commands.Config.AutoUnarchive.NoChannels.Get(ctx.DbUser).Build(true))}";
+ }
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ var embed = new DiscordEmbedBuilder
+ {
+ Description = $"{GetCurrentConfiguration(ctx)}\n\n{this.GetString(CommandKey.Explanation)}"
+ }.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+
+ var Add = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), this.GetString(CommandKey.AddChannelButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("➕")));
+ var Remove = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), this.GetString(CommandKey.RemoveChannelButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("✖")));
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed)
+ .AddComponents(new List
+ {
+ Add,
+ Remove
+ })
+ .AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var e = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (e.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ _ = e.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (e.GetCustomId() == Add.CustomId)
+ {
+ var ChannelResult = await this.PromptChannelSelection(new ChannelType[] { ChannelType.Text, ChannelType.Forum });
+
+ if (ChannelResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ChannelResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (ChannelResult.Failed)
+ {
+ if (ChannelResult.Exception.GetType() == typeof(NullReferenceException))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(this.t.Commands.Common.Errors.NoChannels)));
+ await Task.Delay(3000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ throw ChannelResult.Exception;
+ }
+
+ if (!ctx.DbGuild.AutoUnarchiveThreads.Contains(ChannelResult.Result.Id))
+ ctx.DbGuild.AutoUnarchiveThreads = ctx.DbGuild.AutoUnarchiveThreads.Add(ChannelResult.Result.Id);
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == Remove.CustomId)
+ {
+ var ChannelResult = await this.PromptCustomSelection(ctx.DbGuild.AutoUnarchiveThreads
+ .Select(x => new DiscordStringSelectComponentOption($"#{ctx.Guild.GetChannel(x).Name} ({x})", x.ToString(), $"{(ctx.Guild.GetChannel(x).Parent is not null ? $"{ctx.Guild.GetChannel(x).Parent.Name}" : "")}")).ToList());
+
+ if (ChannelResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ChannelResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (ChannelResult.Errored)
+ {
+ throw ChannelResult.Exception;
+ }
+
+ var ChannelToRemove = Convert.ToUInt64(ChannelResult.Result);
+
+ if (ctx.DbGuild.AutoUnarchiveThreads.Contains(ChannelToRemove))
+ ctx.DbGuild.AutoUnarchiveThreads = ctx.DbGuild.AutoUnarchiveThreads.Remove(x => x.ToString(), ChannelToRemove);
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/BumpReminderCommand.cs b/ProjectMakoto/Commands/Configuration/BumpReminderCommand.cs
new file mode 100644
index 00000000..7fcc6b21
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/BumpReminderCommand.cs
@@ -0,0 +1,230 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class BumpReminderCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx)
+ => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.BumpReminder;
+
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ var CommandKey = ctx.Bot.LoadedTranslations.Commands.Config.BumpReminder;
+
+ if (ctx.DbGuild.BumpReminder.ChannelId == 0)
+ return $"{EmojiTemplates.GetQuestionMark(ctx.Bot)} `{CommandKey.BumpReminderEnabled.Get(ctx.DbUser)}` : {false.ToEmote(ctx.Bot)}";
+
+ var pad = TranslationUtil.CalculatePadding(ctx.DbUser, CommandKey.BumpReminderEnabled, CommandKey.BumpReminderChannel, CommandKey.BumpReminderRole);
+
+ return $"{EmojiTemplates.GetQuestionMark(ctx.Bot)} `{CommandKey.BumpReminderEnabled.Get(ctx.DbUser).PadRight(pad)}` : {true.ToEmote(ctx.Bot)}\n" +
+ $"{EmojiTemplates.GetChannel(ctx.Bot)} `{CommandKey.BumpReminderChannel.Get(ctx.DbUser).PadRight(pad)}` : <#{ctx.DbGuild.BumpReminder.ChannelId}> `({ctx.DbGuild.BumpReminder.ChannelId})`\n" +
+ $"{EmojiTemplates.GetUser(ctx.Bot)} `{CommandKey.BumpReminderRole.Get(ctx.DbUser).PadRight(pad)}` : <@&{ctx.DbGuild.BumpReminder.RoleId}> `({ctx.DbGuild.BumpReminder.RoleId})`";
+ }
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ var Setup = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), this.GetString(CommandKey.SetupBumpReminderButton), ctx.DbGuild.BumpReminder.ChannelId != 0, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("➕")));
+ var Disable = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), this.GetString(CommandKey.DisableBumpReminderButton), ctx.DbGuild.BumpReminder.ChannelId == 0, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("✖")));
+ var ChangeChannel = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeChannelButton), ctx.DbGuild.BumpReminder.ChannelId == 0, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("💬")));
+ var ChangeRole = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeRoleButton), ctx.DbGuild.BumpReminder.ChannelId == 0, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👤")));
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder()
+ .WithDescription(GetCurrentConfiguration(ctx)).AsAwaitingInput(ctx, this.GetString(CommandKey.Title)))
+ .AddComponents(new List
+ {
+ { Setup },
+ { Disable }
+ })
+ .AddComponents(new List
+ {
+ { ChangeChannel },
+ { ChangeRole }
+ }).AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var e = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (e.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ _ = e.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (e.GetCustomId() == Setup.CustomId)
+ {
+ if (!(await ctx.Guild.GetAllMembersAsync()).Any(x => x.Id == ctx.Bot.status.LoadedConfig.Accounts.Disboard))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder()
+ .WithDescription(this.GetString(CommandKey.DisboardMissing, true))
+ .AsError(ctx, this.GetString(CommandKey.Title)));
+ return;
+ }
+
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder()
+ .WithDescription(this.GetString(CommandKey.SettingUp, true))
+ .AsLoading(ctx, this.GetString(CommandKey.Title)));
+
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder()
+ .WithDescription(this.GetString(CommandKey.SelectRole, true))
+ .AsAwaitingInput(ctx, this.GetString(CommandKey.Title)));
+
+
+ var RoleResult = await this.PromptRoleSelection(new() { CreateRoleOption = "BumpReminder" });
+
+ if (RoleResult.TimedOut)
+ {
+ this.ModifyToTimedOut();
+ return;
+ }
+ else if (RoleResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (RoleResult.Failed)
+ {
+ if (RoleResult.Exception.GetType() == typeof(NullReferenceException))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(this.t.Commands.Common.Errors.NoChannels, true)));
+ await Task.Delay(3000);
+ return;
+ }
+
+ throw RoleResult.Exception;
+ }
+
+ if (RoleResult.Result.Id == ctx.DbGuild.Join.AutoAssignRoleId || ctx.DbGuild.LevelRewards.Any(x => x.RoleId == RoleResult.Result.Id))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(CommandKey.CantUseRole, true)));
+ await Task.Delay(3000);
+ return;
+ }
+
+ var bump_reaction_msg = await ctx.Channel.SendMessageAsync(this.GetGuildString(CommandKey.ReactionRoleMessage, new TVar("Emoji", "✅".UnicodeToEmoji())));
+ _ = bump_reaction_msg.CreateReactionAsync(DiscordEmoji.FromUnicode("✅"));
+ _ = bump_reaction_msg.PinAsync();
+
+ _ = ctx.Channel.DeleteMessagesAsync((await ctx.Channel.GetMessagesAsync(2)).Where(x => x.Author.Id == ctx.Client.CurrentUser.Id && x.MessageType == MessageType.ChannelPinnedMessage));
+
+ ctx.DbGuild.BumpReminder.RoleId = RoleResult.Result.Id;
+ ctx.DbGuild.BumpReminder.ChannelId = ctx.Channel.Id;
+ ctx.DbGuild.BumpReminder.MessageId = bump_reaction_msg.Id;
+ ctx.DbGuild.BumpReminder.LastBump = DateTime.UtcNow.AddHours(-2);
+ ctx.DbGuild.BumpReminder.LastReminder = DateTime.UtcNow.AddHours(-2);
+ ctx.DbGuild.BumpReminder.LastUserId = 0;
+
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder()
+ .WithDescription(this.GetString(CommandKey.SetupComplete, true))
+ .AsSuccess(ctx, this.GetString(CommandKey.Title)));
+
+ await Task.Delay(5000);
+ ctx.Bot.BumpReminder.SendPersistentMessage(ctx.Client, ctx.Channel, null);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == Disable.CustomId)
+ {
+ ctx.DbGuild.BumpReminder.Reset();
+
+ foreach (var b in ScheduledTaskExtensions.GetScheduledTasks())
+ {
+ if (b.CustomData is not ScheduledTaskIdentifier scheduledTaskIdentifier)
+ continue;
+
+ if (scheduledTaskIdentifier.Snowflake == ctx.Guild.Id && scheduledTaskIdentifier.Type == "bumpmsg")
+ b.Delete();
+ }
+
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder()
+ .WithDescription(this.GetString(CommandKey.DisableBumpReminderButton, true))
+ .AsSuccess(ctx, this.GetString(CommandKey.Title)));
+
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == ChangeChannel.CustomId)
+ {
+ var ChannelResult = await this.PromptChannelSelection(ChannelType.Text);
+
+ if (ChannelResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ChannelResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (ChannelResult.Failed)
+ {
+ if (ChannelResult.Exception.GetType() == typeof(NullReferenceException))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(this.t.Commands.Common.Errors.NoChannels)));
+ await Task.Delay(3000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ throw ChannelResult.Exception;
+ }
+
+ ctx.DbGuild.BumpReminder.ChannelId = ChannelResult.Result.Id;
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == ChangeRole.CustomId)
+ {
+
+ var RoleResult = await this.PromptRoleSelection();
+
+ if (RoleResult.TimedOut)
+ {
+ this.ModifyToTimedOut();
+ return;
+ }
+ else if (RoleResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (RoleResult.Failed)
+ {
+ if (RoleResult.Exception.GetType() == typeof(NullReferenceException))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(this.t.Commands.Common.Errors.NoRoles, true)));
+ await Task.Delay(3000);
+ return;
+ }
+
+ throw RoleResult.Exception;
+ }
+
+ ctx.DbGuild.BumpReminder.RoleId = RoleResult.Result.Id;
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/EmbedMessageCommand.cs b/ProjectMakoto/Commands/Configuration/EmbedMessageCommand.cs
new file mode 100644
index 00000000..9db9f3d5
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/EmbedMessageCommand.cs
@@ -0,0 +1,82 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class EmbedMessageCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.EmbedMessages;
+
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ var CommandKey = ctx.Bot.LoadedTranslations.Commands.Config.EmbedMessages;
+
+ var pad = TranslationUtil.CalculatePadding(ctx.DbUser, CommandKey.EmbedGithubCode, CommandKey.EmbedMessageLinks);
+
+ return $"{"💬".UnicodeToEmoji()} `{CommandKey.EmbedMessageLinks.Get(ctx.DbUser).PadRight(pad)}`: {ctx.DbGuild.EmbedMessage.UseEmbedding.ToEmote(ctx.Bot)}\n" +
+ $"{"🤖".UnicodeToEmoji()} `{CommandKey.EmbedGithubCode.Get(ctx.DbUser).PadRight(pad)}`: {ctx.DbGuild.EmbedMessage.UseGithubEmbedding.ToEmote(ctx.Bot)}";
+ }
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ var embed = new DiscordEmbedBuilder
+ {
+ Description = GetCurrentConfiguration(ctx)
+ }.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+
+ var ToggleMsg = new DiscordButtonComponent((ctx.DbGuild.EmbedMessage.UseEmbedding ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleMessageLinkButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("💬")));
+ var ToggleGithub = new DiscordButtonComponent((ctx.DbGuild.EmbedMessage.UseGithubEmbedding ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleGithubCodeButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🤖")));
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed)
+ .AddComponents(new List
+ {
+ ToggleMsg,
+ ToggleGithub
+ })
+ .AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var e = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (e.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ _ = e.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (e.GetCustomId() == ToggleMsg.CustomId)
+ {
+ ctx.DbGuild.EmbedMessage.UseEmbedding = !ctx.DbGuild.EmbedMessage.UseEmbedding;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ if (e.GetCustomId() == ToggleGithub.CustomId)
+ {
+ ctx.DbGuild.EmbedMessage.UseGithubEmbedding = !ctx.DbGuild.EmbedMessage.UseGithubEmbedding;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/ExperienceCommand.cs b/ProjectMakoto/Commands/Configuration/ExperienceCommand.cs
new file mode 100644
index 00000000..733ff290
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/ExperienceCommand.cs
@@ -0,0 +1,83 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class ExperienceCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.Experience;
+
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ var CommandKey = ctx.Bot.LoadedTranslations.Commands.Config.Experience;
+
+ var pad = TranslationUtil.CalculatePadding(ctx.DbUser, CommandKey.ExperienceEnabled, CommandKey.ExperienceBoostForBumpers);
+
+ return $"{"✨".UnicodeToEmoji()} `{CommandKey.ExperienceEnabled.Get(ctx.DbUser).PadRight(pad)}`: {ctx.DbGuild.Experience.UseExperience.ToEmote(ctx.Bot)}\n" +
+ $"{"⏫".UnicodeToEmoji()} `{CommandKey.ExperienceBoostForBumpers.Get(ctx.DbUser).PadRight(pad)}`: {ctx.DbGuild.Experience.BoostXpForBumpReminder.ToEmote(ctx.Bot)}";
+ }
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ var embed = new DiscordEmbedBuilder()
+ {
+ Description = GetCurrentConfiguration(ctx)
+ }.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+
+ var builder = new DiscordMessageBuilder().WithEmbed(embed);
+
+ var ToggleExperienceSystem = new DiscordButtonComponent((ctx.DbGuild.Experience.UseExperience ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleExperienceButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("✨")));
+ var ToggleBumperBoost = new DiscordButtonComponent((ctx.DbGuild.Experience.BoostXpForBumpReminder ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleExperienceBoostButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("⏫")));
+
+ _ = await this.RespondOrEdit(builder
+ .AddComponents(new List
+ {
+ ToggleExperienceSystem,
+ ToggleBumperBoost,
+ })
+ .AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var e = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (e.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ _ = e.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (e.GetCustomId() == ToggleExperienceSystem.CustomId)
+ {
+ ctx.DbGuild.Experience.UseExperience = !ctx.DbGuild.Experience.UseExperience;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == ToggleBumperBoost.CustomId)
+ {
+ ctx.DbGuild.Experience.BoostXpForBumpReminder = !ctx.DbGuild.Experience.BoostXpForBumpReminder;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/GuildLanguageCommand.cs b/ProjectMakoto/Commands/Configuration/GuildLanguageCommand.cs
new file mode 100644
index 00000000..ded75eb8
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/GuildLanguageCommand.cs
@@ -0,0 +1,114 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class GuildLanguageCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ return $"🗨 `{ctx.BaseCommand.GetString(this.t.Commands.Config.GuildLanguage.Disclaimer)}`\n`{ctx.BaseCommand.GetString(ctx.t.Commands.Config.GuildLanguage.Response)}`: `{(ctx.DbGuild.OverrideLocale.IsNullOrWhiteSpace() ? (ctx.DbGuild.CurrentLocale.IsNullOrWhiteSpace() ? "en (Default)" : $"{ctx.DbGuild.CurrentLocale} (Discord)") : $"{ctx.DbGuild.OverrideLocale} (Override)")}`";
+ }
+
+ _ = await this.RespondOrEdit((new DiscordEmbedBuilder()
+ {
+ Description = GetCurrentConfiguration(ctx)
+ }.AsAwaitingInput(ctx, this.GetString(this.t.Commands.Config.GuildLanguage.Title))));
+
+ List options = new();
+ List newOptions = new();
+
+ newOptions.Add(new DiscordStringSelectComponentOption("Disable Override", "_", this.GetString(this.t.Commands.Config.GuildLanguage.DisableOverride), false, DiscordEmoji.FromUnicode("❌").ToComponent()));
+
+ options.Add(new DiscordStringSelectComponentOption("English", "en", "English"));
+ options.Add(new DiscordStringSelectComponentOption("German", "de", "Deutsch"));
+ options.Add(new DiscordStringSelectComponentOption("Indonesian", "id", "Bahasa Indonesia"));
+ options.Add(new DiscordStringSelectComponentOption("Danish", "da", "Dansk"));
+ options.Add(new DiscordStringSelectComponentOption("Spanish", "es-ES", "Español"));
+ options.Add(new DiscordStringSelectComponentOption("French", "fr", "Français"));
+ options.Add(new DiscordStringSelectComponentOption("Croatian", "hr", "Hrvatski"));
+ options.Add(new DiscordStringSelectComponentOption("Italian", "it", "Italiano"));
+ options.Add(new DiscordStringSelectComponentOption("Lithuanian", "lt", "Lietuviškai"));
+ options.Add(new DiscordStringSelectComponentOption("Hungarian", "hu", "Magyar"));
+ options.Add(new DiscordStringSelectComponentOption("Dutch", "nl", "Nederlands"));
+ options.Add(new DiscordStringSelectComponentOption("Norwegian", "no", "Norsk"));
+ options.Add(new DiscordStringSelectComponentOption("Polish", "pl", "Polski"));
+ options.Add(new DiscordStringSelectComponentOption("Portuguese, Brazilian", "pt-BR", "Português do Brasil"));
+ options.Add(new DiscordStringSelectComponentOption("Romanian, Romania", "ro", "Română"));
+ options.Add(new DiscordStringSelectComponentOption("Finnish", "fi", "Suomi"));
+ options.Add(new DiscordStringSelectComponentOption("Swedish", "sv-SE", "Svenska"));
+ options.Add(new DiscordStringSelectComponentOption("Vietnamese", "vi", "Tiếng Việt"));
+ options.Add(new DiscordStringSelectComponentOption("Turkish", "tr", "Türkçe"));
+ options.Add(new DiscordStringSelectComponentOption("Czech", "cs", "Čeština"));
+ options.Add(new DiscordStringSelectComponentOption("Greek", "el", "Ελληνικά"));
+ options.Add(new DiscordStringSelectComponentOption("Bulgarian", "bg", "български"));
+ options.Add(new DiscordStringSelectComponentOption("Russian", "ru", "Pусский"));
+ options.Add(new DiscordStringSelectComponentOption("Ukrainian", "uk", "Українська"));
+ options.Add(new DiscordStringSelectComponentOption("Hindi", "hi", "हिन्दी"));
+ options.Add(new DiscordStringSelectComponentOption("Thai", "th", "ไทย"));
+ options.Add(new DiscordStringSelectComponentOption("Chinese, China", "zh-CN", "中文"));
+ options.Add(new DiscordStringSelectComponentOption("Japanese", "ja", "日本語"));
+ options.Add(new DiscordStringSelectComponentOption("Chinese, Taiwan", "zh-TW", "繁體中文"));
+ options.Add(new DiscordStringSelectComponentOption("Korean", "ko", "한국어"));
+
+ foreach (var b in options)
+ if (this.t.Progress.TryGetValue(b.Value, out var value))
+ {
+ var perc = (value / (decimal)this.t.Progress["en"] * 100);
+ DiscordComponentEmoji emoji = null;
+
+ if (perc >= 100)
+ emoji = DiscordEmoji.FromUnicode("🟢").ToComponent();
+ else emoji = perc >= 85 ? DiscordEmoji.FromUnicode("🟡").ToComponent() : DiscordEmoji.FromUnicode("🔴").ToComponent();
+
+ newOptions.Add(new DiscordStringSelectComponentOption(b.Label, b.Value, b.Description.Insert(0, $"{perc.ToString("N1", CultureInfo.CreateSpecificCulture("en-US"))}% | "), false, emoji));
+ }
+
+ var SelectionResult = await this.PromptCustomSelection(newOptions, this.GetString(this.t.Commands.Config.GuildLanguage.Selector));
+
+ if (SelectionResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (SelectionResult.Cancelled)
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ else if (SelectionResult.Errored)
+ {
+ throw SelectionResult.Exception;
+ }
+
+ switch (SelectionResult.Result)
+ {
+ case "_":
+ {
+ ctx.DbGuild.OverrideLocale = null;
+ break;
+ }
+ default:
+ {
+ ctx.DbGuild.OverrideLocale = SelectionResult.Result;
+ break;
+ }
+ }
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/InVoicePrivacyCommand.cs b/ProjectMakoto/Commands/Configuration/InVoicePrivacyCommand.cs
new file mode 100644
index 00000000..e872534c
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/InVoicePrivacyCommand.cs
@@ -0,0 +1,106 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class InVoicePrivacyCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.InVoicePrivacy;
+
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ var CommandKey = ctx.Bot.LoadedTranslations.Commands.Config.InVoicePrivacy;
+
+ var pad = TranslationUtil.CalculatePadding(ctx.DbUser, CommandKey.ClearMessagesOnLeave, CommandKey.SetPermissions);
+
+ return $"{"🗑".UnicodeToEmoji()} `{CommandKey.ClearMessagesOnLeave.Get(ctx.DbUser).PadRight(pad)}`: {ctx.DbGuild.InVoiceTextPrivacy.ClearTextEnabled.ToEmote(ctx.Bot)}\n" +
+ $"{"📋".UnicodeToEmoji()} `{CommandKey.SetPermissions.Get(ctx.DbUser).PadRight(pad)}`: {ctx.DbGuild.InVoiceTextPrivacy.SetPermissionsEnabled.ToEmote(ctx.Bot)}";
+ }
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ var embed = new DiscordEmbedBuilder
+ {
+ Description = GetCurrentConfiguration(ctx)
+ }.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+
+ var ToggleDeletion = new DiscordButtonComponent((ctx.DbGuild.InVoiceTextPrivacy.ClearTextEnabled ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleMessageDeletionButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🗑")));
+ var TogglePermission = new DiscordButtonComponent((ctx.DbGuild.InVoiceTextPrivacy.SetPermissionsEnabled ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.TogglePermissionProtectionButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("📋")));
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed)
+ .AddComponents(new List
+ {
+ ToggleDeletion,
+ TogglePermission
+ })
+ .AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var e = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (e.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ _ = e.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (e.GetCustomId() == ToggleDeletion.CustomId)
+ {
+ ctx.DbGuild.InVoiceTextPrivacy.ClearTextEnabled = !ctx.DbGuild.InVoiceTextPrivacy.ClearTextEnabled;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == TogglePermission.CustomId)
+ {
+ ctx.DbGuild.InVoiceTextPrivacy.SetPermissionsEnabled = !ctx.DbGuild.InVoiceTextPrivacy.SetPermissionsEnabled;
+
+ _ = Task.Run(async () =>
+ {
+ if (ctx.DbGuild.InVoiceTextPrivacy.SetPermissionsEnabled)
+ {
+ if (!ctx.Guild.Channels.Any(x => x.Value.Type == ChannelType.Voice))
+ return;
+
+ foreach (var b in ctx.Guild.Channels.Where(x => x.Value.Type == ChannelType.Voice))
+ {
+ _ = b.Value.AddOverwriteAsync(ctx.Guild.EveryoneRole, Permissions.None, Permissions.ReadMessageHistory | Permissions.SendMessages, this.GetGuildString(CommandKey.EnabledInVoicePrivacy));
+ }
+ }
+ else
+ {
+ if (!ctx.Guild.Channels.Any(x => x.Value.Type == ChannelType.Voice))
+ return;
+
+ foreach (var b in ctx.Guild.Channels.Where(x => x.Value.Type == ChannelType.Voice))
+ {
+ _ = b.Value.DeleteOverwriteAsync(ctx.Guild.EveryoneRole, this.GetGuildString(CommandKey.DisabledInVoicePrivacy));
+ }
+ }
+ });
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/InviteNotesCommand.cs b/ProjectMakoto/Commands/Configuration/InviteNotesCommand.cs
new file mode 100644
index 00000000..6806e2d2
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/InviteNotesCommand.cs
@@ -0,0 +1,192 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class InviteNotesCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.InviteNotes;
+
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ return ctx.DbGuild.InviteNotes.Notes.Length == 0
+ ? ctx.BaseCommand.GetString(this.t.Commands.Config.InviteNotes.NoNotesDefined, true)
+ : $"{string.Join('\n', ctx.DbGuild.InviteNotes.Notes.Select(x => $"> `{x.Invite}`\n{x.Note.FullSanitize()}"))}";
+ }
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ var AddButton = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.AddNoteButton), false, DiscordEmoji.FromUnicode("➕").ToComponent());
+ var RemoveButton = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.RemoveNoteButton), false, DiscordEmoji.FromUnicode("➖").ToComponent());
+
+ var embed = new DiscordEmbedBuilder
+ {
+ Description = GetCurrentConfiguration(ctx)
+ }.AsInfo(ctx, this.GetString(CommandKey.Title));
+
+ if (!(ctx.DbGuild.InviteNotes.Notes.Length > 19))
+ {
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed)
+ .AddComponents(new List
+ {
+ AddButton,
+ RemoveButton,
+ }).AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+ }
+ else
+ {
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed)
+ .AddComponents(new List { RemoveButton }).AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+ }
+
+ var e = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (e.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ _ = e.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (e.GetCustomId() == AddButton.CustomId)
+ {
+ string? SelectedText = null;
+ DiscordInvite SelectedInvite = null;
+
+ while (true)
+ {
+ var SelectTextButton = new DiscordButtonComponent((SelectedText.IsNullOrWhiteSpace() ? ButtonStyle.Primary : ButtonStyle.Secondary), Guid.NewGuid().ToString(), this.GetString(CommandKey.SetNoteButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🗯")));
+ var SelectInviteButton = new DiscordButtonComponent((SelectedText.IsNullOrWhiteSpace() ? ButtonStyle.Primary : ButtonStyle.Secondary), Guid.NewGuid().ToString(), this.GetString(CommandKey.SelectInviteButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👤")));
+ var Finish = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), this.GetString(CommandKey.CreateButton), (SelectedText.IsNullOrWhiteSpace() || SelectedInvite is null), new DiscordComponentEmoji(DiscordEmoji.FromUnicode("✅")));
+
+ var pad = TranslationUtil.CalculatePadding(ctx.DbUser, CommandKey.Note, CommandKey.Invite);
+
+ embed = new DiscordEmbedBuilder
+ {
+ Description = $"`{this.GetString(CommandKey.Note).PadRight(pad)}`: `{(SelectedText.IsNullOrWhiteSpace() ? this.GetString(this.t.Common.NotSelected) : SelectedText).SanitizeForCode()}`\n" +
+ $"`{this.GetString(CommandKey.Invite).PadRight(pad)}`: `{(SelectedInvite is null ? this.GetString(this.t.Common.NotSelected) : $"{SelectedInvite.Code}")}`"
+ }.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed)
+ .AddComponents(new List { SelectTextButton, SelectInviteButton, Finish })
+ .AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var Menu = await ctx.WaitForButtonAsync();
+
+ if (Menu.TimedOut)
+ {
+ this.ModifyToTimedOut();
+ return;
+ }
+
+ if (Menu.GetCustomId() == SelectTextButton.CustomId)
+ {
+ var ModalResult = await this.PromptModalWithRetry(Menu.Result.Interaction, new DiscordInteractionModalBuilder()
+ .AddTextComponent(new DiscordTextComponent(TextComponentStyle.Paragraph, "Note", this.GetString(CommandKey.Note), "", 1, 128, true)), false);
+
+ if (ModalResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ModalResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (ModalResult.Errored)
+ {
+ throw ModalResult.Exception;
+ }
+
+ SelectedText = ModalResult.Result.Interaction.GetModalValueByCustomId("Note").Truncate(128);
+ }
+ else if (Menu.GetCustomId() == SelectInviteButton.CustomId)
+ {
+ _ = Menu.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ var invites = await ctx.Guild.GetInvitesAsync();
+
+ var SelectionResult = await this.PromptCustomSelection(invites.Where(x => !ctx.DbGuild.InviteNotes.Notes.Any(a => a.Invite == x.Code))
+ .Select(x => new DiscordStringSelectComponentOption(x.Code, x.Code, this.GetString(CommandKey.InviteDescription, new TVar("Uses", x.Uses), new TVar("Creator", x.Inviter.GetUsernameWithIdentifier())))).ToList());
+
+ if (SelectionResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (SelectionResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (SelectionResult.Errored)
+ {
+ throw SelectionResult.Exception;
+ }
+
+ SelectedInvite = invites.First(x => x.Code == SelectionResult.Result);
+ }
+ else if (Menu.GetCustomId() == Finish.CustomId)
+ {
+ _ = Menu.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ ctx.DbGuild.InviteNotes.Notes = ctx.DbGuild.InviteNotes.Notes.Add(new()
+ {
+ Invite = SelectedInvite.Code,
+ Moderator = ctx.User.Id,
+ Note = SelectedText
+ });
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ }
+ }
+ else if (e.GetCustomId() == RemoveButton.CustomId)
+ {
+ var SelectionResult = await this.PromptCustomSelection(ctx.DbGuild.InviteNotes.Notes.Select(x => new DiscordStringSelectComponentOption(x.Invite, x.Invite, $"{x.Note.TruncateWithIndication(50)}")).ToList());
+
+ if (SelectionResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (SelectionResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (SelectionResult.Errored)
+ {
+ throw SelectionResult.Exception;
+ }
+
+ ctx.DbGuild.InviteNotes.Notes = ctx.DbGuild.InviteNotes.Notes
+ .Remove(x => x.Invite, ctx.DbGuild.InviteNotes.Notes.First(x => x.Invite == SelectionResult.Result));
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ });
+ }
+}
diff --git a/ProjectMakoto/Commands/Configuration/InviteTrackerCommand.cs b/ProjectMakoto/Commands/Configuration/InviteTrackerCommand.cs
new file mode 100644
index 00000000..acd4b117
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/InviteTrackerCommand.cs
@@ -0,0 +1,71 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class InviteTrackerCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.InviteTracker;
+
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ return $"{"📲".UnicodeToEmoji()} `{this.GetString(this.t.Commands.Config.InviteTracker.InviteTrackerEnabled)}`: {ctx.DbGuild.InviteTracker.Enabled.ToEmote(ctx.Bot)}";
+ }
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ var embed = new DiscordEmbedBuilder
+ {
+ Description = GetCurrentConfiguration(ctx)
+ }.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+
+ var Toggle = new DiscordButtonComponent((ctx.DbGuild.InviteTracker.Enabled ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleInviteTrackerButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("📲")));
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed)
+ .AddComponents(new List
+ {
+ Toggle
+ })
+ .AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var e = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (e.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ _ = e.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (e.GetCustomId() == Toggle.CustomId)
+ {
+ ctx.DbGuild.InviteTracker.Enabled = !ctx.DbGuild.InviteTracker.Enabled;
+
+ if (ctx.DbGuild.InviteTracker.Enabled)
+ _ = InviteTrackerEvents.UpdateCachedInvites(ctx.Bot, ctx.Guild);
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/JoinCommand.cs b/ProjectMakoto/Commands/Configuration/JoinCommand.cs
new file mode 100644
index 00000000..dfebaa34
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/JoinCommand.cs
@@ -0,0 +1,280 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class JoinCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.Join;
+
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ var CommandKey = ctx.Bot.LoadedTranslations.Commands.Config.Join;
+
+ var pad = TranslationUtil.CalculatePadding(ctx.DbUser,
+ CommandKey.Autoban,
+ CommandKey.JoinLogChannel,
+ CommandKey.Role,
+ CommandKey.ReApplyRoles,
+ CommandKey.ReApplyNickname,
+ CommandKey.AutoKickSpammer,
+ CommandKey.AutoKickNewAccounts,
+ CommandKey.AutoKickNoRoles);
+
+ return $"{"🌐".UnicodeToEmoji()} `{CommandKey.Autoban.Get(ctx.DbUser).PadRight(pad)}`: {ctx.DbGuild.Join.AutoBanGlobalBans.ToEmote(ctx.Bot)}\n" +
+ $"{"👋".UnicodeToEmoji()} `{CommandKey.JoinLogChannel.Get(ctx.DbUser).PadRight(pad)}`: {(ctx.DbGuild.Join.JoinlogChannelId != 0 ? $"<#{ctx.DbGuild.Join.JoinlogChannelId}>" : false.ToEmote(ctx.Bot))}\n" +
+ $"{"👤".UnicodeToEmoji()} `{CommandKey.Role.Get(ctx.DbUser).PadRight(pad)}`: {(ctx.DbGuild.Join.AutoAssignRoleId != 0 ? $"<@&{ctx.DbGuild.Join.AutoAssignRoleId}>" : false.ToEmote(ctx.Bot))}\n" +
+ $"{"👥".UnicodeToEmoji()} `{CommandKey.ReApplyRoles.Get(ctx.DbUser).PadRight(pad)}`: {ctx.DbGuild.Join.ReApplyRoles.ToEmote(ctx.Bot)}\n" +
+ $"{"💬".UnicodeToEmoji()} `{CommandKey.ReApplyNickname.Get(ctx.DbUser).PadRight(pad)}`: {ctx.DbGuild.Join.ReApplyNickname.ToEmote(ctx.Bot)}\n\n" +
+ $"{"⚠️".UnicodeToEmoji()} `{CommandKey.AutoKickSpammer.Get(ctx.DbUser).PadRight(pad)}`: {ctx.DbGuild.Join.AutoKickSpammer.ToEmote(ctx.Bot)}\n" +
+ $"{"🕒".UnicodeToEmoji()} `{CommandKey.AutoKickNewAccounts.Get(ctx.DbUser).PadRight(pad)}`: {(ctx.DbGuild.Join.AutoKickAccountAge == TimeSpan.Zero ? false.ToEmote(ctx.Bot) : $"`{ctx.DbGuild.Join.AutoKickAccountAge.GetHumanReadable(TimeFormat.Days, TranslationUtil.GetTranslatedHumanReadableConfig(ctx.DbUser, ctx.Bot))}`")}\n" +
+ $"{"📝".UnicodeToEmoji()} `{CommandKey.AutoKickNoRoles.Get(ctx.DbUser).PadRight(pad)}`: {(ctx.DbGuild.Join.AutoKickNoRoleTime == TimeSpan.Zero ? false.ToEmote(ctx.Bot) : $"`{ctx.DbGuild.Join.AutoKickNoRoleTime.GetHumanReadable(TimeFormat.Minutes, TranslationUtil.GetTranslatedHumanReadableConfig(ctx.DbUser, ctx.Bot))}`")}\n\n" +
+ $"{CommandKey.SecurityNotice.Get(ctx.DbUser).Build(true, new TVar("Permissions", string.Join(", ", Resources.ProtectedPermissions.Select(x => $"{x.ToTranslatedPermissionString(ctx.DbUser, ctx.Bot)}"))))}\n\n" +
+ $"{CommandKey.TimeNotice.Get(ctx.DbUser).Build()}";
+ }
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ var embed = new DiscordEmbedBuilder()
+ {
+ Description = GetCurrentConfiguration(ctx)
+ }.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+
+ var builder = new DiscordMessageBuilder().WithEmbed(embed);
+
+ var ToggleGlobalban = new DiscordButtonComponent((ctx.DbGuild.Join.AutoBanGlobalBans ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleGlobalBansButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🌐")));
+ var ChangeJoinlogChannel = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeJoinlogChannelButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👋")));
+ var ChangeRoleOnJoin = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeRoleButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👤")));
+ var ToggleReApplyRoles = new DiscordButtonComponent((ctx.DbGuild.Join.ReApplyRoles ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleReApplyRole), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👥")));
+ var ToggleReApplyName = new DiscordButtonComponent((ctx.DbGuild.Join.ReApplyNickname ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleReApplyNickname), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("💬")));
+
+ var ToggleAutoKickSpammer = new DiscordButtonComponent((ctx.DbGuild.Join.AutoKickSpammer ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleAutoKickSpammer), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("⚠️")));
+ var ChangeAutoKickNewAccounts = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeAutoKickNewAccounts), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🕒")));
+ var ChangeAutoKickNoRoles = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeAutoKickNoRoles), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("📝")));
+
+ _ = await this.RespondOrEdit(builder
+ .AddComponents(new List
+ {
+ ToggleGlobalban,
+ ToggleReApplyRoles,
+ ToggleReApplyName,
+ })
+ .AddComponents(new List
+ {
+ ChangeJoinlogChannel,
+ ChangeRoleOnJoin,
+ })
+ .AddComponents(new List
+ {
+ ToggleAutoKickSpammer,
+ ChangeAutoKickNewAccounts,
+ ChangeAutoKickNoRoles,
+ })
+ .AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var e = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (e.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ _ = e.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (e.GetCustomId() == ToggleGlobalban.CustomId)
+ {
+ ctx.DbGuild.Join.AutoBanGlobalBans = !ctx.DbGuild.Join.AutoBanGlobalBans;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == ToggleReApplyRoles.CustomId)
+ {
+ ctx.DbGuild.Join.ReApplyRoles = !ctx.DbGuild.Join.ReApplyRoles;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == ToggleReApplyName.CustomId)
+ {
+ ctx.DbGuild.Join.ReApplyNickname = !ctx.DbGuild.Join.ReApplyNickname;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == ChangeJoinlogChannel.CustomId)
+ {
+ var ChannelResult = await this.PromptChannelSelection(ChannelType.Text, new ChannelPromptConfiguration
+ {
+ CreateChannelOption = new()
+ {
+ Name = this.GetString(CommandKey.JoinLogChannelName),
+ ChannelType = ChannelType.Text
+ },
+ DisableOption = this.GetString(CommandKey.DisableJoinlog)
+ });
+
+ if (ChannelResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ChannelResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (ChannelResult.Failed)
+ {
+ if (ChannelResult.Exception.GetType() == typeof(NullReferenceException))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(this.t.Commands.Common.Errors.NoChannels)));
+ await Task.Delay(3000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ throw ChannelResult.Exception;
+ }
+
+ ctx.DbGuild.Join.JoinlogChannelId = ChannelResult.Result is null ? 0 : ChannelResult.Result.Id;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == ChangeRoleOnJoin.CustomId)
+ {
+ var RoleResult = await this.PromptRoleSelection(new RolePromptConfiguration { CreateRoleOption = this.GetString(CommandKey.AutoAssignRoleName), DisableOption = this.GetString(CommandKey.DisableRoleOnJoin) });
+
+ if (RoleResult.TimedOut)
+ {
+ this.ModifyToTimedOut();
+ return;
+ }
+ else if (RoleResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (RoleResult.Failed)
+ {
+ if (RoleResult.Exception.GetType() == typeof(NullReferenceException))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(this.t.Commands.Common.Errors.NoRoles)));
+ await Task.Delay(3000);
+ return;
+ }
+
+ throw RoleResult.Exception;
+ }
+
+ if (RoleResult.Result?.Id == ctx.DbGuild.BumpReminder.RoleId)
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(CommandKey.CantUseRole, true)));
+ await Task.Delay(3000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ ctx.DbGuild.Join.AutoAssignRoleId = RoleResult.Result is null ? 0 : RoleResult.Result.Id;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == ToggleAutoKickSpammer.CustomId)
+ {
+ ctx.DbGuild.Join.AutoKickSpammer = !ctx.DbGuild.Join.AutoKickSpammer;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == ChangeAutoKickNewAccounts.CustomId)
+ {
+ var TimeResult = await this.PromptForTimeSpan(TimeSpan.FromDays(30), TimeSpan.Zero, ctx.DbGuild.Join.AutoKickAccountAge);
+
+ if (TimeResult.TimedOut)
+ {
+ this.ModifyToTimedOut();
+ return;
+ }
+ else if (TimeResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (TimeResult.Failed)
+ {
+ if (TimeResult.Exception.GetType() == typeof(InvalidOperationException))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(CommandKey.AutoKickNewAccountsDurationLimit)));
+ await Task.Delay(3000);
+ return;
+ }
+
+ throw TimeResult.Exception;
+ }
+
+ ctx.DbGuild.Join.AutoKickAccountAge = TimeResult.Result;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == ChangeAutoKickNoRoles.CustomId)
+ {
+ var TimeResult = await this.PromptForTimeSpan(TimeSpan.FromMinutes(30), TimeSpan.Zero, ctx.DbGuild.Join.AutoKickNoRoleTime);
+
+ if (TimeResult.TimedOut)
+ {
+ this.ModifyToTimedOut();
+ return;
+ }
+ else if (TimeResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (TimeResult.Failed)
+ {
+ if (TimeResult.Exception.GetType() == typeof(NullReferenceException))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(CommandKey.AutoKickNoRolesDurationLimit)));
+ await Task.Delay(3000);
+ return;
+ }
+
+ throw TimeResult.Exception;
+ }
+
+ if (TimeResult.Result < TimeSpan.FromMinutes(1) && TimeResult.Result != TimeSpan.Zero)
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsWarning(ctx).WithDescription($"{this.GetString(CommandKey.LowTimeWarning, true, new TVar("Time", TimeResult.Result.GetHumanReadable(TimeFormat.Minutes, TranslationUtil.GetTranslatedHumanReadableConfig(ctx.DbUser, ctx.Bot))))}\n\n" +
+ $"{this.GetString(this.t.Commands.Moderation.CustomEmbed.ContinueTimer, true, new TVar("Timestamp", DateTime.UtcNow.AddSeconds(6).ToTimestamp()))}"));
+ await Task.Delay(5000);
+ }
+
+ ctx.DbGuild.Join.AutoKickNoRoleTime = TimeResult.Result;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/LevelRewardsCommand.cs b/ProjectMakoto/Commands/Configuration/LevelRewardsCommand.cs
new file mode 100644
index 00000000..c7604f2c
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/LevelRewardsCommand.cs
@@ -0,0 +1,460 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class LevelRewardsCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.LevelRewards;
+
+#pragma warning disable CS8321 // Local function is declared but never used
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ var CommandKey = ctx.Bot.LoadedTranslations.Commands.Config.LevelRewards;
+
+ var str = "";
+ if (ctx.DbGuild.LevelRewards.Length != 0)
+ {
+ foreach (var b in ctx.DbGuild.LevelRewards.OrderBy(x => x.Level))
+ {
+ if (!ctx.Guild.Roles.ContainsKey(b.RoleId))
+ {
+ ctx.DbGuild.LevelRewards = ctx.DbGuild.LevelRewards.Remove(x => x.RoleId.ToString(), b);
+ continue;
+ }
+
+ str += $"**{ctx.BaseCommand.GetString(CommandKey.Level)}**: `{b.Level}`\n" +
+ $"**{ctx.BaseCommand.GetString(CommandKey.Role)}**: <@&{b.RoleId}> (`{b.RoleId}`)\n" +
+ $"**{ctx.BaseCommand.GetString(CommandKey.Message)}**: `{b.Message}`\n";
+
+ str += "\n\n";
+ }
+ }
+ else
+ {
+ str = ctx.BaseCommand.GetString(CommandKey.NoRewardsSetup, true);
+ }
+
+ return str;
+ }
+#pragma warning restore CS8321 // Local function is declared but never used
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ var CurrentPage = 0;
+
+ var embed = new DiscordEmbedBuilder()
+ {
+ Description = this.GetString(CommandKey.Loading, true)
+ }.AsLoading(ctx, this.GetString(CommandKey.Title));
+
+ _ = await this.RespondOrEdit(embed);
+
+ embed = embed.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+
+ var selected = "";
+
+ async Task RefreshMessage()
+ {
+ List DefinedRewards = new();
+
+ embed.Description = "";
+
+ foreach (var reward in ctx.DbGuild.LevelRewards.ToList().OrderBy(x => x.Level))
+ {
+ if (!ctx.Guild.Roles.ContainsKey(reward.RoleId))
+ {
+ ctx.DbGuild.LevelRewards = ctx.DbGuild.LevelRewards.Remove(x => x.RoleId.ToString(), reward);
+ continue;
+ }
+
+ var role = ctx.Guild.GetRole(reward.RoleId);
+
+ DefinedRewards.Add(new DiscordStringSelectComponentOption($"{this.GetString(CommandKey.Level)} {reward.Level}: @{role.Name}", role.Id.ToString(), $"{reward.Message.TruncateWithIndication(100)}", (selected == role.Id.ToString()), new DiscordComponentEmoji(role.Color.GetClosestColorEmoji(ctx.Client))));
+
+ if (selected == role.Id.ToString())
+ {
+ embed.Description = $"**{this.GetString(CommandKey.Level)}**: `{reward.Level}`\n" +
+ $"**{this.GetString(CommandKey.Role)}**: <@&{reward.RoleId}> (`{reward.RoleId}`)\n" +
+ $"**{this.GetString(CommandKey.Message)}**: `{reward.Message}`\n";
+ }
+ }
+
+ if (DefinedRewards.Count > 0)
+ {
+ if (embed.Description == "")
+ embed.Description = this.GetString(CommandKey.SelectPrompt, true);
+ }
+ else
+ {
+ embed.Description = this.GetString(CommandKey.NoRewardsSetup, true);
+ }
+
+ var PreviousPage = new DiscordButtonComponent(ButtonStyle.Primary, "PreviousPage", this.GetString(this.t.Common.PreviousPage), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("◀")));
+ var NextPage = new DiscordButtonComponent(ButtonStyle.Primary, "NextPage", this.GetString(this.t.Common.NextPage), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("▶")));
+
+ var Add = new DiscordButtonComponent(ButtonStyle.Success, "Add", this.GetString(CommandKey.AddNewButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("➕")));
+ var Modify = new DiscordButtonComponent(ButtonStyle.Primary, "Modify", this.GetString(CommandKey.ModifyButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🔄")));
+ var Delete = new DiscordButtonComponent(ButtonStyle.Danger, "Delete", this.GetString(CommandKey.RemoveButton), false, new DiscordComponentEmoji(DiscordEmoji.FromGuildEmote(ctx.Client, 1005430134070841395)));
+
+ var Dropdown = new DiscordStringSelectComponent(this.GetString(CommandKey.SelectDropdown), DefinedRewards.Skip(CurrentPage * 20).Take(20).ToList(), "RewardSelection");
+ embed = embed.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+ var builder = new DiscordMessageBuilder().WithEmbed(embed);
+
+ if (DefinedRewards.Count > 0)
+ _ = builder.AddComponents(Dropdown);
+
+ List Row1 = new();
+ List Row2 = new();
+
+ if (DefinedRewards.Skip(CurrentPage * 20).Count() > 20)
+ Row1.Add(NextPage);
+
+ if (CurrentPage != 0)
+ Row1.Add(PreviousPage);
+
+ Row2.Add(Add);
+
+ if (selected != "")
+ {
+ Row2.Add(Modify);
+ Row2.Add(Delete);
+ }
+
+ if (Row1.Count > 0)
+ _ = builder.AddComponents(Row1);
+
+ _ = builder.AddComponents(Row2);
+
+ _ = builder.AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot));
+
+ _ = await this.RespondOrEdit(builder);
+ }
+
+ CancellationTokenSource cancellationTokenSource = new();
+
+ async Task SelectInteraction(DiscordClient s, ComponentInteractionCreateEventArgs e)
+ {
+ _ = Task.Run(async () =>
+ {
+ if (e.Message?.Id == ctx.ResponseMessage.Id && e.User.Id == ctx.User.Id)
+ {
+ cancellationTokenSource.Cancel();
+ cancellationTokenSource = new();
+
+ _ = Task.Delay(120000, cancellationTokenSource.Token).ContinueWith(x =>
+ {
+ if (x.IsCompletedSuccessfully)
+ {
+ ctx.Client.ComponentInteractionCreated -= SelectInteraction;
+ this.ModifyToTimedOut(true);
+ }
+ });
+
+ if (e.GetCustomId() == "RewardSelection")
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ selected = e.Values.First();
+ await RefreshMessage();
+ }
+ else if (e.GetCustomId() == "Add")
+ {
+ ctx.Client.ComponentInteractionCreated -= SelectInteraction;
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ DiscordRole selectedRole = null;
+ var selectedLevel = -1;
+ var selectedCustomText = this.GetGuildString(CommandKey.DefaultCustomText);
+
+ while (true)
+ {
+ var SelectRole = new DiscordButtonComponent((selectedRole is null ? ButtonStyle.Primary : ButtonStyle.Secondary), Guid.NewGuid().ToString(), this.GetString(CommandKey.SelectRoleButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👤")));
+ var SelectLevel = new DiscordButtonComponent((selectedLevel is -1 ? ButtonStyle.Primary : ButtonStyle.Secondary), Guid.NewGuid().ToString(), this.GetString(CommandKey.SelectLevelButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("✨")));
+ var SelectCustomText = new DiscordButtonComponent((selectedCustomText.IsNullOrWhiteSpace() ? ButtonStyle.Primary : ButtonStyle.Secondary), Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeMessageButton), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🗯")));
+ var Finish = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), this.GetString(this.t.Common.Submit), (selectedRole is null || selectedLevel is -1 || selectedCustomText.IsNullOrWhiteSpace()), new DiscordComponentEmoji(DiscordEmoji.FromUnicode("✅")));
+
+ var pad = TranslationUtil.CalculatePadding(ctx.DbUser, CommandKey.Role, CommandKey.Level, CommandKey.Message);
+
+ var action_embed = new DiscordEmbedBuilder
+ {
+ Description = $"`{this.GetString(CommandKey.Role).PadRight(pad)}`: {(selectedRole is null ? this.GetString(this.t.Common.NotSelected, true) : selectedRole.Mention)}\n" +
+ $"`{this.GetString(CommandKey.Level).PadRight(pad)}`: {(selectedLevel is -1 ? this.GetString(this.t.Common.NotSelected, true) : selectedLevel.ToEmotes())}\n" +
+ $"`{this.GetString(CommandKey.Message).PadRight(pad)}`: `{selectedCustomText}`"
+ }.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed)
+ .AddComponents(new List { SelectRole, SelectLevel, SelectCustomText, Finish })
+ .AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var Menu = await ctx.WaitForButtonAsync();
+
+ if (Menu.TimedOut)
+ {
+ this.ModifyToTimedOut();
+ return;
+ }
+
+ if (Menu.GetCustomId() == SelectRole.CustomId)
+ {
+ _ = Menu.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ var RoleResult = await this.PromptRoleSelection();
+
+ if (RoleResult.TimedOut)
+ {
+ this.ModifyToTimedOut();
+ return;
+ }
+ else if (RoleResult.Cancelled)
+ {
+ continue;
+ }
+ else if (RoleResult.Failed)
+ {
+ if (RoleResult.Exception.GetType() == typeof(NullReferenceException))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(this.t.Commands.Common.Errors.NoRoles, true)));
+ await Task.Delay(3000);
+ return;
+ }
+
+ throw RoleResult.Exception;
+ }
+
+ if (RoleResult.Result.Id == ctx.DbGuild.BumpReminder.RoleId)
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(CommandKey.CantUseRole, true)));
+ await Task.Delay(3000);
+ continue;
+ }
+
+ selectedRole = RoleResult.Result;
+ continue;
+ }
+ else if (Menu.GetCustomId() == SelectLevel.CustomId)
+ {
+ var modal = new DiscordInteractionModalBuilder(this.GetString(CommandKey.Title), Guid.NewGuid().ToString())
+ .AddTextComponent(new DiscordTextComponent(TextComponentStyle.Small, "level", this.GetString(CommandKey.Level), "2", 1, 3, true, (selectedLevel is -1 ? 2 : selectedLevel).ToString()));
+
+
+ var ModalResult = await this.PromptModalWithRetry(Menu.Result.Interaction, modal, false);
+
+ if (ModalResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ModalResult.Cancelled)
+ {
+ continue;
+ }
+ else if (ModalResult.Errored)
+ {
+ throw ModalResult.Exception;
+ }
+
+ InteractionCreateEventArgs Response = ModalResult.Result;
+ var rawInt = Response.Interaction.GetModalValueByCustomId("level");
+
+ uint level;
+
+ try
+ {
+ level = Convert.ToUInt32(rawInt);
+
+ if (level < 2)
+ throw new Exception("");
+ }
+ catch (Exception)
+ {
+ continue;
+ }
+
+ selectedLevel = (int)level;
+ continue;
+ }
+ else if (Menu.GetCustomId() == SelectCustomText.CustomId)
+ {
+ var modal = new DiscordInteractionModalBuilder(this.GetString(CommandKey.Title), Guid.NewGuid().ToString())
+ .AddTextComponent(new DiscordTextComponent(TextComponentStyle.Small, "message", this.GetString(CommandKey.Message), this.GetGuildString(CommandKey.DefaultCustomText), 1, 256, true, selectedCustomText));
+
+
+ var ModalResult = await this.PromptModalWithRetry(Menu.Result.Interaction, modal, false);
+
+ if (ModalResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ModalResult.Cancelled)
+ {
+ continue;
+ }
+ else if (ModalResult.Errored)
+ {
+ throw ModalResult.Exception;
+ }
+
+ InteractionCreateEventArgs Response = ModalResult.Result;
+
+ var newMessage = Response.Interaction.GetModalValueByCustomId("message");
+
+ if (newMessage.Length > 256)
+ {
+ action_embed.Description = this.GetString(CommandKey.MessageTooLong, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(3000);
+ continue;
+ }
+
+ selectedCustomText = newMessage;
+ continue;
+ }
+ else if (Menu.GetCustomId() == Finish.CustomId)
+ {
+ if (selectedRole.Id == ctx.DbGuild.BumpReminder.RoleId)
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(CommandKey.CantUseRole, true)));
+ await Task.Delay(3000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ ctx.DbGuild.LevelRewards = ctx.DbGuild.LevelRewards.Add(new()
+ {
+ Level = selectedLevel,
+ RoleId = selectedRole.Id,
+ Message = selectedCustomText
+ });
+
+ action_embed.Description = this.GetString(CommandKey.AddedNewReward, true, new TVar("Role", $"<@&{selectedRole.Id}>"), new TVar("Level", selectedLevel));
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed.AsSuccess(ctx, this.GetString(CommandKey.Title))));
+
+ await Task.Delay(5000);
+ await RefreshMessage();
+ ctx.Client.ComponentInteractionCreated += SelectInteraction;
+ return;
+ }
+ else if (Menu.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ _ = Menu.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ await RefreshMessage();
+ ctx.Client.ComponentInteractionCreated += SelectInteraction;
+ return;
+ }
+
+ return;
+ }
+ }
+ else if (e.GetCustomId() == "Modify")
+ {
+ var modal = new DiscordInteractionModalBuilder()
+ .WithTitle(this.GetString(CommandKey.Title))
+ .WithCustomId(Guid.NewGuid().ToString())
+ .AddTextComponents(new DiscordTextComponent(TextComponentStyle.Small, "new_text", this.GetString(CommandKey.Message), null, 0, 256, false, ctx.DbGuild.LevelRewards.First(x => x.RoleId == Convert.ToUInt64(selected)).Message));
+ ;
+
+ var ModalResult = await this.PromptModalWithRetry(e.Interaction, modal, false);
+
+ if (ModalResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ModalResult.Cancelled)
+ {
+ await RefreshMessage();
+ return;
+ }
+ else if (ModalResult.Errored)
+ {
+ throw ModalResult.Exception;
+ }
+
+ InteractionCreateEventArgs Response = ModalResult.Result;
+ var result = Response.Interaction.GetModalValueByCustomId("new_text");
+
+ if (result.Length > 256)
+ {
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.WithDescription(this.GetString(CommandKey.MessageTooLong, true)).AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ ctx.DbGuild.LevelRewards.First(x => x.RoleId == Convert.ToUInt64(selected)).Message = result;
+
+ await RefreshMessage();
+ }
+ else if (e.GetCustomId() == "Delete")
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ ctx.DbGuild.LevelRewards = ctx.DbGuild.LevelRewards.Remove(x => x.RoleId.ToString(), ctx.DbGuild.LevelRewards.First(x => x.RoleId == Convert.ToUInt64(selected)));
+
+ if (ctx.DbGuild.LevelRewards.Length == 0)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ embed.Description = this.GetString(CommandKey.SelectPrompt, true);
+ selected = "";
+
+ await RefreshMessage();
+ }
+ else if (e.GetCustomId() == "PreviousPage")
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ CurrentPage--;
+ await RefreshMessage();
+ }
+ else if (e.GetCustomId() == "NextPage")
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ CurrentPage++;
+ await RefreshMessage();
+ }
+ else if (e.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ this.DeleteOrInvalidate();
+ return;
+ }
+ }
+ }).Add(ctx.Bot, ctx);
+ }
+
+ await RefreshMessage();
+
+ _ = Task.Delay(120000, cancellationTokenSource.Token).ContinueWith(x =>
+ {
+ if (x.IsCompletedSuccessfully)
+ {
+ ctx.Client.ComponentInteractionCreated -= SelectInteraction;
+ this.ModifyToTimedOut(true);
+ }
+ });
+
+ ctx.Client.ComponentInteractionCreated += SelectInteraction;
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/NameNormalizerCommand.cs b/ProjectMakoto/Commands/Configuration/NameNormalizerCommand.cs
new file mode 100644
index 00000000..65c20670
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/NameNormalizerCommand.cs
@@ -0,0 +1,125 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class NameNormalizerCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.NameNormalizer;
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ return $"💬 `{this.GetString(CommandKey.NameNormalizerEnabled)}`: {ctx.DbGuild.NameNormalizer.NameNormalizerEnabled.ToEmote(ctx.Bot)}";
+ }
+
+ var embed = new DiscordEmbedBuilder
+ {
+ Description = GetCurrentConfiguration(ctx)
+ }.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+
+ var Toggle = new DiscordButtonComponent((ctx.DbGuild.NameNormalizer.NameNormalizerEnabled ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleNameNormalizer), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("💬")));
+ var SearchAllNames = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), this.GetString(CommandKey.NormalizeNow), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🔨")));
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed)
+ .AddComponents(new List
+ {
+ Toggle,
+ SearchAllNames
+ })
+ .AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var e = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (e.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ _ = e.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (e.GetCustomId() == Toggle.CustomId)
+ {
+ ctx.DbGuild.NameNormalizer.NameNormalizerEnabled = !ctx.DbGuild.NameNormalizer.NameNormalizerEnabled;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == SearchAllNames.CustomId)
+ {
+ if (ctx.DbGuild.NameNormalizer.NameNormalizerRunning)
+ {
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsError(ctx, this.GetString(CommandKey.Title))
+ .WithDescription(this.GetString(CommandKey.NormalizerRunning, true))));
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ if (await ctx.DbUser.Cooldown.WaitForHeavy(ctx))
+ return;
+
+ ctx.DbGuild.NameNormalizer.NameNormalizerRunning = true;
+
+ try
+ {
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsLoading(ctx, this.GetString(CommandKey.Title))
+ .WithDescription(this.GetString(CommandKey.RenamingAllMembers, true))));
+
+ var members = await ctx.Guild.GetAllMembersAsync();
+ var Renamed = 0;
+
+ for (var i = 0; i < members.Count; i++)
+ {
+ var b = members.ElementAt(i);
+
+ var PingableName = RegexTemplates.AllowedNickname.Replace(b.DisplayName.Normalize(NormalizationForm.FormKC), "");
+
+ if (PingableName.IsNullOrWhiteSpace())
+ PingableName = this.GetGuildString(CommandKey.DefaultName);
+
+ if (PingableName != b.DisplayName)
+ {
+ _ = b.ModifyAsync(x => x.Nickname = PingableName);
+ Renamed++;
+ await Task.Delay(2000);
+ }
+ }
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsSuccess(ctx, this.GetString(CommandKey.Title))
+ .WithDescription(this.GetString(CommandKey.RenamedMembers, true, new TVar("Count", Renamed)))));
+ await Task.Delay(5000);
+ ctx.DbGuild.NameNormalizer.NameNormalizerRunning = false;
+ }
+ catch (Exception)
+ {
+ ctx.DbGuild.NameNormalizer.NameNormalizerRunning = false;
+ throw;
+ }
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/PhishingCommand.cs b/ProjectMakoto/Commands/Configuration/PhishingCommand.cs
new file mode 100644
index 00000000..a18ef2de
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/PhishingCommand.cs
@@ -0,0 +1,234 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class PhishingCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.Phishing;
+
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ var pad = TranslationUtil.CalculatePadding(ctx.DbUser, CommandKey.DetectPhishingLinks, CommandKey.RedirectWarning, CommandKey.AbuseIpDbReports, CommandKey.PunishmentType,
+ CommandKey.CustomPunishmentReason, CommandKey.CustomTimeoutLength);
+
+ return $"💀 `{this.GetString(CommandKey.DetectPhishingLinks).PadRight(pad)}` : {ctx.DbGuild.PhishingDetection.DetectPhishing.ToEmote(ctx.Bot)}\n" +
+ $"⚠ `{this.GetString(CommandKey.RedirectWarning).PadRight(pad)}` : {ctx.DbGuild.PhishingDetection.WarnOnRedirect.ToEmote(ctx.Bot)}\n" +
+ $"{EmojiTemplates.GetAbuseIpDb(ctx.Bot)} `{this.GetString(CommandKey.AbuseIpDbReports).PadRight(pad)}` : {ctx.DbGuild.PhishingDetection.AbuseIpDbReports.ToEmote(ctx.Bot)}\n" +
+ $"🔨 `{this.GetString(CommandKey.PunishmentType).PadRight(pad)}` : `{GetTypeString(ctx.DbGuild.PhishingDetection.PunishmentType)}`\n" +
+ $"💬 `{this.GetString(CommandKey.CustomPunishmentReason).PadRight(pad)}` : `{ctx.DbGuild.PhishingDetection.CustomPunishmentReason}`\n" +
+ $"🕒 `{this.GetString(CommandKey.CustomTimeoutLength).PadRight(pad)}` : `{ctx.DbGuild.PhishingDetection.CustomPunishmentLength.GetHumanReadable(TimeFormat.Days, TranslationUtil.GetTranslatedHumanReadableConfig(ctx.DbUser, ctx.Bot))}`";
+ }
+
+ string GetTypeString(PhishingPunishmentType type)
+ {
+ return type switch
+ {
+ PhishingPunishmentType.Delete => this.GetString(CommandKey.PunishmentTypeDelete),
+ PhishingPunishmentType.Timeout => this.GetString(CommandKey.PunishmentTypeTimeout),
+ PhishingPunishmentType.Kick => this.GetString(CommandKey.PunishmentTypeKick),
+ PhishingPunishmentType.Ban => this.GetString(CommandKey.PunishmentTypeBan),
+ PhishingPunishmentType.SoftBan => this.GetString(CommandKey.PunishmentTypeSoftban),
+ _ => throw new NotImplementedException(),
+ };
+ }
+
+ string GetTypeDescriptionString(PhishingPunishmentType type)
+ {
+ return type switch
+ {
+ PhishingPunishmentType.Delete => this.GetString(CommandKey.PunishmentTypeDeleteDescription),
+ PhishingPunishmentType.Timeout => this.GetString(CommandKey.PunishmentTypeTimeoutDescription),
+ PhishingPunishmentType.Kick => this.GetString(CommandKey.PunishmentTypeKickDescription),
+ PhishingPunishmentType.Ban => this.GetString(CommandKey.PunishmentTypeBanDescription),
+ PhishingPunishmentType.SoftBan => this.GetString(CommandKey.PunishmentTypeSoftbanDescription),
+ _ => throw new NotImplementedException(),
+ };
+ }
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ var embed = new DiscordEmbedBuilder()
+ {
+ Description = GetCurrentConfiguration(ctx)
+ }.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+
+ var ToggleDetectionButton = new DiscordButtonComponent((ctx.DbGuild.PhishingDetection.DetectPhishing ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleDetection), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("💀")));
+ var ToggleWarningButton = new DiscordButtonComponent((ctx.DbGuild.PhishingDetection.WarnOnRedirect ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleWarning), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("⚠")));
+ var ToggleAbuseIpDbButton = new DiscordButtonComponent((ctx.DbGuild.PhishingDetection.AbuseIpDbReports ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.AbuseIpDbReports), false, new DiscordComponentEmoji(EmojiTemplates.GetAbuseIpDb(ctx.Bot)));
+ var ChangePunishmentButton = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangePunishmentType), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🔨")));
+ var ChangeReasonButton = new DiscordButtonComponent(ButtonStyle.Secondary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangePunishmentReason), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("💬")));
+ var ChangeTimeoutLengthButton = new DiscordButtonComponent(ButtonStyle.Secondary, Guid.NewGuid().ToString(), this.GetString(CommandKey.ChangeTimeoutLength), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🕒")));
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed)
+ .AddComponents(new List
+ {
+ { ToggleDetectionButton },
+ { ToggleWarningButton },
+ { ToggleAbuseIpDbButton },
+ })
+ .AddComponents(new List
+ {
+ { ChangePunishmentButton },
+ { ChangeReasonButton },
+ { ChangeTimeoutLengthButton }
+ }).AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var Button = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (Button.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ if (Button.GetCustomId() == ToggleDetectionButton.CustomId)
+ {
+ _ = Button.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ ctx.DbGuild.PhishingDetection.DetectPhishing = !ctx.DbGuild.PhishingDetection.DetectPhishing;
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == ToggleWarningButton.CustomId)
+ {
+ _ = Button.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ ctx.DbGuild.PhishingDetection.WarnOnRedirect = !ctx.DbGuild.PhishingDetection.WarnOnRedirect;
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == ToggleAbuseIpDbButton.CustomId)
+ {
+ _ = Button.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ ctx.DbGuild.PhishingDetection.AbuseIpDbReports = !ctx.DbGuild.PhishingDetection.AbuseIpDbReports;
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == ChangePunishmentButton.CustomId)
+ {
+ _ = Button.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ var e = await this.PromptCustomSelection(Enum.GetNames(typeof(PhishingPunishmentType)).Select(x =>
+ {
+ var type = Enum.Parse(x);
+ return new DiscordStringSelectComponentOption(GetTypeString(type), x, GetTypeDescriptionString(type));
+ }));
+
+ if (e.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ switch (e.Result)
+ {
+ case "Ban":
+ ctx.DbGuild.PhishingDetection.PunishmentType = PhishingPunishmentType.Ban;
+ break;
+ case "SoftBan":
+ ctx.DbGuild.PhishingDetection.PunishmentType = PhishingPunishmentType.SoftBan;
+ break;
+ case "Kick":
+ ctx.DbGuild.PhishingDetection.PunishmentType = PhishingPunishmentType.Kick;
+ break;
+ case "Timeout":
+ ctx.DbGuild.PhishingDetection.PunishmentType = PhishingPunishmentType.Timeout;
+ break;
+ case "Delete":
+ ctx.DbGuild.PhishingDetection.PunishmentType = PhishingPunishmentType.Delete;
+ break;
+ }
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == ChangeReasonButton.CustomId)
+ {
+ var modal = new DiscordInteractionModalBuilder(this.GetString(CommandKey.Title), Guid.NewGuid().ToString())
+ .AddTextComponent(new DiscordTextComponent(TextComponentStyle.Small, "new_reason", this.GetString(CommandKey.DefineNewReason), "", null, null, true, ctx.DbGuild.PhishingDetection.CustomPunishmentReason));
+
+ var ModalResult = await this.PromptModalWithRetry(Button.Result.Interaction, modal, false);
+
+ if (ModalResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ModalResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (ModalResult.Errored)
+ {
+ throw ModalResult.Exception;
+ }
+
+ ctx.DbGuild.PhishingDetection.CustomPunishmentReason = ModalResult.Result.Interaction.GetModalValueByCustomId("new_reason");
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == ChangeTimeoutLengthButton.CustomId)
+ {
+ if (ctx.DbGuild.PhishingDetection.PunishmentType != PhishingPunishmentType.Timeout)
+ {
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.WithDescription(this.GetString(CommandKey.NotUsingType, true, new TVar("Type", this.GetString(CommandKey.PunishmentTypeTimeout))))));
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ _ = Button.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ var ModalResult = await this.PromptForTimeSpan(TimeSpan.FromDays(28), TimeSpan.FromSeconds(10), ctx.DbGuild.PhishingDetection.CustomPunishmentLength, false);
+
+ if (ModalResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ModalResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (ModalResult.Errored)
+ {
+ if (ModalResult.Exception.GetType() == typeof(InvalidOperationException))
+ {
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.WithDescription(this.GetString(CommandKey.InvalidDuration, true)).AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ throw ModalResult.Exception;
+ }
+
+ ctx.DbGuild.PhishingDetection.CustomPunishmentLength = ModalResult.Result;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/PrefixCommand.cs b/ProjectMakoto/Commands/Configuration/PrefixCommand.cs
new file mode 100644
index 00000000..d41c17f8
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/PrefixCommand.cs
@@ -0,0 +1,103 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class PrefixCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ var pad = TranslationUtil.CalculatePadding(ctx.DbUser, this.t.Commands.Config.PrefixConfigCommand.CurrentPrefix, this.t.Commands.Config.PrefixConfigCommand.PrefixDisabled);
+
+ return $"⌨ `{this.GetString(this.t.Commands.Config.PrefixConfigCommand.PrefixDisabled).PadRight(pad)}` : {ctx.DbGuild.PrefixSettings.PrefixDisabled.ToEmote(ctx.Bot)}\n" +
+ $"🗝 `{this.GetString(this.t.Commands.Config.PrefixConfigCommand.CurrentPrefix).PadRight(pad)}` : `{ctx.DbGuild.PrefixSettings.Prefix}`";
+ }
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ var embed = new DiscordEmbedBuilder()
+ {
+ Description = GetCurrentConfiguration(ctx)
+ }.AsAwaitingInput(ctx, this.GetString(this.t.Commands.Config.PrefixConfigCommand.Title));
+
+ var TogglePrefixCommands = new DiscordButtonComponent((ctx.DbGuild.PrefixSettings.PrefixDisabled ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(this.t.Commands.Config.PrefixConfigCommand.TogglePrefixCommands), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("⌨")));
+ var ChangePrefix = new DiscordButtonComponent(ButtonStyle.Secondary, Guid.NewGuid().ToString(), this.GetString(this.t.Commands.Config.PrefixConfigCommand.ChangePrefix), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("🗝")));
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed)
+ .AddComponents(new List
+ {
+ { TogglePrefixCommands },
+ { ChangePrefix },
+ }).AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var Button = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (Button.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ if (Button.GetCustomId() == TogglePrefixCommands.CustomId)
+ {
+ _ = Button.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ ctx.DbGuild.PrefixSettings.PrefixDisabled = !ctx.DbGuild.PrefixSettings.PrefixDisabled;
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == ChangePrefix.CustomId)
+ {
+ var modal = new DiscordInteractionModalBuilder(this.GetString(this.t.Commands.Config.PrefixConfigCommand.NewPrefixModalTitle), Guid.NewGuid().ToString());
+
+ _ = modal.AddTextComponent(new DiscordTextComponent(TextComponentStyle.Small, "newPrefix", this.GetString(this.t.Commands.Config.PrefixConfigCommand.NewPrefix), ctx.Bot.Prefix, 1, 4, true, ctx.DbGuild.PrefixSettings.Prefix));
+
+ var ModalResult = await this.PromptModalWithRetry(Button.Result.Interaction, modal, false);
+
+ if (ModalResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ModalResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (ModalResult.Errored)
+ {
+ throw ModalResult.Exception;
+ }
+
+ var newPrefix = ModalResult.Result.Interaction.GetModalValueByCustomId("newPrefix");
+
+ if (newPrefix.Length is > 4 or < 1)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ ctx.DbGuild.PrefixSettings.Prefix = newPrefix;
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/ReactionRolesCommand/AddCommand.cs b/ProjectMakoto/Commands/Configuration/ReactionRolesCommand/AddCommand.cs
new file mode 100644
index 00000000..6703cebe
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/ReactionRolesCommand/AddCommand.cs
@@ -0,0 +1,204 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.ReactionRolesCommand;
+
+internal sealed class AddCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.ReactionRoles;
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ DiscordMessage message;
+
+ var embed = new DiscordEmbedBuilder
+ {
+ Description = this.GetString(CommandKey.AddingReactionRole, true)
+ }.AsLoading(ctx, this.GetString(CommandKey.Title));
+
+ _ = await this.RespondOrEdit(embed);
+
+ DiscordRole role_parameter;
+ DiscordEmoji emoji_parameter;
+
+ if (arguments?.ContainsKey("message") ?? false)
+ {
+ message = (DiscordMessage)arguments["message"];
+ }
+ else
+ {
+ switch (ctx.CommandType)
+ {
+ case Enums.CommandType.PrefixCommand:
+ {
+ if (ctx.OriginalCommandContext.Message.ReferencedMessage is not null)
+ {
+ message = ctx.OriginalCommandContext.Message.ReferencedMessage;
+ }
+ else
+ {
+ this.SendSyntaxError();
+ return;
+ }
+
+ break;
+ }
+ default:
+ throw new ArgumentException("Message expected");
+ }
+ }
+
+ if (message is null)
+ {
+ this.SendSyntaxError();
+ return;
+ }
+
+ if (arguments?.ContainsKey("role_parameter") ?? false)
+ {
+ role_parameter = (DiscordRole)arguments["role_parameter"];
+ }
+ else
+ {
+ switch (ctx.CommandType)
+ {
+ case Enums.CommandType.ContextMenu:
+ {
+ embed.Description = this.GetString(CommandKey.SelectRolePrompt, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsAwaitingInput(ctx, this.GetString(CommandKey.Title))));
+ var RoleResult = await this.PromptRoleSelection();
+
+ if (RoleResult.TimedOut)
+ {
+ this.ModifyToTimedOut();
+ return;
+ }
+ else if (RoleResult.Cancelled)
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ else if (RoleResult.Failed)
+ {
+ if (RoleResult.Exception.GetType() == typeof(NullReferenceException))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(CommandKey.NoRoles, true)));
+ await Task.Delay(3000);
+ return;
+ }
+
+ throw RoleResult.Exception;
+ }
+
+ role_parameter = RoleResult.Result;
+ break;
+ }
+ default:
+ throw new ArgumentException("Interaction expected");
+ }
+ }
+
+ if (arguments?.ContainsKey("emoji_parameter") ?? false)
+ {
+ emoji_parameter = (DiscordEmoji)arguments["emoji_parameter"];
+ }
+ else
+ {
+ switch (ctx.CommandType)
+ {
+ case Enums.CommandType.ContextMenu:
+ {
+ embed.Description = this.GetString(CommandKey.ReactWithEmoji, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsAwaitingInput(ctx, this.GetString(CommandKey.Title))));
+
+ var emoji_wait = await ctx.Client.GetInteractivity().WaitForReactionAsync(x => x.Channel.Id == ctx.Channel.Id && x.User.Id == ctx.User.Id && x.Message.Id == message.Id, TimeSpan.FromMinutes(2));
+
+ if (emoji_wait.TimedOut)
+ {
+ this.ModifyToTimedOut();
+ return;
+ }
+
+ try
+ { _ = emoji_wait.Result.Message.DeleteReactionAsync(emoji_wait.Result.Emoji, ctx.User); }
+ catch { }
+
+ emoji_parameter = emoji_wait.Result.Emoji;
+
+ if (emoji_parameter.Id != 0 && !ctx.Guild.Emojis.ContainsKey(emoji_parameter.Id))
+ {
+ embed.Description = this.GetString(CommandKey.NoAccessToEmoji);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ return;
+ }
+
+ break;
+ }
+ default:
+ throw new ArgumentException("Interaction expected");
+ }
+ }
+
+ embed.Author.IconUrl = ctx.Guild.IconUrl;
+
+ if (ctx.DbGuild.ReactionRoles.Length > 100)
+ {
+ embed.Description = this.GetString(CommandKey.ReactionRoleLimitReached, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ return;
+ }
+
+ if (emoji_parameter.Id != 0 && !ctx.Guild.Emojis.ContainsKey(emoji_parameter.Id))
+ {
+ embed.Description = this.GetString(CommandKey.NoAccessToEmoji, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ return;
+ }
+
+ if (ctx.DbGuild.ReactionRoles.Any(x => (x.MessageId == message.Id && x.EmojiName == emoji_parameter.GetUniqueDiscordName())))
+ {
+ embed.Description = this.GetString(CommandKey.EmojiAlreadyUsed, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ return;
+ }
+
+ if (ctx.DbGuild.ReactionRoles.Any(x => x.RoleId == role_parameter.Id))
+ {
+ embed.Description = this.GetString(CommandKey.RoleAlreadyUsed, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ return;
+ }
+
+ await message.CreateReactionAsync(emoji_parameter);
+
+ ctx.DbGuild.ReactionRoles = ctx.DbGuild.ReactionRoles.Add(new()
+ {
+ ChannelId = message.Channel.Id,
+ RoleId = role_parameter.Id,
+ EmojiId = emoji_parameter.Id,
+ EmojiName = emoji_parameter.GetUniqueDiscordName(),
+ MessageId = message.Id
+ });
+
+ embed.Description = this.GetString(CommandKey.AddedReactionRole, true,
+ new TVar("Role", role_parameter.Mention),
+ new TVar("User", message.Author.Mention),
+ new TVar("Channel", message.Channel.Mention),
+ new TVar("Emoji", emoji_parameter));
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsSuccess(ctx, this.GetString(CommandKey.Title))));
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/ReactionRolesCommand/ConfigCommand.cs b/ProjectMakoto/Commands/Configuration/ReactionRolesCommand/ConfigCommand.cs
new file mode 100644
index 00000000..96feb20f
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/ReactionRolesCommand/ConfigCommand.cs
@@ -0,0 +1,372 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.ReactionRolesCommand;
+
+internal sealed class ConfigCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.ReactionRoles;
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder
+ {
+ Description = this.GetString(CommandKey.LoadingReactionRoles, true)
+ }.AsLoading(ctx, this.GetString(CommandKey.Title)));
+
+ _ = await ReactionRolesCommandAbstractions.CheckForInvalid(ctx);
+
+ var AddButton = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.AddNewReactionRole), (ctx.DbGuild.ReactionRoles.Length > 100), new DiscordComponentEmoji(DiscordEmoji.FromUnicode("➕")));
+ var RemoveButton = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), this.GetString(CommandKey.RemoveReactionRole), (ctx.DbGuild.ReactionRoles.Length == 0), new DiscordComponentEmoji(DiscordEmoji.FromUnicode("✖")));
+
+ var embed = new DiscordEmbedBuilder
+ {
+ Description = this.GetString(CommandKey.ReactionRoleCount, true, new TVar("Count", ctx.DbGuild.ReactionRoles.Length))
+ }.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed)
+ .AddComponents(new List
+ {
+ AddButton, RemoveButton
+ })
+ .AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var e = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (e.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ _ = e.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (e.GetCustomId() == AddButton.CustomId)
+ {
+ DiscordMessage selectedMessage = null;
+ DiscordEmoji selectedEmoji = null;
+ DiscordRole selectedRole = null;
+
+ while (true)
+ {
+ var SelectMessage = new DiscordButtonComponent((selectedMessage is null ? ButtonStyle.Primary : ButtonStyle.Secondary), Guid.NewGuid().ToString(), this.GetString(CommandKey.SelectMessage), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("💬")));
+ var SelectEmoji = new DiscordButtonComponent((selectedEmoji is null ? ButtonStyle.Primary : ButtonStyle.Secondary), Guid.NewGuid().ToString(), this.GetString(CommandKey.SelectEmoji), (selectedMessage is null), new DiscordComponentEmoji(DiscordEmoji.FromUnicode("😀")));
+ var SelectRole = new DiscordButtonComponent((selectedRole is null ? ButtonStyle.Primary : ButtonStyle.Secondary), Guid.NewGuid().ToString(), this.GetString(CommandKey.SelectRole), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("👤")));
+ var Finish = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), this.GetString(this.t.Common.Submit), (selectedMessage is null || selectedRole is null || selectedEmoji is null), new DiscordComponentEmoji(DiscordEmoji.FromUnicode("✅")));
+
+ var pad = TranslationUtil.CalculatePadding(ctx.DbUser, CommandKey.Message, CommandKey.Emoji, CommandKey.Role);
+
+ var action_embed = new DiscordEmbedBuilder
+ {
+ Description = $"`{this.GetString(CommandKey.Message).PadRight(pad)}`: {(selectedMessage is null ? this.GetString(this.t.Common.NotSelected, true) : $"[`{this.GetString(this.t.Common.JumpToMessage)}`]({selectedMessage.JumpLink})")}\n" +
+ $"`{this.GetString(CommandKey.Emoji).PadRight(pad)}`: {(selectedEmoji is null ? this.GetString(this.t.Common.NotSelected, true) : selectedEmoji.ToString())}\n" +
+ $"`{this.GetString(CommandKey.Role).PadRight(pad)}`: {(selectedRole is null ? this.GetString(this.t.Common.NotSelected, true) : selectedRole.Mention)}"
+ }.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+
+
+ if (ctx.DbGuild.ReactionRoles.Length > 100)
+ {
+ action_embed.Description = this.GetString(CommandKey.ReactionRoleLimitReached, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed)
+ .AddComponents(new List { SelectMessage, SelectEmoji, SelectRole, Finish })
+ .AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var Menu = await ctx.WaitForButtonAsync();
+
+ if (Menu.TimedOut)
+ {
+ this.ModifyToTimedOut();
+ return;
+ }
+
+ if (Menu.GetCustomId() == SelectMessage.CustomId)
+ {
+ var modal = new DiscordInteractionModalBuilder(this.GetString(CommandKey.Title), Guid.NewGuid().ToString())
+ .AddTextComponent(new DiscordTextComponent(TextComponentStyle.Small, "url", this.GetString(CommandKey.MessageUrl), "https://discord.com/channels/012345678901234567/012345678901234567/012345678912345678", null, null, true));
+
+ var ModalResult = await this.PromptModalWithRetry(Menu.Result.Interaction, modal, new DiscordEmbedBuilder
+ {
+ Description = this.GetString(CommandKey.MessageUrlInstructions, true),
+ ImageUrl = "https://cdn.discordapp.com/attachments/906976602557145110/967753175241203712/unknown.png"
+ }.AsAwaitingInput(ctx, this.GetString(CommandKey.Title)), false);
+
+ if (ModalResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ModalResult.Cancelled)
+ {
+ continue;
+ }
+ else if (ModalResult.Errored)
+ {
+ throw ModalResult.Exception;
+ }
+
+ var url = ModalResult.Result.Interaction.GetModalValueByCustomId("url");
+
+ if (!RegexTemplates.DiscordChannelUrl.IsMatch(url) || !url.TryParseMessageLink(out var GuildId, out var ChannelId, out var MessageId))
+ {
+ action_embed.Description = $"{this.GetString(CommandKey.InvalidMessageUrl, true)}\n" +
+ $"`https://discord.com/channels/012345678901234567/012345678901234567/012345678912345678`\n" +
+ $"`https://ptb.discord.com/channels/012345678901234567/012345678901234567/012345678912345678`\n" +
+ $"`https://canary.discord.com/channels/012345678901234567/012345678901234567/012345678912345678`";
+ action_embed.ImageUrl = "";
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(3000);
+ continue;
+ }
+
+ if (GuildId != ctx.Guild.Id)
+ {
+ action_embed.Description = this.GetString(CommandKey.MessageUrlWrongGuild, true);
+ action_embed.ImageUrl = "";
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(3000);
+ continue;
+ }
+
+ if (!ctx.Guild.Channels.ContainsKey(ChannelId))
+ {
+ action_embed.Description = this.GetString(CommandKey.MessageUrlNoChannel, true);
+ action_embed.ImageUrl = "";
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(3000);
+ continue;
+ }
+
+ var channel = ctx.Guild.GetChannel(ChannelId);
+
+ if (!channel.TryGetMessage(MessageId, out var reactionMessage))
+ {
+ action_embed.Description = this.GetString(CommandKey.MessageUrlNoMessage, true);
+ action_embed.ImageUrl = "";
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(3000);
+ continue;
+ }
+
+ selectedMessage = reactionMessage;
+ continue;
+ }
+ else if (Menu.GetCustomId() == SelectEmoji.CustomId)
+ {
+ _ = Menu.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ action_embed.Description = this.GetString(CommandKey.ReactWithEmoji, true);
+ action_embed.ImageUrl = "";
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed.AsAwaitingInput(ctx, this.GetString(CommandKey.Title))));
+
+ var emoji_wait = await ctx.Client.GetInteractivity().WaitForReactionAsync(x => x.Channel.Id == ctx.Channel.Id && x.User.Id == ctx.User.Id && x.Message.Id == selectedMessage.Id, TimeSpan.FromMinutes(2));
+
+ if (emoji_wait.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ try
+ { _ = emoji_wait.Result.Message.DeleteReactionAsync(emoji_wait.Result.Emoji, ctx.User); }
+ catch { }
+
+ var emoji = emoji_wait.Result.Emoji;
+
+ if (emoji.Id != 0 && !ctx.Guild.Emojis.ContainsKey(emoji.Id))
+ {
+ action_embed.Description = this.GetString(CommandKey.NoAccessToEmoji, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(3000);
+ continue;
+ }
+
+ if (ctx.DbGuild.ReactionRoles.Any(x => (x.MessageId == selectedMessage.Id && x.EmojiName == emoji.GetUniqueDiscordName())))
+ {
+ action_embed.Description = this.GetString(CommandKey.EmojiAlreadyUsed, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(3000);
+ continue;
+ }
+
+ selectedEmoji = emoji;
+ continue;
+ }
+ else if (Menu.GetCustomId() == SelectRole.CustomId)
+ {
+ _ = Menu.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ _ = await this.RespondOrEdit(action_embed.WithDescription(this.GetString(CommandKey.SelectRolePrompt, true)).AsAwaitingInput(ctx, this.GetString(CommandKey.Title)));
+
+ var RoleResult = await this.PromptRoleSelection();
+
+ if (RoleResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (RoleResult.Cancelled)
+ {
+ continue;
+ }
+ else if (RoleResult.Failed)
+ {
+ if (RoleResult.Exception.GetType() == typeof(NullReferenceException))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(CommandKey.NoRoles, true)));
+ await Task.Delay(3000);
+ continue;
+ }
+
+ throw RoleResult.Exception;
+ }
+
+ if (ctx.DbGuild.ReactionRoles.Any(x => x.RoleId == RoleResult.Result.Id))
+ {
+ action_embed.Description = this.GetString(CommandKey.RoleAlreadyUsed, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(3000);
+ continue;
+ }
+
+ selectedRole = RoleResult.Result;
+ continue;
+ }
+ else if (Menu.GetCustomId() == Finish.CustomId)
+ {
+ _ = Menu.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (ctx.DbGuild.ReactionRoles.Length > 100)
+ {
+ action_embed.Description = this.GetString(CommandKey.ReactionRoleLimitReached, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ if (ctx.DbGuild.ReactionRoles.Any(x => x.RoleId == selectedRole.Id))
+ {
+ action_embed.Description = this.GetString(CommandKey.RoleAlreadyUsed, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ if (selectedEmoji.Id != 0 && !ctx.Guild.Emojis.ContainsKey(selectedEmoji.Id))
+ {
+ action_embed.Description = this.GetString(CommandKey.NoAccessToEmoji, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ if (ctx.DbGuild.ReactionRoles.Any(x => (x.MessageId == selectedMessage.Id && x.EmojiName == selectedEmoji.GetUniqueDiscordName())))
+ {
+ action_embed.Description = this.GetString(CommandKey.EmojiAlreadyUsed, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ ctx.DbGuild.ReactionRoles = ctx.DbGuild.ReactionRoles.Add(new()
+ {
+ ChannelId = selectedMessage.Channel.Id,
+ RoleId = selectedRole.Id,
+ EmojiId = selectedEmoji.Id,
+ EmojiName = selectedEmoji.GetUniqueDiscordName(),
+ MessageId = selectedMessage.Id
+ });
+
+ await selectedMessage.CreateReactionAsync(selectedEmoji);
+
+ embed.Description = this.GetString(CommandKey.AddedReactionRole, true,
+ new TVar("Role", selectedRole.Mention),
+ new TVar("User", selectedMessage.Author.Mention),
+ new TVar("Channel", selectedMessage.Channel.Mention),
+ new TVar("Emoji", selectedEmoji));
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(action_embed.AsSuccess(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Menu.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ _ = Menu.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ return;
+ }
+ }
+ else if (e.GetCustomId() == RemoveButton.CustomId)
+ {
+ var RoleResult = await this.PromptCustomSelection(ctx.DbGuild.ReactionRoles
+ .Select(x => new DiscordStringSelectComponentOption($"@{ctx.Guild.GetRole(x.RoleId).Name}", x.UUID, $"in Channel #{ctx.Guild.GetChannel(x.ChannelId).Name}", emoji: new DiscordComponentEmoji(x.GetEmoji(ctx.Client)))).ToList());
+
+ if (RoleResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (RoleResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (RoleResult.Errored)
+ {
+ throw RoleResult.Exception;
+ }
+
+ var obj = ctx.DbGuild.ReactionRoles.First(x => x.UUID == RoleResult.Result);
+
+ if (ctx.Guild.GetChannel(obj.ChannelId).TryGetMessage(obj.MessageId, out var reactionMessage))
+ _ = reactionMessage.DeleteReactionsEmojiAsync(obj.GetEmoji(ctx.Client));
+
+ var role = ctx.Guild.GetRole(obj.RoleId);
+
+ ctx.DbGuild.ReactionRoles = ctx.DbGuild.ReactionRoles.Remove(x => x.MessageId.ToString(), obj);
+
+
+ embed.Description = this.GetString(CommandKey.RemovedReactionRole, true,
+ new TVar("Role", role.Mention),
+ new TVar("User", reactionMessage?.Author.Mention ?? "`/`"),
+ new TVar("Channel", reactionMessage?.Channel.Mention ?? "`/`"),
+ new TVar("Emoji", obj.GetEmoji(ctx.Client)));
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsSuccess(ctx, this.GetString(CommandKey.Title))));
+ await Task.Delay(5000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/ReactionRolesCommand/ReactionRolesCommandAbstractions.cs b/ProjectMakoto/Commands/Configuration/ReactionRolesCommand/ReactionRolesCommandAbstractions.cs
new file mode 100644
index 00000000..45bf4b49
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/ReactionRolesCommand/ReactionRolesCommandAbstractions.cs
@@ -0,0 +1,83 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.ReactionRolesCommand;
+
+internal static class ReactionRolesCommandAbstractions
+{
+ internal static async Task> CheckForInvalid(SharedCommandContext ctx)
+ {
+ if (await ctx.DbUser.Cooldown.WaitForHeavy(ctx))
+ return new();
+
+ Dictionary messageCache = new();
+
+ foreach (var b in ctx.DbGuild.ReactionRoles.ToList())
+ {
+ if (!ctx.Guild.Channels.ContainsKey(b.ChannelId))
+ {
+ ctx.DbGuild.ReactionRoles = ctx.DbGuild.ReactionRoles.Remove(x => x.MessageId.ToString(), b);
+ continue;
+ }
+
+ if (!ctx.Guild.Roles.ContainsKey(b.RoleId))
+ {
+ ctx.DbGuild.ReactionRoles = ctx.DbGuild.ReactionRoles.Remove(x => x.MessageId.ToString(), b);
+ continue;
+ }
+
+ var channel = ctx.Guild.GetChannel(b.ChannelId);
+
+ if (!messageCache.ContainsKey(b.MessageId))
+ {
+ try
+ {
+ var requested_msg = await channel.GetMessageAsync(b.MessageId);
+ messageCache.Add(b.MessageId, requested_msg);
+ }
+ catch (DisCatSharp.Exceptions.NotFoundException)
+ {
+ messageCache.Add(b.MessageId, null);
+
+ ctx.DbGuild.ReactionRoles = ctx.DbGuild.ReactionRoles.Remove(x => x.MessageId.ToString(), b);
+ continue;
+ }
+ catch (DisCatSharp.Exceptions.UnauthorizedException)
+ {
+ messageCache.Add(b.MessageId, null);
+
+ ctx.DbGuild.ReactionRoles = ctx.DbGuild.ReactionRoles.Remove(x => x.MessageId.ToString(), b);
+ continue;
+ }
+ }
+
+ if (messageCache[b.MessageId] == null)
+ {
+ ctx.DbGuild.ReactionRoles = ctx.DbGuild.ReactionRoles.Remove(x => x.MessageId.ToString(), b);
+ continue;
+ }
+
+ var msg = messageCache[b.MessageId ];
+
+ if (!msg.Reactions.Any(x => x.Emoji.Id == b.EmojiId && x.Emoji.GetUniqueDiscordName() == b.EmojiName && x.IsMe))
+ {
+ _ = msg.CreateReactionAsync(b.GetEmoji(ctx.Client)).ContinueWith(x =>
+ {
+ if (x.IsFaulted)
+ {
+ ctx.DbGuild.ReactionRoles = ctx.DbGuild.ReactionRoles.Remove(x => x.MessageId.ToString(), b);
+ }
+ });
+ continue;
+ }
+ }
+
+ return messageCache;
+ }
+}
diff --git a/ProjectMakoto/Commands/Configuration/ReactionRolesCommand/RemoveAllCommand.cs b/ProjectMakoto/Commands/Configuration/ReactionRolesCommand/RemoveAllCommand.cs
new file mode 100644
index 00000000..ef09781a
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/ReactionRolesCommand/RemoveAllCommand.cs
@@ -0,0 +1,86 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.ReactionRolesCommand;
+
+internal sealed class RemoveAllCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.ReactionRoles;
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ DiscordMessage message;
+
+ if (arguments?.ContainsKey("message") ?? false)
+ {
+ message = (DiscordMessage)arguments["message"];
+ }
+ else
+ {
+ switch (ctx.CommandType)
+ {
+ case Enums.CommandType.PrefixCommand:
+ {
+ if (ctx.OriginalCommandContext.Message.ReferencedMessage is not null)
+ {
+ message = ctx.OriginalCommandContext.Message.ReferencedMessage;
+ }
+ else
+ {
+ this.SendSyntaxError();
+ return;
+ }
+
+ break;
+ }
+ default:
+ throw new ArgumentException("Message expected");
+ }
+ }
+
+ if (message is null)
+ {
+ this.SendSyntaxError();
+ return;
+ }
+
+ var embed = new DiscordEmbedBuilder
+ {
+ Description = this.GetString(CommandKey.RemovingAllReactionRoles)
+ }.AsLoading(ctx, this.GetString(CommandKey.Title));
+
+ _ = await this.RespondOrEdit(embed);
+ embed.Author.IconUrl = ctx.Guild.IconUrl;
+
+ if (!ctx.DbGuild.ReactionRoles.Any(x => x.MessageId == message.Id))
+ {
+ embed.Description = this.GetString(CommandKey.NoReactionRoles, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ return;
+ }
+
+ foreach (var b in ctx.DbGuild.ReactionRoles.Where(x => x.MessageId == message.Id).ToList())
+ ctx.DbGuild.ReactionRoles = ctx.DbGuild.ReactionRoles.Remove(x => x.MessageId.ToString(), b);
+
+ _ = message.DeleteAllReactionsAsync();
+
+ embed.Description = this.GetString(CommandKey.RemovedAllReactionRoles, true,
+ new TVar("User", message?.Author.Mention ?? "`/`"),
+ new TVar("Channel", message?.Channel.Mention ?? "`/`"));
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsSuccess(ctx, this.GetString(CommandKey.Title))));
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/ReactionRolesCommand/RemoveCommand.cs b/ProjectMakoto/Commands/Configuration/ReactionRolesCommand/RemoveCommand.cs
new file mode 100644
index 00000000..5a2fa9a6
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/ReactionRolesCommand/RemoveCommand.cs
@@ -0,0 +1,122 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.ReactionRolesCommand;
+
+internal sealed class RemoveCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.ReactionRoles;
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ DiscordMessage message;
+
+ var embed = new DiscordEmbedBuilder
+ {
+ Description = this.GetString(CommandKey.RemovingReactionRole, true)
+ }.AsLoading(ctx, this.GetString(CommandKey.Title));
+
+ _ = await this.RespondOrEdit(embed);
+
+ DiscordEmoji emoji_parameter;
+
+ if (arguments?.ContainsKey("message") ?? false)
+ {
+ message = (DiscordMessage)arguments["message"];
+ }
+ else
+ {
+ switch (ctx.CommandType)
+ {
+ case Enums.CommandType.PrefixCommand:
+ {
+ if (ctx.OriginalCommandContext.Message.ReferencedMessage is not null)
+ {
+ message = ctx.OriginalCommandContext.Message.ReferencedMessage;
+ }
+ else
+ {
+ this.SendSyntaxError();
+ return;
+ }
+
+ break;
+ }
+ default:
+ throw new ArgumentException("Message expected");
+ }
+ }
+
+ if (message is null)
+ {
+ this.SendSyntaxError();
+ return;
+ }
+
+ if (arguments?.ContainsKey("emoji_parameter") ?? false)
+ {
+ emoji_parameter = (DiscordEmoji)arguments["emoji_parameter"];
+ }
+ else
+ {
+ switch (ctx.CommandType)
+ {
+ case Enums.CommandType.ContextMenu:
+ {
+ embed.Description = this.GetString(CommandKey.ReactWithEmojiToRemove, true);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsAwaitingInput(ctx, this.GetString(CommandKey.Title))));
+
+ var emoji_wait = await ctx.Client.GetInteractivity().WaitForReactionAsync(x => x.Channel.Id == ctx.Channel.Id && x.User.Id == ctx.User.Id && x.Message.Id == message.Id, TimeSpan.FromMinutes(2));
+
+ if (emoji_wait.TimedOut)
+ {
+ this.ModifyToTimedOut();
+ return;
+ }
+
+ emoji_parameter = emoji_wait.Result.Emoji;
+ break;
+ }
+ default:
+ throw new ArgumentException("Interaction expected");
+ }
+ }
+
+ if (!ctx.DbGuild.ReactionRoles.Any(x => x.MessageId == message.Id && x.EmojiName == emoji_parameter.GetUniqueDiscordName()))
+ {
+ embed.Description = this.GetString(CommandKey.NoReactionRoleFound);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsError(ctx, this.GetString(CommandKey.Title))));
+ return;
+ }
+
+ var obj = ctx.DbGuild.ReactionRoles.First(x => x.MessageId == message.Id && x.EmojiName == emoji_parameter.GetUniqueDiscordName());
+
+ var role = ctx.Guild.GetRole(obj.RoleId);
+ var channel = ctx.Guild.GetChannel(obj.ChannelId);
+ var reactionMessage = await channel.GetMessageAsync(obj.MessageId);
+ _ = reactionMessage.DeleteReactionsEmojiAsync(obj.GetEmoji(ctx.Client));
+
+ ctx.DbGuild.ReactionRoles = ctx.DbGuild.ReactionRoles.Remove(x => x.MessageId.ToString(), obj);
+
+ embed.Description = this.GetString(CommandKey.RemovedReactionRole, true,
+ new TVar("Role", role.Mention),
+ new TVar("User", reactionMessage?.Author.Mention ?? "`/`"),
+ new TVar("Channel", reactionMessage?.Channel.Mention ?? "`/`"),
+ new TVar("Emoji", obj.GetEmoji(ctx.Client)));
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed.AsSuccess(ctx, this.GetString(CommandKey.Title))));
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/TokenDetectionCommand.cs b/ProjectMakoto/Commands/Configuration/TokenDetectionCommand.cs
new file mode 100644
index 00000000..5ac6f0af
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/TokenDetectionCommand.cs
@@ -0,0 +1,68 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class TokenDetectionCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckAdmin();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.TokenDetection;
+
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ return $"⚠ `{this.GetString(CommandKey.DetectTokens)}`: {ctx.DbGuild.TokenLeakDetection.DetectTokens.ToEmote(ctx.Bot)}";
+ }
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ var embed = new DiscordEmbedBuilder
+ {
+ Description = GetCurrentConfiguration(ctx)
+ }.AsAwaitingInput(ctx, this.GetString(CommandKey.Title));
+
+ var Toggle = new DiscordButtonComponent((ctx.DbGuild.TokenLeakDetection.DetectTokens ? ButtonStyle.Danger : ButtonStyle.Success), Guid.NewGuid().ToString(), this.GetString(CommandKey.ToggleTokenDetection), false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("⚠")));
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed)
+ .AddComponents(new List
+ {
+ Toggle
+ })
+ .AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var e = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (e.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ _ = e.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (e.GetCustomId() == Toggle.CustomId)
+ {
+ ctx.DbGuild.TokenLeakDetection.DetectTokens = !ctx.DbGuild.TokenLeakDetection.DetectTokens;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Configuration/VcCreatorCommand.cs b/ProjectMakoto/Commands/Configuration/VcCreatorCommand.cs
new file mode 100644
index 00000000..638e3790
--- /dev/null
+++ b/ProjectMakoto/Commands/Configuration/VcCreatorCommand.cs
@@ -0,0 +1,98 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Configuration;
+
+internal sealed class VcCreatorCommand : BaseCommand
+{
+ public override async Task BeforeExecution(SharedCommandContext ctx) => (await this.CheckAdmin() && await this.CheckOwnPermissions(Permissions.ManageChannels));
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var CommandKey = this.t.Commands.Config.VcCreator;
+
+ string GetCurrentConfiguration(SharedCommandContext ctx)
+ {
+ return $"{EmojiTemplates.GetChannel(ctx.Bot)} `{this.GetString(CommandKey.Title)}`: {(ctx.DbGuild.VcCreator.Channel == 0 ? false.ToEmote(ctx.Bot) : $"<#{ctx.DbGuild.VcCreator.Channel}>")}";
+ }
+
+ if (await ctx.DbUser.Cooldown.WaitForLight(ctx))
+ return;
+
+ var embed = new DiscordEmbedBuilder
+ {
+ Description = GetCurrentConfiguration(ctx)
+ }.AsInfo(ctx, this.GetString(CommandKey.Title));
+
+ var SetChannel = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), this.GetString(CommandKey.SetVcCreator), false, EmojiTemplates.GetChannel(ctx.Bot).ToComponent());
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(embed)
+ .AddComponents(new List
+ {
+ SetChannel
+ })
+ .AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var e = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (e.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ _ = e.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (e.GetCustomId() == SetChannel.CustomId)
+ {
+ var ChannelResult = await this.PromptChannelSelection(ChannelType.Voice, new ChannelPromptConfiguration { DisableOption = this.GetString(CommandKey.DisableVcCreator) });
+
+ if (ChannelResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ChannelResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (ChannelResult.Failed)
+ {
+ if (ChannelResult.Exception.GetType() == typeof(NullReferenceException))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().AsError(ctx).WithDescription(this.GetString(CommandKey.NoChannels, true)));
+ await Task.Delay(3000);
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ throw ChannelResult.Exception;
+ }
+
+ var present = ChannelResult.Result.Parent.PermissionOverwrites;
+
+ var Category = ChannelResult.Result?.Parent ?? await ctx.Guild.CreateChannelAsync(this.GetString(CommandKey.Title), ChannelType.Category);
+ await ChannelResult.Result?.ModifyAsync(x => { x.Name = $"➕ {this.GetGuildString(CommandKey.CreateNewChannel)}"; x.Parent = Category; x.PermissionOverwrites = ChannelResult.Result.Parent.PermissionOverwrites.Merge(ctx.Guild.EveryoneRole, Permissions.None, Permissions.ReadMessageHistory | Permissions.UseVoiceDetection | Permissions.Speak); });
+
+ ctx.DbGuild.VcCreator.Channel = ChannelResult.Result?.Id ?? 0;
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (e.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/DebugCommands.cs b/ProjectMakoto/Commands/DebugCommands.cs
new file mode 100644
index 00000000..8cfe7b2b
--- /dev/null
+++ b/ProjectMakoto/Commands/DebugCommands.cs
@@ -0,0 +1,480 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.ApplicationCommands;
+
+[ModulePriority(-999)]
+
+public sealed partial class DebugCommands : ApplicationCommandsModule
+{
+ public Bot _bot { private get; set; }
+
+ public sealed class MaintainerAutoComplete : IAutocompleteProvider
+ {
+ public async Task> Provider(AutocompleteContext ctx)
+ {
+ try
+ {
+ var bot = ((Bot)ctx.Services.GetService(typeof(Bot)));
+
+ if (!ctx.User.IsMaintenance(bot.status))
+ return new List().AsEnumerable();
+
+ var filteredCommands = Enum.GetNames(typeof(DevCommands))
+ .Where(x => x.Contains(ctx.FocusedOption.Value.ToString(), StringComparison.InvariantCultureIgnoreCase)).Take(25);
+
+ var options = filteredCommands
+ .Select(x => new DiscordApplicationCommandAutocompleteChoice(x, x)).ToList();
+ return options.AsEnumerable();
+ }
+ catch (Exception)
+ {
+ return new List().AsEnumerable();
+ }
+ }
+ }
+
+ public sealed class ArgumentAutoComplete : IAutocompleteProvider
+ {
+ public async Task> Provider(AutocompleteContext ctx)
+ {
+ try
+ {
+ var bot = ((Bot)ctx.Services.GetService(typeof(Bot)));
+
+ if (!ctx.User.IsMaintenance(bot.status))
+ return new List().AsEnumerable();
+
+ if (ctx.Options.Any(x => x.Name == "command"))
+ {
+ var currentArgument = ctx.FocusedOption.Name switch
+ {
+ "argument1" => 1,
+ "argument2" => 2,
+ "argument3" => 3,
+ "argument4" => 4,
+ _ => -1,
+ };
+
+ var Command = (DevCommands)Enum.Parse(typeof(DevCommands), ctx.Options.First(x => x.Name == "command").Value.ToString());
+
+ return Command switch
+ {
+ DevCommands.RawGuild => currentArgument switch
+ {
+ 1 => [ new("GuildId", "") ],
+ _ => [],
+ },
+ DevCommands.BotNick => currentArgument switch
+ {
+ 1 => new List() { new("NewNickName", "") },
+ _ => [],
+ },
+ DevCommands.BanUser => currentArgument switch
+ {
+ 1 => [ new("UserId", "") ],
+ 2 => [ new("Reason", "") ],
+ _ => [],
+ },
+ DevCommands.UnbanUser => currentArgument switch
+ {
+ 1 => new List() { new("UserId", "") },
+ _ => [],
+ },
+ DevCommands.BanGuild => currentArgument switch
+ {
+ 1 => [ new("GuildId", "") ],
+ 2 => [ new("Reason", "") ],
+ _ => [],
+ },
+ DevCommands.UnbanGuild => currentArgument switch
+ {
+ 1 => [ new("GuildId", "") ],
+ _ => [],
+ },
+ DevCommands.GlobalBan => currentArgument switch
+ {
+ 1 => [ new("UserIds", "") ],
+ 2 => [ new("Reason", "") ],
+ _ => [],
+ },
+ DevCommands.GlobalUnban => currentArgument switch
+ {
+ 1 => [ ..bot.globalBans.Keys
+ .Where(bannedId =>
+ {
+ var currentInputRaw = ctx.Options.First(x => x.Name == "argument1").Value.ToString().Trim();
+ var currentInput = DiscordExtensions.ParseStringAsIdArray(currentInputRaw).ToList();
+
+ foreach (var input in currentInput)
+ if (bannedId == input)
+ return false;
+
+ return true;
+ })
+ .Select(bannedId =>
+ {
+ var val = bot.globalBans[bannedId];
+ var currentInputRaw = ctx.Options.First(x => x.Name == "argument1").Value.ToString().Trim();
+ var currentInput = DiscordExtensions.ParseStringAsIdArray(currentInputRaw)
+ .Select(id => id.ToString())
+ .ToList();
+
+ return new DiscordApplicationCommandAutocompleteChoice($"{(currentInput.Count > 0 ? $"{string.Join(", ", currentInput)}, " : string.Empty)}{bannedId}", $"{string.Join(" ", currentInput)} {bannedId}");
+ }).ToList()
+ ],
+ 2 => [ new("Unban from all servers that global banned them", "true"), new("Do not unban from all servers that global banned them", "false") ],
+ _ => [],
+ },
+ DevCommands.GlobalNotes => currentArgument switch
+ {
+ 1 => [ new("UserId", "") ],
+ _ => [],
+ },
+ DevCommands.Log => currentArgument switch
+ {
+ 1 => [
+ ..Enum.GetValues(typeof(LogEventLevel)).Cast().Select(x => {
+ var val = (LogEventLevel)x;
+ return new DiscordApplicationCommandAutocompleteChoice($"{Enum.GetName(val)} and above", ((int)val).ToString());
+ }).ToList()
+ ],
+ _ => [],
+ },
+ DevCommands.BatchLookup => currentArgument switch
+ {
+ 1 => [ new("UserId, UserId, UserId, ...", "") ],
+ _ => [],
+ },
+ DevCommands.CreateIssue => currentArgument switch
+ {
+ 1 => [ new("Use Textbox Label Selector", "true"), new("Use Dropdown Label Selector (broken)", "false")],
+ _ => [],
+ },
+ DevCommands.Evaluate => currentArgument switch
+ {
+ 1 => [ new("MessageId", "") ],
+ _ => [],
+ },
+ DevCommands.Disenroll2FAUser => currentArgument switch
+ {
+ 1 => [ new("UserId", "") ],
+ _ => [],
+ },
+ _ => [],
+ };
+ }
+
+ return [];
+ }
+ catch (Exception)
+ {
+ return new List().AsEnumerable();
+ }
+ }
+ }
+
+ [SlashCommand("developertools", "Developer Tools used to manage Makoto.", dmPermission: false, defaultMemberPermissions: (long)Permissions.None)]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0075:Simplify conditional expression", Justification = "")]
+ public async Task DevTools(InteractionContext ctx,
+ [Autocomplete(typeof(MaintainerAutoComplete))][Option("command", "The command to run.", true)] string command,
+ [Autocomplete(typeof(ArgumentAutoComplete))][Option("argument1", "Argument 1, if required", true)] string argument1 = "",
+ [Autocomplete(typeof(ArgumentAutoComplete))][Option("argument2", "Argument 2, if required", true)] string argument2 = "",
+ [Autocomplete(typeof(ArgumentAutoComplete))][Option("argument3", "Argument 3, if required", true)] string argument3 = "")
+ {
+ bool Require1()
+ {
+ if (argument1.IsNullOrWhiteSpace())
+ {
+ _ = ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().WithContent("Argument 1 required").AsEphemeral());
+ return false;
+ }
+ else
+ return true;
+ }
+
+ bool Require2()
+ {
+ if (argument2.IsNullOrWhiteSpace())
+ {
+ _ = ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().WithContent("Argument 2 required").AsEphemeral());
+ return false;
+ }
+ else
+ return true;
+ }
+
+#pragma warning disable CS8321 // Local function is declared but never used
+ bool Require3()
+ {
+ if (argument3.IsNullOrWhiteSpace())
+ {
+ _ = ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().WithContent("Argument 3 required").AsEphemeral());
+ return false;
+ }
+ else
+ return true;
+ }
+
+
+
+ if (!ctx.User.IsMaintenance(this._bot.status))
+ {
+ DummyCommand dummyCommand = new();
+ await dummyCommand.ExecuteCommand(ctx, this._bot);
+
+ dummyCommand.SendMaintenanceError();
+ return;
+ }
+
+ DevCommands Command;
+
+ try
+ {
+ Command = (DevCommands)Enum.Parse(typeof(DevCommands), command);
+ }
+ catch (Exception)
+ {
+ await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().WithContent("Specified Command does not exist.").AsEphemeral());
+ return;
+ }
+
+ try
+ {
+ switch (Command)
+ {
+ case DevCommands.Info:
+ _ = Task.Run(async () =>
+ {
+ await new Commands.DevTools.InfoCommand().ExecuteCommand(ctx, this._bot);
+ });
+ break;
+ case DevCommands.RawGuild:
+ _ = Task.Run(async () =>
+ {
+ if (!Require1())
+ return;
+
+ await new Commands.DevTools.RawGuildCommand().ExecuteCommand(ctx, this._bot, new Dictionary
+ {
+ { "guild", argument1 is not null ? Convert.ToUInt64(argument1) : null }
+ });
+ });
+ break;
+ case DevCommands.BotNick:
+ _ = Task.Run(async () =>
+ {
+ await new Commands.DevTools.BotnickCommand().ExecuteCommand(ctx, this._bot, new Dictionary
+ {
+ { "newNickname", argument1 }
+ });
+ });
+ break;
+ case DevCommands.BanUser:
+ _ = Task.Run(async () =>
+ {
+ if (!Require1() || !Require2())
+ return;
+
+ await new Commands.DevTools.BanUserCommand().ExecuteCommandWith2FA(ctx, this._bot, new Dictionary
+ {
+ { "victim", await DiscordExtensions.ParseStringAsUser(argument1, ctx.Client) },
+ { "reason", argument2 },
+ });
+ });
+ break;
+ case DevCommands.UnbanUser:
+ _ = Task.Run(async () =>
+ {
+ if (!Require1())
+ return;
+
+ await new Commands.DevTools.UnbanUserCommand().ExecuteCommandWith2FA(ctx, this._bot, new Dictionary
+ {
+ { "victim", await DiscordExtensions.ParseStringAsUser(argument1, ctx.Client) },
+ });
+ });
+ break;
+ case DevCommands.BanGuild:
+ _ = Task.Run(async () =>
+ {
+ if (!Require1() || !Require2())
+ return;
+
+ await new Commands.DevTools.BanGuildCommand().ExecuteCommandWith2FA(ctx, this._bot, new Dictionary
+ {
+ { "guild", Convert.ToUInt64(argument1) },
+ { "reason", argument2 }
+ });
+ });
+ break;
+ case DevCommands.UnbanGuild:
+ _ = Task.Run(async () =>
+ {
+ if (!Require1())
+ return;
+
+ await new Commands.DevTools.UnbanGuildCommand().ExecuteCommandWith2FA(ctx, this._bot, new Dictionary
+ {
+ { "guild", Convert.ToUInt64(argument1) },
+ });
+ });
+ break;
+ case DevCommands.GlobalBan:
+ _ = Task.Run(async () =>
+ {
+ if (!Require1() || !Require2())
+ return;
+
+ await new Commands.DevTools.GlobalBanCommand().ExecuteCommandWith2FA(ctx, this._bot, new Dictionary
+ {
+ { "victims", argument1 },
+ { "reason", argument2 },
+ });
+ });
+ break;
+ case DevCommands.GlobalUnban:
+ _ = Task.Run(async () =>
+ {
+ if (!Require1())
+ return;
+
+ await new Commands.DevTools.GlobalUnbanCommand().ExecuteCommandWith2FA(ctx, this._bot, new Dictionary
+ {
+ { "victims", argument1 },
+ { "UnbanFromGuilds", bool.TryParse(argument2, out var r) ? r : true },
+ });
+ });
+ break;
+ case DevCommands.GlobalNotes:
+ _ = Task.Run(async () =>
+ {
+ if (!Require1())
+ return;
+
+ await new Commands.DevTools.GlobalNotesCommand().ExecuteCommandWith2FA(ctx, this._bot, new Dictionary
+ {
+ { "victim", await DiscordExtensions.ParseStringAsUser(argument1, ctx.Client) },
+ });
+ });
+ break;
+ case DevCommands.Log:
+ _ = Task.Run(async () =>
+ {
+ if (!Require1())
+ return;
+
+ await new Commands.DevTools.LogCommand().ExecuteCommand(ctx, this._bot, new Dictionary
+ {
+ { "Level", (LogEventLevel)Enum.Parse(typeof(LogEventLevel), argument1) },
+ });
+ });
+ break;
+ case DevCommands.Stop:
+ _ = Task.Run(async () =>
+ {
+ await new Commands.DevTools.StopCommand().ExecuteCommandWith2FA(ctx, this._bot, null);
+ });
+ break;
+ case DevCommands.BatchLookup:
+ _ = Task.Run(async () =>
+ {
+ if (!Require1())
+ return;
+
+ await new Commands.DevTools.BatchLookupCommand().ExecuteCommand(ctx, this._bot, new Dictionary
+ {
+ { "IDs", argument1 },
+ });
+ });
+ break;
+ case DevCommands.CreateIssue:
+ _ = Task.Run(async () =>
+ {
+ await new Commands.DevTools.CreateIssueCommand().ExecuteCommand(ctx, this._bot, new Dictionary
+ {
+ { "UseOldTagsSelector", (bool.TryParse(argument1, out var result) ? result : true) },
+ }, InitiateInteraction: false);
+ });
+ break;
+ case DevCommands.Evaluate:
+ _ = Task.Run(async () =>
+ {
+ if (!Require1())
+ return;
+
+ var id = Convert.ToUInt64(argument1);
+ var message = await ctx.Channel.GetMessageAsync(id);
+
+ await new Commands.DevTools.EvaluationCommand().ExecuteCommandWith2FA(ctx, this._bot, new Dictionary
+ {
+ { "code", message.Content },
+ });
+ });
+ break;
+ case DevCommands.Enroll2FA:
+ _ = Task.Run(async () =>
+ {
+ await new Commands.DevTools.EnrollTwoFactorCommand().ExecuteCommand(ctx, this._bot);
+ });
+ break;
+ case DevCommands.Quit2FASession:
+ _ = Task.Run(async () =>
+ {
+ await new Commands.DevTools.Quit2FASessionCommand().ExecuteCommand(ctx, this._bot);
+ });
+ break;
+
+ case DevCommands.Disenroll2FAUser:
+ _ = Task.Run(async () =>
+ {
+ if (!Require1())
+ return;
+
+ await new Commands.DevTools.Disenroll2FAUserCommand().ExecuteCommandWith2FA(ctx, this._bot, new Dictionary
+ {
+ { "victim", await DiscordExtensions.ParseStringAsUser(argument1, ctx.Client) },
+ });
+ });
+ break;
+ case DevCommands.ManageCommands:
+ _ = Task.Run(async () =>
+ {
+ await new Commands.DevTools.CommandManageCommand().ExecuteCommand(ctx, this._bot);
+ });
+ break;
+ }
+ }
+ catch (Exception)
+ {
+ await ctx.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder().WithContent("Exception occurred, check console.").AsEphemeral());
+ }
+ }
+
+#if DEBUG
+ [SlashCommandGroup("debug", "Debug commands, only registered in this server.")]
+ public sealed class Debug : ApplicationCommandsModule
+ {
+ public Bot _bot { private get; set; }
+
+ [SlashCommand("throw", "Throw.")]
+ public async Task Throw(InteractionContext ctx)
+ => _ = new Commands.Debug.ThrowCommand().ExecuteCommand(ctx, this._bot);
+
+ [SlashCommand("test", "Test.")]
+ public async Task Test(InteractionContext ctx)
+ {
+ _ = Task.Run(async () =>
+ {
+
+ });
+ }
+ }
+#endif
+}
diff --git a/ProjectMakoto/Commands/DummyCommand.cs b/ProjectMakoto/Commands/DummyCommand.cs
new file mode 100644
index 00000000..b8dc322e
--- /dev/null
+++ b/ProjectMakoto/Commands/DummyCommand.cs
@@ -0,0 +1,18 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands;
+
+internal sealed class DummyCommand : BaseCommand
+{
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.CompletedTask;
+ }
+}
diff --git a/ProjectMakoto/Commands/Maintainers/DevDebug/ThrowCommand.cs b/ProjectMakoto/Commands/Maintainers/DevDebug/ThrowCommand.cs
new file mode 100644
index 00000000..048a8875
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevDebug/ThrowCommand.cs
@@ -0,0 +1,21 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.Debug;
+
+internal sealed class ThrowCommand : BaseCommand
+{
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ throw new InvalidCastException();
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/BanGuildCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/BanGuildCommand.cs
new file mode 100644
index 00000000..3d88008c
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/BanGuildCommand.cs
@@ -0,0 +1,43 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class BanGuildCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckMaintenance();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var guild = (ulong)arguments["guild"];
+ var reason = (string)arguments["reason"];
+
+ if (reason.IsNullOrWhiteSpace())
+ reason = "No reason provided.";
+
+ if (ctx.Bot.bannedGuilds.ContainsKey(guild))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription($"`Guild '{guild}' is already banned from using the bot.`").AsError(ctx));
+ return;
+ }
+
+ ctx.Bot.bannedGuilds.Add(guild, new(ctx.Bot, "banned_guilds", guild) { Reason = reason, Moderator = ctx.User.Id });
+
+ foreach (var b in ctx.Client.Guilds.Where(x => x.Key == guild))
+ {
+ Log.Information("Leaving guild '{guild}'..", b.Key);
+ await b.Value.LeaveAsync();
+ }
+
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription($"`Guild '{guild}' was banned from using the bot.`").AsSuccess(ctx));
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/BanUserCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/BanUserCommand.cs
new file mode 100644
index 00000000..3b323973
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/BanUserCommand.cs
@@ -0,0 +1,49 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class BanUserCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckMaintenance();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var victim = (DiscordUser)arguments["victim"];
+ var reason = (string)arguments["reason"];
+
+ if (reason.IsNullOrWhiteSpace())
+ reason = "No reason provided.";
+
+ if (ctx.Bot.status.TeamMembers.Contains(victim.Id))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription($"`'{victim.GetUsernameWithIdentifier()}' is registered in the staff team.`").AsError(ctx));
+ return;
+ }
+
+ if (ctx.Bot.bannedUsers.ContainsKey(victim.Id))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription($"`'{victim.GetUsernameWithIdentifier()}' is already banned from using the bot.`").AsError(ctx));
+ return;
+ }
+
+ ctx.Bot.bannedUsers.Add(victim.Id, new(ctx.Bot, "banned_users", victim.Id) { Reason = reason, Moderator = ctx.User.Id });
+
+ foreach (var b in ctx.Client.Guilds.Where(x => x.Value.OwnerId == victim.Id))
+ {
+ Log.Information("Leaving guild '{guild}'..", b.Key);
+ await b.Value.LeaveAsync();
+ }
+
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription($"`'{victim.GetUsernameWithIdentifier()}' was banned from using the bot.`").AsSuccess(ctx));
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/BatchLookupCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/BatchLookupCommand.cs
new file mode 100644
index 00000000..f301495b
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/BatchLookupCommand.cs
@@ -0,0 +1,43 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class BatchLookupCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckMaintenance();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var IDs = ((string)arguments["IDs"]).Split(" ", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Select(x => x.ToUInt64()).ToList();
+
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription($"`Looking up {IDs.Count} users..`\n`{StringTools.GenerateASCIIProgressbar(0d, IDs.Count)}`").AsLoading(ctx));
+
+ Dictionary fetched = new();
+
+ for (var i = 0; i < IDs.Count; i++)
+ {
+ try
+ {
+ fetched.Add(IDs[i], await ctx.Client.GetUserAsync(IDs[i]));
+ }
+ catch (Exception)
+ {
+ fetched.Add(IDs[i], null);
+ }
+
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription($"`Looking up {IDs.Count} users..`\n`{StringTools.GenerateASCIIProgressbar(i, IDs.Count)}`").AsLoading(ctx));
+ }
+
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription(string.Join("\n", fetched.Select(x => $"{(x.Value is null ? $"❌ `Failed to fetch '{x.Key}'`" : $"✅ {x.Value.Mention} `{x.Value.GetUsernameWithIdentifier()}` (`{x.Value.Id}`)")}"))).AsSuccess(ctx));
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/BotnickCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/BotnickCommand.cs
new file mode 100644
index 00000000..e0fa7dbb
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/BotnickCommand.cs
@@ -0,0 +1,37 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class BotnickCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckMaintenance();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var newNickname = (string)arguments["newNickname"];
+
+ try
+ {
+ await ctx.Guild.CurrentMember.ModifyAsync(x => x.Nickname = newNickname);
+
+ if (newNickname.IsNullOrWhiteSpace())
+ _ = await this.RespondOrEdit($"My nickname on this server has been reset.");
+ else
+ _ = await this.RespondOrEdit($"My nickname on this server has been changed to **{newNickname}**.");
+ }
+ catch (Exception)
+ {
+ _ = await this.RespondOrEdit($"My nickname could not be changed.");
+ }
+ });
+ }
+}
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/CommandManageCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/CommandManageCommand.cs
new file mode 100644
index 00000000..79eb72b6
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/CommandManageCommand.cs
@@ -0,0 +1,142 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class CommandManageCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckMaintenance();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var EnableCommandButton = new DiscordButtonComponent(ButtonStyle.Success, Guid.NewGuid().ToString(), "Enable Command", ctx.Bot.status.LoadedConfig.Discord.DisabledCommands.Count == 0, "➕".UnicodeToEmoji().ToComponent());
+ var DisableCommandButton = new DiscordButtonComponent(ButtonStyle.Danger, Guid.NewGuid().ToString(), "Disable Command", false, "➖".UnicodeToEmoji().ToComponent());
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder()
+ .AddEmbed(new DiscordEmbedBuilder()
+ .WithTitle("Disabled Commands")
+ .WithDescription($"{(ctx.Bot.status.LoadedConfig.Discord.DisabledCommands.Count != 0 ? string.Join(", ", ctx.Bot.status.LoadedConfig.Discord.DisabledCommands.Select(x => $"`{x}`")) : "`No commands disabled.`")}")
+ .AsAwaitingInput(ctx))
+ .AddComponents(EnableCommandButton, DisableCommandButton)
+ .AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var Button = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (Button.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ _ = Button.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (Button.GetCustomId() == EnableCommandButton.CustomId)
+ {
+ var SelectionResult = await this.PromptCustomSelection(ctx.Bot.status.LoadedConfig.Discord.DisabledCommands.Select(x => new DiscordStringSelectComponentOption(x, x)).ToList());
+
+ if (SelectionResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (SelectionResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (SelectionResult.Errored)
+ {
+ throw SelectionResult.Exception;
+ }
+
+ if (!ctx.Bot.status.LoadedConfig.Discord.DisabledCommands.Contains(SelectionResult.Result))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder()
+ .WithDescription("`That command is already enabled.`")
+ .AsError(ctx));
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ _ = ctx.Bot.status.LoadedConfig.Discord.DisabledCommands.Remove(SelectionResult.Result);
+ ctx.Bot.status.LoadedConfig.Save();
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == DisableCommandButton.CustomId)
+ {
+ List CommandList = new();
+
+ foreach (var cmd in ctx.Client.GetCommandList(ctx.Bot))
+ {
+ if (ctx.Bot.status.LoadedConfig.Discord.DisabledCommands.Contains(cmd.Name.ToLower()))
+ continue;
+
+ CommandList.Add(cmd.Name.ToLower());
+
+ foreach (var sub in cmd.Options?.Where(x => x.Type == ApplicationCommandOptionType.SubCommand) ?? new List())
+ {
+ if (ctx.Bot.status.LoadedConfig.Discord.DisabledCommands.Contains($"{cmd.Name} {sub.Name}".ToLower()))
+ continue;
+
+ CommandList.Add($"{cmd.Name} {sub.Name}".ToLower());
+ }
+ }
+
+ if (CommandList.Count == 0)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ var SelectionResult = await this.PromptCustomSelection(CommandList.Select(x =>
+ new DiscordStringSelectComponentOption(x.FirstLetterToUpper(), x,
+ (x.Contains(' ') ? "Sub Command" : (CommandList.Where(y => y.StartsWith(x)).Count() >= 2 ? "Command Group" : "Single Command")))).ToList(), "Select a command to disable..");
+
+ if (SelectionResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (SelectionResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (SelectionResult.Errored)
+ {
+ throw SelectionResult.Exception;
+ }
+
+ if (ctx.Bot.status.LoadedConfig.Discord.DisabledCommands.Contains(SelectionResult.Result))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder()
+ .WithDescription("`That command is already disabled.`")
+ .AsError(ctx));
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+
+ ctx.Bot.status.LoadedConfig.Discord.DisabledCommands.Add(SelectionResult.Result);
+ ctx.Bot.status.LoadedConfig.Save();
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/CreateIssueCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/CreateIssueCommand.cs
new file mode 100644
index 00000000..1702070d
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/CreateIssueCommand.cs
@@ -0,0 +1,92 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+using Octokit;
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class CreateIssueCommand : BaseCommand
+{
+ public override async Task BeforeExecution(SharedCommandContext ctx) => (await this.CheckMaintenance() && await this.CheckSource(Enums.CommandType.ApplicationCommand));
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var UseOldTagsSelector = (bool)arguments["UseOldTagsSelector"];
+
+ if (ctx.Bot.status.LoadedConfig.Secrets.Github.TokenExperiation.GetTotalSecondsUntil() <= 0)
+ {
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithContent($"❌ `The GitHub Token expired, please update.`"));
+ return;
+ }
+
+ var labels = await ctx.Bot.GithubClient.Issue.Labels.GetAllForRepository(ctx.Bot.status.LoadedConfig.Secrets.Github.Username, ctx.Bot.status.LoadedConfig.Secrets.Github.Repository);
+
+ var modal = new DiscordInteractionModalBuilder().WithCustomId(Guid.NewGuid().ToString()).WithTitle("Create new Issue on Github")
+ .AddModalComponents(new DiscordTextComponent(TextComponentStyle.Small, "title", "Title", "New issue", 4, 250, true))
+ .AddModalComponents(new DiscordTextComponent(TextComponentStyle.Paragraph, "description", "Description", required: false));
+
+ if (!UseOldTagsSelector)
+ _ = modal.AddModalComponents(new DiscordStringSelectComponent("Select tags", labels.Select(x => new DiscordStringSelectComponentOption(x.Name, x.Name.ToLower().MakeValidFileName(), "", false, new DiscordComponentEmoji(new DiscordColor(x.Color).GetClosestColorEmoji(ctx.Client)))), "labels", 1, labels.Count));
+ else
+ _ = modal.AddModalComponents(new DiscordTextComponent(TextComponentStyle.Paragraph, "labels", "Labels", "", null, null, false, $"Put a # in front of every label you want to add.\n\n{string.Join("\n", labels.Select(x => x.Name))}"));
+
+ await ctx.OriginalInteractionContext.CreateModalResponseAsync(modal);
+
+ CancellationTokenSource cancellationTokenSource = new();
+
+ ctx.Client.ComponentInteractionCreated += RunInteraction;
+
+ async Task RunInteraction(DiscordClient s, ComponentInteractionCreateEventArgs e)
+ {
+ _ = Task.Run(async () =>
+ {
+ if (e.GetCustomId() == modal.CustomId)
+ {
+ cancellationTokenSource.Cancel();
+ ctx.Client.ComponentInteractionCreated -= RunInteraction;
+
+ _ = e.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+ var followup = await e.Interaction.CreateFollowupMessageAsync(new DiscordFollowupMessageBuilder { IsEphemeral = true }.WithContent(":arrows_counterclockwise: `Submitting your issue..`"));
+
+ var labelComp = e.Interaction.Data.Components.Where(x => x.CustomId == "labels").First();
+
+ var title = e.Interaction.Data.Components.Where(x => x.CustomId == "title").First().Value;
+ var description = e.Interaction.Data.Components.Where(x => x.CustomId == "description").First().Value;
+ var labels = labelComp.Type == ComponentType.StringSelect
+ ? labelComp.Values.ToList()
+ : labelComp.Value.Split("\n", StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries).Where(x => x.StartsWith('#')).Select(x => x.Replace("#", "")).ToList();
+
+ if (ctx.Bot.status.LoadedConfig.Secrets.Github.TokenExperiation.GetTotalSecondsUntil() <= 0)
+ {
+ _ = e.Interaction.EditFollowupMessageAsync(followup.Id, new DiscordWebhookBuilder().WithContent($"❌ `The GitHub Token expired, please update.`"));
+ return;
+ }
+
+ var issue = await ctx.Bot.GithubClient.Issue.Create(ctx.Bot.status.LoadedConfig.Secrets.Github.Username, ctx.Bot.status.LoadedConfig.Secrets.Github.Repository, new NewIssue(title) { Body = $"{(description.IsNullOrWhiteSpace() ? "_No description provided_" : description)}\n\n\n\n#####
_Submitted by [`{ctx.User.GetUsernameWithIdentifier()}`]({ctx.User.ProfileUrl}) (`{ctx.User.Id}`) via Discord._" });
+
+ if (labels.Count > 0)
+ _ = await ctx.Bot.GithubClient.Issue.Labels.ReplaceAllForIssue(ctx.Bot.status.LoadedConfig.Secrets.Github.Username, ctx.Bot.status.LoadedConfig.Secrets.Github.Repository, issue.Number, labels.ToArray());
+
+ _ = e.Interaction.EditFollowupMessageAsync(followup.Id, new DiscordWebhookBuilder().WithContent($"✅ `Issue submitted:` {issue.HtmlUrl}"));
+ }
+ }).Add(ctx.Bot, ctx);
+ }
+
+ try
+ {
+ await Task.Delay(TimeSpan.FromMinutes(15), cancellationTokenSource.Token);
+
+ ctx.Client.ComponentInteractionCreated -= RunInteraction;
+ }
+ catch { }
+ });
+ }
+}
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/Disenroll2FAUserCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/Disenroll2FAUserCommand.cs
new file mode 100644
index 00000000..9420d8f8
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/Disenroll2FAUserCommand.cs
@@ -0,0 +1,33 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class Disenroll2FAUserCommand : BaseCommand
+{
+ public override async Task BeforeExecution(SharedCommandContext ctx)
+ => await this.CheckMaintenance() && await this.CheckBotOwner();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var victim = (DiscordUser)arguments["victim"];
+
+ if (!ctx.Client.CheckTwoFactorEnrollmentFor(victim.Id))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription($"`{victim.GetUsernameWithIdentifier()} is not enrolled in Two Factor Authentication.`").AsError(ctx));
+ return;
+ }
+
+ ctx.Client.DisenrollTwoFactor(victim.Id);
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription($"`Two Factor Authentication removed for {victim.GetUsername()}.`").AsSuccess(ctx));
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/EnrollTwoFactorCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/EnrollTwoFactorCommand.cs
new file mode 100644
index 00000000..a01407bf
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/EnrollTwoFactorCommand.cs
@@ -0,0 +1,93 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+using DisCatSharp.Extensions.TwoFactorCommands.Enums;
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class EnrollTwoFactorCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx)
+ => this.CheckMaintenance();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ if (ctx.Client.CheckTwoFactorEnrollmentFor(ctx.User.Id))
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription("`You're already enrolled in Two Factor Authentication.`").AsError(ctx));
+ return;
+ }
+
+ var Confirmed = false;
+
+ var ConfirmButton = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), "Confirm Two Factor Authentication", false, DiscordEmoji.FromUnicode("✅").ToComponent());
+
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription("`Enrolling you into Two Factor Authentication..`").AsLoading(ctx));
+ var (Secret, QrCode) = ctx.Client.EnrollTwoFactor(ctx.User);
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithContent($"Please scan this QR Code or use the Secret below to register the Two Factor in an App of your choosing." +
+ $"\n\n`{Secret}`\n\n" +
+ $"When you're done, please press the button below to confirm the success of the registration.")
+ .WithFile("2fa.png", QrCode, false, "This is a QR Code for an Authenticator App.")
+ .AddComponents(ConfirmButton, MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ _ = Task.Delay(120000).ContinueWith((_) =>
+ {
+ ctx.Client.ComponentInteractionCreated -= RunInteraction;
+
+ if (!Confirmed)
+ {
+ ctx.Client.DisenrollTwoFactor(ctx.User.Id);
+ _ = this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription("`Failed to authenticate. Enrollment reverted.`").AsError(ctx));
+ }
+ });
+
+ async Task RunInteraction(DiscordClient s, ComponentInteractionCreateEventArgs e)
+ {
+ _ = Task.Run(async () =>
+ {
+ if (e.Message?.Id == ctx.ResponseMessage.Id && e.User.Id == ctx.User.Id)
+ {
+ try
+ {
+ if (e.GetCustomId() == ConfirmButton.CustomId)
+ {
+ var tfa_result = await e.RequestTwoFactorAsync(s);
+
+ if (tfa_result.Result is TwoFactorResult.ValidCode or TwoFactorResult.InvalidCode)
+ _ = tfa_result.ComponentInteraction.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ if (tfa_result.Result == TwoFactorResult.ValidCode)
+ {
+ Confirmed = true;
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription("`Enrolled successfully.`").AsSuccess(ctx));
+ return;
+ }
+
+ throw new Exception("Invalid Code");
+ }
+ else if (e.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ throw new Exception("Cancelled");
+ }
+ }
+ catch (Exception)
+ {
+ ctx.Client.DisenrollTwoFactor(ctx.User.Id);
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription("`Failed to authenticate. Enrollment reverted.`").AsError(ctx));
+ }
+ }
+ });
+ }
+
+ ctx.Client.ComponentInteractionCreated += RunInteraction;
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/EvaluationCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/EvaluationCommand.cs
new file mode 100644
index 00000000..c35d0d27
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/EvaluationCommand.cs
@@ -0,0 +1,83 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp.Scripting;
+using Microsoft.CodeAnalysis.Scripting;
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class EvaluationCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckBotOwner();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ if (ctx.CommandType is not Enums.CommandType.ApplicationCommand and not Enums.CommandType.ContextMenu)
+ {
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithEmbed(new DiscordEmbedBuilder().WithDescription("Evaluating CScript has the potential of leaking confidential information. Are you sure you want to run this command as Prefix Command?").AsWarning(ctx))
+ .AddComponents(new List { new DiscordButtonComponent(ButtonStyle.Success, "yes", "Yes"),
+ new DiscordButtonComponent(ButtonStyle.Danger, "no", "No")}));
+
+ var result = await ctx.ResponseMessage.WaitForButtonAsync(ctx.User);
+
+ if (result.TimedOut || result.GetCustomId() != "yes")
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ }
+
+ var rawCode = (string)arguments["code"];
+
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription("`Evaluating..`").AsLoading(ctx));
+
+ var code = RegexTemplates.Code.Match(rawCode).Groups[1]?.Value?.Trim() ?? "";
+
+ if (code.IsNullOrWhiteSpace())
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription("`No code block was found.`").AsError(ctx));
+ return;
+ }
+
+ try
+ {
+ var options = ScriptOptions.Default;
+ options = options.WithImports(
+ "System",
+ "System.Collections.Generic",
+ "System.Linq",
+ "System.Text",
+ "System.Threading.Tasks",
+ "DisCatSharp",
+ "DisCatSharp.Entities",
+ "DisCatSharp.Interactivity",
+ "DisCatSharp.Interactivity.Extensions",
+ "DisCatSharp.Interactivity.Enums",
+ "DisCatSharp.Enums",
+ "Newtonsoft.Json"
+ );
+ options = options.WithReferences(AppDomain.CurrentDomain.GetAssemblies().Where(x => !x.IsDynamic && !x.Location.IsNullOrWhiteSpace()));
+
+ var script = CSharpScript.Create(code, options, typeof(SharedCommandContext));
+ _ = script.Compile();
+ var result = await script.RunAsync(ctx).ConfigureAwait(false);
+
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithTitle("Successful Evaluation")
+ .WithDescription($"{(result.ReturnValue?.ToString().IsNullOrWhiteSpace() ?? true ? "`The evaluation did not return any result.`" : $"{result.ReturnValue}")}").AsSuccess(ctx));
+ }
+ catch (Exception ex)
+ {
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithTitle("Failed Evaluation").WithDescription($"```{ex.Message.SanitizeForCode()}```").AsError(ctx));
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/GlobalBanCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/GlobalBanCommand.cs
new file mode 100644
index 00000000..acad0963
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/GlobalBanCommand.cs
@@ -0,0 +1,183 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.DevTools;
+internal sealed class GlobalBanCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckMaintenance();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var victims = await DiscordExtensions.ParseStringAsUserArray((string)arguments["victims"], ctx.Client);
+ var reason = (string)arguments["reason"];
+
+ if (victims?.Length <= 0)
+ {
+ _ = this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription("`Please provide user(s).`").AsError(ctx, "Global Ban"));
+ return;
+ }
+
+ if (reason.IsNullOrWhiteSpace())
+ {
+ _ = this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription("`Please provide a reason for the global ban.`").AsError(ctx, "Global Ban"));
+ return;
+ }
+
+ var currentStatus = new Dictionary([
+ ..victims.Select(x => new KeyValuePair(x, CurrentStatus.InQueue)).ToList()
+ ]);
+
+ _ = Task.Run(async () =>
+ {
+ while (true)
+ {
+ var desc = string.Empty;
+
+ lock (currentStatus)
+ {
+ desc = $"{string.Join("\n\n", currentStatus
+ .Select(x =>
+ {
+ var emoji = x.Value switch
+ {
+ CurrentStatus.Invalid => DiscordEmoji.FromUnicode("❌"),
+ CurrentStatus.Added => DiscordEmoji.FromUnicode("✅"),
+ CurrentStatus.Changed => DiscordEmoji.FromUnicode("🔄"),
+ CurrentStatus.InQueue => DiscordEmoji.FromUnicode("🕒"),
+ CurrentStatus.InProgress => EmojiTemplates.GetLoading(ctx.Bot),
+ _ => throw new NotImplementedException(),
+ };
+
+ var text = x.Value switch
+ {
+ CurrentStatus.Invalid => $"**`{x.Key.GetUsernameWithIdentifier()} ({x.Key.Id})`**\n{EmojiTemplates.GetInVisible(ctx.Bot)} `This user cannot be global banned.`",
+ CurrentStatus.Added => $"**`{x.Key.GetUsernameWithIdentifier()} ({x.Key.Id})`**\n{EmojiTemplates.GetInVisible(ctx.Bot)} `User was added to global ban list.`",
+ CurrentStatus.Changed => $"**`{x.Key.GetUsernameWithIdentifier()} ({x.Key.Id})`**\n{EmojiTemplates.GetInVisible(ctx.Bot)} `User was already global banned, updated entry.`",
+ CurrentStatus.InQueue => $"**`{x.Key.GetUsernameWithIdentifier()} ({x.Key.Id})`**\n{EmojiTemplates.GetInVisible(ctx.Bot)} `In queue..`",
+ CurrentStatus.InProgress => $"**`{x.Key.GetUsernameWithIdentifier()} ({x.Key.Id})`**\n{EmojiTemplates.GetInVisible(ctx.Bot)} `Processing..`",
+ _ => throw new NotImplementedException(),
+ };
+
+ return $"{emoji} {text}";
+ }))}";
+ }
+
+ var embed = new DiscordEmbedBuilder();
+
+ var done = true;
+
+ if (currentStatus.All(x => x.Value is CurrentStatus.Changed or CurrentStatus.Added))
+ _ = embed.AsSuccess(ctx, "Global Ban").WithDescription(desc.TruncateWithIndication(2000));
+ else if (currentStatus.All(x => x.Value is CurrentStatus.Changed or CurrentStatus.Added or CurrentStatus.Invalid))
+ _ = embed.AsWarning(ctx, "Global Ban").WithDescription(desc.TruncateWithIndication(2000));
+ else
+ {
+ _ = embed.AsLoading(ctx, "Global Ban").WithDescription($"`Global banning {currentStatus.Count} users..`\n\n{desc}".TruncateWithIndication(2000));
+ done = false;
+ }
+
+ _ = await this.RespondOrEdit(embed);
+
+ if (done)
+ return;
+
+ await Task.Delay(1000);
+ }
+ }).Add(ctx.Bot, ctx);
+
+ foreach (var victim in currentStatus)
+ {
+ currentStatus[victim.Key] = CurrentStatus.InProgress;
+ await Task.Delay(2000);
+
+ if (ctx.Bot.globalBans.ContainsKey(victim.Key.Id))
+ {
+ ctx.Bot.globalBans[victim.Key.Id].Reason = reason;
+ ctx.Bot.globalBans[victim.Key.Id].Moderator = ctx.User.Id;
+ currentStatus[victim.Key] = CurrentStatus.Changed;
+
+ var announceChannel1 = await ctx.Client.GetChannelAsync(ctx.Bot.status.LoadedConfig.Channels.GlobalBanAnnouncements);
+ _ = await announceChannel1.SendMessageAsync(new DiscordEmbedBuilder
+ {
+ Author = new DiscordEmbedBuilder.EmbedAuthor
+ {
+ Name = ctx.CurrentUser.GetUsername(),
+ IconUrl = AuditLogIcons.UserUpdated
+ },
+ Description = $"The global ban entry of {victim.Key.Mention} `{victim.Key.GetUsernameWithIdentifier()}` (`{victim.Key.Id}`) was updated.\n\n" +
+ $"Reason: `{reason.SanitizeForCode()}`\n" +
+ $"Moderator: {ctx.User.Mention} `{ctx.User.GetUsernameWithIdentifier()}` (`{ctx.User.Id}`)",
+ Color = EmbedColors.Warning,
+ Timestamp = DateTime.UtcNow
+ });
+ continue;
+ }
+
+ if (ctx.Bot.status.TeamMembers.Contains(victim.Key.Id))
+ {
+ currentStatus[victim.Key] = CurrentStatus.Invalid;
+ continue;
+ }
+
+ ctx.Bot.globalBans.Add(victim.Key.Id, new(ctx.Bot, "globalbans", victim.Key.Id) { Reason = reason, Moderator = ctx.User.Id });
+
+ var Success = 0;
+ var Failed = 0;
+
+ foreach (var b in ctx.Client.Guilds.OrderByDescending(x => x.Key == ctx.Guild.Id))
+ {
+ if (!ctx.Bot.Guilds.ContainsKey(b.Key))
+ ctx.Bot.Guilds.Add(b.Key, new Guild(ctx.Bot, b.Key));
+
+ if (ctx.Bot.Guilds[b.Key].Join.AutoBanGlobalBans)
+ {
+ try
+ {
+ await b.Value.BanMemberAsync(victim.Key.Id, 7, $"Globalban: {reason}");
+ Success++;
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex, "Exception occurred while trying to ban user from {guild}", b.Key);
+ Failed++;
+ }
+ }
+ }
+
+ currentStatus[victim.Key] = CurrentStatus.Added;
+
+ var announceChannel = await ctx.Client.GetChannelAsync(ctx.Bot.status.LoadedConfig.Channels.GlobalBanAnnouncements);
+ _ = await announceChannel.SendMessageAsync(new DiscordEmbedBuilder
+ {
+ Author = new DiscordEmbedBuilder.EmbedAuthor
+ {
+ Name = ctx.CurrentUser.GetUsername(),
+ IconUrl = AuditLogIcons.UserBanned
+ },
+ Description = $"{victim.Key.Mention} `{victim.Key.GetUsernameWithIdentifier()}` (`{victim.Key.Id}`) was added to the global ban list.\n\n" +
+ $"Reason: `{reason.SanitizeForCode()}`\n" +
+ $"Moderator: {ctx.User.Mention} `{ctx.User.GetUsernameWithIdentifier()}` (`{ctx.User.Id}`)",
+ Color = EmbedColors.Error,
+ Timestamp = DateTime.UtcNow
+ });
+ }
+ });
+ }
+
+ private enum CurrentStatus
+ {
+ InQueue,
+ InProgress,
+ Changed,
+ Added,
+ Invalid
+ }
+}
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/GlobalNotesCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/GlobalNotesCommand.cs
new file mode 100644
index 00000000..912b94cb
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/GlobalNotesCommand.cs
@@ -0,0 +1,121 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class GlobalNotesCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckMaintenance();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ if (await ctx.DbUser.Cooldown.WaitForModerate(ctx, true))
+ return;
+
+ var victim = (DiscordUser)arguments["victim"];
+
+ var ModeratorCache = new Dictionary();
+
+ if (ctx.Bot.globalNotes.TryGetValue(victim.Id, out var globalNotes))
+ foreach (var b in globalNotes.Notes)
+ {
+ if (ModeratorCache.ContainsKey(b.Moderator))
+ continue;
+
+ try
+ {
+ ModeratorCache.Add(b.Moderator, await ctx.Client.GetUserAsync(b.Moderator));
+ }
+ catch (Exception)
+ {
+ ModeratorCache.Add(b.Moderator, null);
+ }
+ }
+
+ var AddButton = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), "Add Notes", false, DiscordEmoji.FromUnicode("➕").ToComponent());
+ var RemoveButton = new DiscordButtonComponent(ButtonStyle.Primary, Guid.NewGuid().ToString(), "Remove Notes", (!ctx.Bot.globalNotes.ContainsKey(victim.Id)), DiscordEmoji.FromUnicode("➖").ToComponent());
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder()
+ .WithEmbed(new DiscordEmbedBuilder()
+ .WithDescription($"{victim.Mention} `has {(ctx.Bot.globalNotes.TryGetValue(victim.Id, out var noteObj) ? noteObj.Notes.Length : 0)} global notes.`")
+ .AddFields((noteObj is not null ? noteObj.Notes.Take(20).Select(x => new DiscordEmbedField(" ", $"{x.Reason.FullSanitize()} - `{(ModeratorCache[x.Moderator] is null ? "Unknown#0000" : ModeratorCache[x.Moderator].GetUsernameWithIdentifier())}` {x.Timestamp.ToTimestamp()}")) : new List())))
+ .AddComponents(new List { AddButton, RemoveButton })
+ .AddComponents(MessageComponents.GetCancelButton(ctx.DbUser, ctx.Bot)));
+
+ var Button = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(2));
+
+ if (Button.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+
+ if (Button.GetCustomId() == AddButton.CustomId)
+ {
+ var ModalResult = await this.PromptModalWithRetry(Button.Result.Interaction,
+ new DiscordInteractionModalBuilder().AddTextComponent(new DiscordTextComponent(TextComponentStyle.Paragraph, "Note", "New Note", "", 1, 256, true)), false);
+
+ if (ModalResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (ModalResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (ModalResult.Errored)
+ {
+ throw ModalResult.Exception;
+ }
+
+ var note = ModalResult.Result.Interaction.GetModalValueByCustomId("Note");
+
+ ctx.Bot.globalNotes[victim.Id].Notes = ctx.Bot.globalNotes[victim.Id].Notes.Add(new GlobalNote.Note() { Moderator = ctx.User.Id, Reason = note });
+
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == RemoveButton.CustomId)
+ {
+ _ = Button.Result.Interaction.CreateResponseAsync(InteractionResponseType.DeferredMessageUpdate);
+
+ var SelectionResult = await this.PromptCustomSelection(ctx.Bot.globalNotes[victim.Id].Notes
+ .Select(x => new DiscordStringSelectComponentOption(x.Reason.TruncateWithIndication(100), x.Timestamp.Ticks.ToString(), $"Added by {(ModeratorCache[x.Moderator] is null ? "Unknown#0000" : ModeratorCache[x.Moderator].GetUsernameWithIdentifier())} {x.Timestamp.GetTimespanSince().GetHumanReadable()} ago")).ToList());
+
+ if (SelectionResult.TimedOut)
+ {
+ this.ModifyToTimedOut(true);
+ return;
+ }
+ else if (SelectionResult.Cancelled)
+ {
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (SelectionResult.Errored)
+ {
+ throw SelectionResult.Exception;
+ }
+
+ ctx.Bot.globalNotes[victim.Id].Notes = ctx.Bot.globalNotes[victim.Id].Notes.Remove(x => x.UUID, ctx.Bot.globalNotes[victim.Id].Notes.First(x => x.Timestamp.Ticks.ToString() == SelectionResult.Result));
+ await this.ExecuteCommand(ctx, arguments);
+ return;
+ }
+ else if (Button.GetCustomId() == MessageComponents.CancelButtonId)
+ {
+ this.DeleteOrInvalidate();
+ return;
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/GlobalUnbanCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/GlobalUnbanCommand.cs
new file mode 100644
index 00000000..4e721ac0
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/GlobalUnbanCommand.cs
@@ -0,0 +1,155 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class GlobalUnbanCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckMaintenance();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var victims = await DiscordExtensions.ParseStringAsUserArray((string)arguments["victims"], ctx.Client);
+ var UnbanFromGuilds = (bool)arguments["UnbanFromGuilds"];
+
+ if (victims?.Length <= 0)
+ {
+ _ = this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription("`Please provide user(s).`").AsError(ctx, "Global Ban"));
+ return;
+ }
+
+ var currentStatus = new Dictionary([
+ ..victims.Select(x => new KeyValuePair(x, CurrentStatus.InQueue)).ToList()
+ ]);
+
+ _ = Task.Run(async () =>
+ {
+ while (true)
+ {
+ var desc = string.Empty;
+
+ lock (currentStatus)
+ {
+ desc = $"{string.Join("\n\n", currentStatus
+ .Select(x =>
+ {
+ var emoji = x.Value switch
+ {
+ CurrentStatus.Invalid => DiscordEmoji.FromUnicode("❌"),
+ CurrentStatus.Removed => DiscordEmoji.FromUnicode("✅"),
+ CurrentStatus.InQueue => DiscordEmoji.FromUnicode("🕒"),
+ CurrentStatus.InProgress => EmojiTemplates.GetLoading(ctx.Bot),
+ _ => throw new NotImplementedException(),
+ };
+
+ var text = x.Value switch
+ {
+ CurrentStatus.Invalid => $"**`{x.Key.GetUsernameWithIdentifier()} ({x.Key.Id})`**\n{EmojiTemplates.GetInVisible(ctx.Bot)} `This user is not on the global ban list.`",
+ CurrentStatus.Removed => $"**`{x.Key.GetUsernameWithIdentifier()} ({x.Key.Id})`**\n{EmojiTemplates.GetInVisible(ctx.Bot)} `User was removed from the global ban list.`",
+ CurrentStatus.InQueue => $"**`{x.Key.GetUsernameWithIdentifier()} ({x.Key.Id})`**\n{EmojiTemplates.GetInVisible(ctx.Bot)} `In queue..`",
+ CurrentStatus.InProgress => $"**`{x.Key.GetUsernameWithIdentifier()} ({x.Key.Id})`**\n{EmojiTemplates.GetInVisible(ctx.Bot)} `Processing..`",
+ _ => throw new NotImplementedException(),
+ };
+
+ return $"{emoji} {text}";
+ }))}";
+ }
+
+ var embed = new DiscordEmbedBuilder();
+
+ var done = true;
+
+ if (currentStatus.All(x => x.Value is CurrentStatus.Removed))
+ _ = embed.AsSuccess(ctx, "Global Ban").WithDescription(desc.TruncateWithIndication(2000));
+ else if (currentStatus.All(x => x.Value is CurrentStatus.Removed or CurrentStatus.Invalid))
+ _ = embed.AsWarning(ctx, "Global Ban").WithDescription(desc.TruncateWithIndication(2000));
+ else
+ {
+ _ = embed.AsLoading(ctx, "Global Ban").WithDescription($"`Removing Global ban for {currentStatus.Count} users..`\n\n{desc}".TruncateWithIndication(2000));
+ done = false;
+ }
+
+ _ = await this.RespondOrEdit(embed);
+
+ if (done)
+ return;
+
+ await Task.Delay(1000);
+ }
+ }).Add(ctx.Bot, ctx);
+
+ foreach (var victim in currentStatus)
+ {
+ currentStatus[victim.Key] = CurrentStatus.InProgress;
+ await Task.Delay(2000);
+
+ if (!ctx.Bot.globalBans.ContainsKey(victim.Key.Id))
+ {
+ currentStatus[victim.Key] = CurrentStatus.Invalid;
+ continue;
+ }
+
+ _ = ctx.Bot.globalBans.Remove(victim.Key.Id);
+ currentStatus[victim.Key] = CurrentStatus.Removed;
+
+ var Success = 0;
+ var Failed = 0;
+
+ if (UnbanFromGuilds)
+ foreach (var b in ctx.Client.Guilds.OrderByDescending(x => x.Key == ctx.Guild.Id))
+ {
+ if (!ctx.Bot.Guilds.ContainsKey(b.Key))
+ ctx.Bot.Guilds.Add(b.Key, new Guild(ctx.Bot, b.Key));
+
+ if (ctx.Bot.Guilds[b.Key].Join.AutoBanGlobalBans)
+ {
+ try
+ {
+ var Ban = await b.Value.GetBanAsync(victim.Key);
+
+ if (Ban.Reason.StartsWith("Globalban: "))
+ await b.Value.UnbanMemberAsync(victim.Key, $"Globalban removed.");
+
+ Success++;
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex, "Exception occurred while trying to unban user from {guild}", b.Key);
+ Failed++;
+ }
+ }
+ }
+
+ var announceChannel = await ctx.Client.GetChannelAsync(ctx.Bot.status.LoadedConfig.Channels.GlobalBanAnnouncements);
+ _ = await announceChannel.SendMessageAsync(new DiscordEmbedBuilder
+ {
+ Author = new DiscordEmbedBuilder.EmbedAuthor
+ {
+ Name = ctx.CurrentUser.GetUsername(),
+ IconUrl = AuditLogIcons.UserBanRemoved
+ },
+ Description = $"{victim.Key.Mention} `{victim.Key.GetUsernameWithIdentifier()}` (`{victim.Key.Id}`) was removed from the global ban list.\n\n" +
+ $"Moderator: {ctx.User.Mention} `{ctx.User.GetUsernameWithIdentifier()}` (`{ctx.User.Id}`)",
+ Color = EmbedColors.Success,
+ Timestamp = DateTime.UtcNow
+ });
+ }
+ });
+ }
+
+ private enum CurrentStatus
+ {
+ InQueue,
+ InProgress,
+ Removed,
+ Invalid
+ }
+}
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/InfoCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/InfoCommand.cs
new file mode 100644
index 00000000..909c60fe
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/InfoCommand.cs
@@ -0,0 +1,211 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class InfoCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckMaintenance();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ if (await ctx.DbUser.Cooldown.WaitForModerate(ctx))
+ return;
+
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription("`Fetching system details..`").AsLoading(ctx));
+
+ Dictionary history = new();
+
+ try
+ {
+ var rawHistory = ctx.Bot.MonitorClient.GetHistory().GroupBy(x => $"{x.Key.Hour}-{(int)Math.Floor(x.Key.Minute / 6d)}");
+ foreach (var entry in rawHistory)
+ {
+ history.Add(entry.Last().Key, new()
+ {
+ Cpu = new()
+ {
+ Load = entry.Average(x => x.Value.Cpu.Load),
+ Temperature = entry.Average(x => x.Value.Cpu.Temperature)
+ },
+ Memory = new()
+ {
+ Available = entry.Average(x => x.Value.Memory.Available),
+ Used = entry.Average(x => x.Value.Memory.Used),
+ }
+ });
+ }
+ }
+ catch {}
+
+ history.Add(DateTime.UtcNow, await ctx.Bot.MonitorClient.GetCurrent());
+ history = history.OrderBy(x => x.Key.Ticks).ToDictionary(x => x.Key, x => x.Value);
+
+ var ServerUptime = "";
+ if (Environment.OSVersion.Platform == PlatformID.Unix)
+ {
+ ProcessStartInfo info = new()
+ {
+ FileName = "bash",
+ Arguments = $"-c uptime",
+ RedirectStandardError = true,
+ RedirectStandardOutput = true,
+ UseShellExecute = false
+ };
+
+ var b = Process.Start(info);
+
+ b.WaitForExit();
+
+ var Output = b.StandardOutput.ReadToEnd();
+ ServerUptime = Output.Remove(Output.IndexOf(','), Output.Length - Output.IndexOf(',')).TrimStart();
+ }
+
+ IEnumerable bFile;
+
+ try
+ {
+ bFile = File.ReadLines("LatestGitPush.cfg");
+ }
+ catch (Exception)
+ {
+ bFile = new List
+ {
+ "Developer Version",
+ "dev",
+ $"{DateTime.UtcNow:dd.MM.yy}",
+ $"{DateTime.UtcNow:HH:mm:ss},00"
+ };
+ }
+
+ var Version = bFile.First().Trim();
+ var Branch = bFile.Skip(1).First().Trim();
+ var Date = bFile.Skip(2).First().Trim().Replace("/", ".");
+
+ var Time = bFile.Skip(3).First().Trim();
+ Time = Time[..Time.IndexOf(',')];
+
+ var miscEmbed = new DiscordEmbedBuilder().WithTitle($"{ctx.CurrentUser.GetUsername()} Details")
+ .AddField(new DiscordEmbedField("Currently running as", $"`{ctx.CurrentUser.GetUsernameWithIdentifier()}`", true))
+ .AddField(new DiscordEmbedField("Process PID", $"`{Environment.ProcessId}`", true))
+ .AddField(new DiscordEmbedField(" ", $" ", true))
+ .AddField(new DiscordEmbedField("Bot uptime", $"`{Math.Round((DateTime.UtcNow - ctx.Bot.status.startupTime).TotalHours, 2)} hours`", true))
+ .AddField(new DiscordEmbedField("Discord API Latency", $"`{ctx.Client.Ping}ms`", true))
+ .AddField(new DiscordEmbedField("Server uptime", $"`{(ServerUptime.IsNullOrWhiteSpace() ? "Currently unavailable" : ServerUptime)}`", true))
+ .AddField(new DiscordEmbedField("Currently running software", $"`Project Makoto by {(await ctx.Client.GetUserAsync(411950662662881290)).GetUsernameWithIdentifier()} ({Version} ({Branch}) built on the {Date} at {Time})`"))
+ .AddField(new DiscordEmbedField("Current bot library and version", $"[`{ctx.Client.BotLibrary} {ctx.Client.VersionString}`](https://github.com/Aiko-IT-Systems/DisCatSharp)"))
+ .AddField(new DiscordEmbedField("Plugin Status",
+ $"{(ctx.Bot.status.LoadedConfig.EnablePlugins && ctx.Bot.Plugins.Count > 0 ?
+ $"`{ctx.Bot.Plugins.Count}/{new DirectoryInfo("Plugins")?.GetFiles()?.Where(x => !x.Name.StartsWith('.') && x.Extension == ".pmpl")?.Count() ?? 0} loaded`\n\n" +
+ $"{string.Join("\n", ctx.Bot.Plugins.Select(x => $"- {x.Value.OfficialPlugin.ToEmote(ctx.Bot)} `{x.Value.Name}` `v{x.Value.Version}` by {x.Value.AuthorUser?.Mention ?? "`N/A`"} (`{x.Value.Author}`)"))}" :
+ "`Disabled`")}"))
+ .AsInfo(ctx).WithFooter().WithTimestamp(null);
+
+ var cpuEmbed1 = new DiscordEmbedBuilder()
+ .WithTitle("CPU")
+ .AddField(new DiscordEmbedField("Load", $"`{history.MaxBy(x => x.Key).Value.Cpu.Load.ToString("N0", CultureInfo.CreateSpecificCulture("en-US")),3}%`", true))
+ .AddField(new DiscordEmbedField("Temperature", $"`{history.MaxBy(x => x.Key).Value.Cpu.Temperature.ToString("N0", CultureInfo.CreateSpecificCulture("en-US")),2}°C`", true))
+ .AsLoading(ctx).WithFooter().WithTimestamp(null).WithAuthor();
+
+ var memoryEmbed = new DiscordEmbedBuilder()
+ .WithTitle("Memory")
+ .AddField(new DiscordEmbedField("Usage", $"`{history.MaxBy(x => x.Key).Value.Memory.Used.ToString("N0", CultureInfo.CreateSpecificCulture("en-US"))}/{history.MaxBy(x => x.Key).Value.Memory.Total.ToString("N0", CultureInfo.CreateSpecificCulture("en-US"))} MB`", true))
+ .AsLoading(ctx);
+
+ var embeds = new List() { miscEmbed };
+
+ if (ctx.Bot.status.LoadedConfig.MonitorSystem.Enabled)
+ embeds.AddRange(cpuEmbed1, memoryEmbed);
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().AddEmbeds(embeds));
+
+ if (!ctx.Bot.status.LoadedConfig.MonitorSystem.Enabled)
+ return;
+
+ Dictionary charts = new();
+
+ try
+ {
+ var prev = "";
+ var qc = ctx.Bot.ChartsClient.GetChart(800, 600, history.Select(x =>
+ {
+ var value = x.Key.ToString("HH:mm");
+ if (prev == value)
+ return " ";
+ prev = value;
+ return $"{value}";
+ }), new ChartGeneration.Dataset[]
+ {
+ new("Usage (%)", history.Select(x => $"{(int)x.Value.Cpu.Load}"), "getGradientFillHelper('vertical', ['#ff0000', '#00ff00'])"),
+ new("Temperature (°C)", history.Select(x => $"{(int)x.Value.Cpu.Temperature}"), "getGradientFillHelper('vertical', ['#4287f5', '#ff0000'])"),
+ }, 0, 100);
+
+ charts.Add("cpu.png", qc.ToByteArray());
+ cpuEmbed1.ImageUrl = "attachment://cpu.png";
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex, "Failed to generate cpu usage graph");
+ cpuEmbed1.ImageUrl = "attachment://1.png";
+ }
+ finally
+ {
+ _ = cpuEmbed1.AsInfo(ctx).WithFooter().WithTimestamp(null).WithAuthor();
+ }
+
+ try
+ {
+ var prev = "";
+ var qc = ctx.Bot.ChartsClient.GetChart(800, 600, history.Select(x =>
+ {
+ var value = x.Key.ToString("HH:mm");
+ if (prev == value)
+ return " ";
+ prev = value;
+ return $"{value}";
+ }),
+ new ChartGeneration.Dataset[]
+ {
+ new("Usage (MB)", history.Select(x => $"{(int)x.Value.Memory.Used}"))
+ }, 0, (int)history.First().Value.Memory.Total);
+
+ charts.Add("mem.png", qc.ToByteArray());
+ memoryEmbed.ImageUrl = "attachment://mem.png";
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex, "Failed to generate memory graph");
+ memoryEmbed.ImageUrl = "attachment://1.png";
+ }
+ finally
+ {
+ _ = memoryEmbed.AsInfo(ctx).WithAuthor();
+ }
+
+ var list = new List();
+ list.Add(miscEmbed.WithImageUrl("attachment://1.png"));
+ list.Add(cpuEmbed1);
+ list.Add(memoryEmbed);
+
+ var files = charts.ToDictionary(x => x.Key, y => (Stream)new MemoryStream(y.Value));
+ try
+ {
+ files.Add("1.png", new FileStream("Assets/1.png", FileMode.Open));
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().AddEmbeds(new DiscordEmbed[] { miscEmbed.Build(), cpuEmbed1.Build(), memoryEmbed.Build() }).WithFiles(files));
+ }
+ finally
+ {
+ foreach (var file in files)
+ file.Value.Dispose();
+ }
+ });
+ }
+}
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/LogCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/LogCommand.cs
new file mode 100644
index 00000000..25d82f63
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/LogCommand.cs
@@ -0,0 +1,29 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class LogCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckMaintenance();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var Level = (int)arguments["Level"];
+
+ if (Level is > ((int)LogEventLevel.Fatal) or < ((int)LogEventLevel.Verbose))
+ throw new Exception("Invalid Log Level");
+
+ ctx.Bot.loggingLevel.MinimumLevel = (LogEventLevel)Level;
+ _ = await this.RespondOrEdit($"`Changed LogLevel to '{Enum.GetName((LogEventLevel)Level)}'`");
+ });
+ }
+}
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/Quit2FASessionCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/Quit2FASessionCommand.cs
new file mode 100644
index 00000000..45215090
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/Quit2FASessionCommand.cs
@@ -0,0 +1,25 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class Quit2FASessionCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx)
+ => this.CheckMaintenance();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ ctx.DbUser.LastSuccessful2FA = DateTime.MinValue;
+ _ = await this.RespondOrEdit(new DiscordEmbedBuilder().WithDescription("`Your active 2FA Session, if present, has been quit.`").AsSuccess(ctx));
+ });
+ }
+}
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/RawGuildCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/RawGuildCommand.cs
new file mode 100644
index 00000000..4ecf0205
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/RawGuildCommand.cs
@@ -0,0 +1,29 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class RawGuildCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckMaintenance();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var guild = (ulong?)arguments["guild"];
+ guild ??= ctx.Guild.Id;
+
+ _ = await this.RespondOrEdit(new DiscordMessageBuilder().WithFile("guild.json", JsonConvert.SerializeObject(ctx.Bot.Guilds[guild.Value], Formatting.Indented, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
+ }).ToStream()));
+ });
+ }
+}
\ No newline at end of file
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/StopCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/StopCommand.cs
new file mode 100644
index 00000000..c8b032f5
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/StopCommand.cs
@@ -0,0 +1,35 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class StopCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckMaintenance();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary arguments)
+ {
+ return Task.Run(async () =>
+ {
+ var msg = await this.RespondOrEdit(new DiscordMessageBuilder().WithContent("Confirm?").AddComponents(new DiscordButtonComponent(ButtonStyle.Danger, "Shutdown", "Confirm shutdown", false, new DiscordComponentEmoji(DiscordEmoji.FromUnicode("⛔")))));
+
+ var x = await ctx.WaitForButtonAsync(TimeSpan.FromMinutes(1));
+
+ if (x.TimedOut)
+ {
+ _ = await this.RespondOrEdit("_Interaction timed out._");
+ return;
+ }
+
+ _ = await this.RespondOrEdit("Shutting down!");
+
+ await ctx.Bot.ExitApplication(true);
+ });
+ }
+}
diff --git a/ProjectMakoto/Commands/Maintainers/DevTools/UnbanGuildCommand.cs b/ProjectMakoto/Commands/Maintainers/DevTools/UnbanGuildCommand.cs
new file mode 100644
index 00000000..f7c46976
--- /dev/null
+++ b/ProjectMakoto/Commands/Maintainers/DevTools/UnbanGuildCommand.cs
@@ -0,0 +1,32 @@
+// Project Makoto
+// Copyright (C) 2024 Fortunevale
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY
+
+namespace ProjectMakoto.Commands.DevTools;
+
+internal sealed class UnbanGuildCommand : BaseCommand
+{
+ public override Task BeforeExecution(SharedCommandContext ctx) => this.CheckMaintenance();
+
+ public override Task ExecuteCommand(SharedCommandContext ctx, Dictionary