mirror of
https://github.com/eRgo35/lyra.git
synced 2026-02-04 20:36:10 +01:00
Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 66052e4f74 | |||
| 09b0d6fd9d | |||
| c27d1f70da | |||
| 73b885e5d6 | |||
| 8c0eb62d41 | |||
| 5bc86aca2b | |||
|
|
57a281a1d3 | ||
|
2f4045d4a9
|
|||
|
aa215daf28
|
|||
|
7fde11f615
|
|||
|
c8f86a2f9c
|
|||
| d9b6c8fc4b | |||
|
|
051ae857a7 | ||
|
08fbdc828c
|
|||
|
aeb10d9baf
|
|||
|
af247aa6d5
|
|||
| eae957c6d7 | |||
|
5399f3ba6d
|
|||
|
076dfd0a93
|
|||
|
212abd9bdd
|
|||
|
8d787f2a11
|
|||
|
486f403d10
|
|||
|
bfd301c9c2
|
|||
|
670b8dd30e
|
|||
|
c607aaf403
|
|||
|
f41fa7e09b
|
|||
|
10b7d4d7e3
|
|||
|
772d5d2a97
|
|||
|
f1b52d2be2
|
|||
|
e77818e09b
|
|||
|
5a026afc52
|
|||
|
8a0d08de4e
|
|||
|
f224ccfbdf
|
|||
|
d0af34833b
|
|||
|
c2e653b3ea
|
|||
|
78a1937210
|
|||
|
fc42427437
|
|||
|
9474577233
|
|||
|
b86e8b9daf
|
|||
|
ef29e5319a
|
|||
|
ee3d9a0c45
|
|||
|
4e92771f8f
|
|||
|
8a947926f7
|
|||
|
639fd7775f
|
|||
|
8fa86b0182
|
|||
|
d75c5bc9a2
|
|||
|
21822405c0
|
|||
|
3b0121699f
|
|||
|
a27e95a88d
|
|||
|
6946ddc9f1
|
|||
|
21fe190921
|
|||
|
4a0184811e
|
2
.env.example
Normal file
2
.env.example
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
DISCORD_TOKEN=<YOUR_DISCORD_TOKEN>
|
||||||
|
PREFIX=<YOUR_PREFIX>
|
||||||
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
github: eRgo35
|
||||||
22
.github/workflows/ci.yml
vendored
Normal file
22
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
name: Rust
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "senpai" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "senpai" ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Build
|
||||||
|
run: cargo build --verbose
|
||||||
|
- name: Run tests
|
||||||
|
run: cargo test --verbose
|
||||||
27
.github/workflows/release-plz.yml
vendored
Normal file
27
.github/workflows/release-plz.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
name: Release Plz
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- senpai
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release-plz:
|
||||||
|
name: Release-plz
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Install Rust toolchain
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
- name: Run release-plz
|
||||||
|
uses: MarcoIeni/release-plz-action@v0.5
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
|
||||||
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||||
281
.github/workflows/release.yml
vendored
Normal file
281
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,281 @@
|
|||||||
|
# Copyright 2022-2024, axodotdev
|
||||||
|
# SPDX-License-Identifier: MIT or Apache-2.0
|
||||||
|
#
|
||||||
|
# CI that:
|
||||||
|
#
|
||||||
|
# * checks for a Git Tag that looks like a release
|
||||||
|
# * builds artifacts with cargo-dist (archives, installers, hashes)
|
||||||
|
# * uploads those artifacts to temporary workflow zip
|
||||||
|
# * on success, uploads the artifacts to a GitHub Release
|
||||||
|
#
|
||||||
|
# Note that the GitHub Release will be created with a generated
|
||||||
|
# title/body based on your changelogs.
|
||||||
|
|
||||||
|
name: Release
|
||||||
|
permissions:
|
||||||
|
"contents": "write"
|
||||||
|
|
||||||
|
# This task will run whenever you push a git tag that looks like a version
|
||||||
|
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
|
||||||
|
# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where
|
||||||
|
# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION
|
||||||
|
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
|
||||||
|
#
|
||||||
|
# If PACKAGE_NAME is specified, then the announcement will be for that
|
||||||
|
# package (erroring out if it doesn't have the given version or isn't cargo-dist-able).
|
||||||
|
#
|
||||||
|
# If PACKAGE_NAME isn't specified, then the announcement will be for all
|
||||||
|
# (cargo-dist-able) packages in the workspace with that version (this mode is
|
||||||
|
# intended for workspaces with only one dist-able package, or with all dist-able
|
||||||
|
# packages versioned/released in lockstep).
|
||||||
|
#
|
||||||
|
# If you push multiple tags at once, separate instances of this workflow will
|
||||||
|
# spin up, creating an independent announcement for each one. However, GitHub
|
||||||
|
# will hard limit this to 3 tags per commit, as it will assume more tags is a
|
||||||
|
# mistake.
|
||||||
|
#
|
||||||
|
# If there's a prerelease-style suffix to the version, then the release(s)
|
||||||
|
# will be marked as a prerelease.
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '**[0-9]+.[0-9]+.[0-9]+*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# Run 'cargo dist plan' (or host) to determine what tasks we need to do
|
||||||
|
plan:
|
||||||
|
runs-on: "ubuntu-20.04"
|
||||||
|
outputs:
|
||||||
|
val: ${{ steps.plan.outputs.manifest }}
|
||||||
|
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
|
||||||
|
tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }}
|
||||||
|
publishing: ${{ !github.event.pull_request }}
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: Install cargo-dist
|
||||||
|
# we specify bash to get pipefail; it guards against the `curl` command
|
||||||
|
# failing. otherwise `sh` won't catch that `curl` returned non-0
|
||||||
|
shell: bash
|
||||||
|
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.20.0/cargo-dist-installer.sh | sh"
|
||||||
|
- name: Cache cargo-dist
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: cargo-dist-cache
|
||||||
|
path: ~/.cargo/bin/cargo-dist
|
||||||
|
# sure would be cool if github gave us proper conditionals...
|
||||||
|
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
|
||||||
|
# functionality based on whether this is a pull_request, and whether it's from a fork.
|
||||||
|
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
|
||||||
|
# but also really annoying to build CI around when it needs secrets to work right.)
|
||||||
|
- id: plan
|
||||||
|
run: |
|
||||||
|
cargo dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
|
||||||
|
echo "cargo dist ran successfully"
|
||||||
|
cat plan-dist-manifest.json
|
||||||
|
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
|
||||||
|
- name: "Upload dist-manifest.json"
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: artifacts-plan-dist-manifest
|
||||||
|
path: plan-dist-manifest.json
|
||||||
|
|
||||||
|
# Build and packages all the platform-specific things
|
||||||
|
build-local-artifacts:
|
||||||
|
name: build-local-artifacts (${{ join(matrix.targets, ', ') }})
|
||||||
|
# Let the initial task tell us to not run (currently very blunt)
|
||||||
|
needs:
|
||||||
|
- plan
|
||||||
|
if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
# Target platforms/runners are computed by cargo-dist in create-release.
|
||||||
|
# Each member of the matrix has the following arguments:
|
||||||
|
#
|
||||||
|
# - runner: the github runner
|
||||||
|
# - dist-args: cli flags to pass to cargo dist
|
||||||
|
# - install-dist: expression to run to install cargo-dist on the runner
|
||||||
|
#
|
||||||
|
# Typically there will be:
|
||||||
|
# - 1 "global" task that builds universal installers
|
||||||
|
# - N "local" tasks that build each platform's binaries and platform-specific installers
|
||||||
|
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
|
||||||
|
steps:
|
||||||
|
- name: enable windows longpaths
|
||||||
|
run: |
|
||||||
|
git config --global core.longpaths true
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: Install cargo-dist
|
||||||
|
run: ${{ matrix.install_dist }}
|
||||||
|
# Get the dist-manifest
|
||||||
|
- name: Fetch local artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
pattern: artifacts-*
|
||||||
|
path: target/distrib/
|
||||||
|
merge-multiple: true
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
${{ matrix.packages_install }}
|
||||||
|
- name: Build artifacts
|
||||||
|
run: |
|
||||||
|
# Actually do builds and make zips and whatnot
|
||||||
|
cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
|
||||||
|
echo "cargo dist ran successfully"
|
||||||
|
- id: cargo-dist
|
||||||
|
name: Post-build
|
||||||
|
# We force bash here just because github makes it really hard to get values up
|
||||||
|
# to "real" actions without writing to env-vars, and writing to env-vars has
|
||||||
|
# inconsistent syntax between shell and powershell.
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
# Parse out what we just built and upload it to scratch storage
|
||||||
|
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
|
||||||
|
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
|
||||||
|
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
|
||||||
|
- name: "Upload artifacts"
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: artifacts-build-local-${{ join(matrix.targets, '_') }}
|
||||||
|
path: |
|
||||||
|
${{ steps.cargo-dist.outputs.paths }}
|
||||||
|
${{ env.BUILD_MANIFEST_NAME }}
|
||||||
|
|
||||||
|
# Build and package all the platform-agnostic(ish) things
|
||||||
|
build-global-artifacts:
|
||||||
|
needs:
|
||||||
|
- plan
|
||||||
|
- build-local-artifacts
|
||||||
|
runs-on: "ubuntu-20.04"
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: Install cached cargo-dist
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: cargo-dist-cache
|
||||||
|
path: ~/.cargo/bin/
|
||||||
|
- run: chmod +x ~/.cargo/bin/cargo-dist
|
||||||
|
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
|
||||||
|
- name: Fetch local artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
pattern: artifacts-*
|
||||||
|
path: target/distrib/
|
||||||
|
merge-multiple: true
|
||||||
|
- id: cargo-dist
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
|
||||||
|
echo "cargo dist ran successfully"
|
||||||
|
|
||||||
|
# Parse out what we just built and upload it to scratch storage
|
||||||
|
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
|
||||||
|
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
|
||||||
|
echo "EOF" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
|
||||||
|
- name: "Upload artifacts"
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: artifacts-build-global
|
||||||
|
path: |
|
||||||
|
${{ steps.cargo-dist.outputs.paths }}
|
||||||
|
${{ env.BUILD_MANIFEST_NAME }}
|
||||||
|
# Determines if we should publish/announce
|
||||||
|
host:
|
||||||
|
needs:
|
||||||
|
- plan
|
||||||
|
- build-local-artifacts
|
||||||
|
- build-global-artifacts
|
||||||
|
# Only run if we're "publishing", and only if local and global didn't fail (skipped is fine)
|
||||||
|
if: ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }}
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
runs-on: "ubuntu-20.04"
|
||||||
|
outputs:
|
||||||
|
val: ${{ steps.host.outputs.manifest }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
- name: Install cached cargo-dist
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: cargo-dist-cache
|
||||||
|
path: ~/.cargo/bin/
|
||||||
|
- run: chmod +x ~/.cargo/bin/cargo-dist
|
||||||
|
# Fetch artifacts from scratch-storage
|
||||||
|
- name: Fetch artifacts
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
pattern: artifacts-*
|
||||||
|
path: target/distrib/
|
||||||
|
merge-multiple: true
|
||||||
|
- id: host
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
|
||||||
|
echo "artifacts uploaded and released successfully"
|
||||||
|
cat dist-manifest.json
|
||||||
|
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
|
||||||
|
- name: "Upload dist-manifest.json"
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
# Overwrite the previous copy
|
||||||
|
name: artifacts-dist-manifest
|
||||||
|
path: dist-manifest.json
|
||||||
|
# Create a GitHub Release while uploading all files to it
|
||||||
|
- name: "Download GitHub Artifacts"
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
pattern: artifacts-*
|
||||||
|
path: artifacts
|
||||||
|
merge-multiple: true
|
||||||
|
- name: Cleanup
|
||||||
|
run: |
|
||||||
|
# Remove the granular manifests
|
||||||
|
rm -f artifacts/*-dist-manifest.json
|
||||||
|
- name: Create GitHub Release
|
||||||
|
env:
|
||||||
|
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
|
||||||
|
ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
|
||||||
|
ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
|
||||||
|
RELEASE_COMMIT: "${{ github.sha }}"
|
||||||
|
run: |
|
||||||
|
# Write and read notes from a file to avoid quoting breaking things
|
||||||
|
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
|
||||||
|
|
||||||
|
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
|
||||||
|
|
||||||
|
announce:
|
||||||
|
needs:
|
||||||
|
- plan
|
||||||
|
- host
|
||||||
|
# use "always() && ..." to allow us to wait for all publish jobs while
|
||||||
|
# still allowing individual publish jobs to skip themselves (for prereleases).
|
||||||
|
# "host" however must run to completion, no skipping allowed!
|
||||||
|
if: ${{ always() && needs.host.result == 'success' }}
|
||||||
|
runs-on: "ubuntu-20.04"
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
/target
|
/target
|
||||||
|
**/target
|
||||||
.env
|
.env
|
||||||
|
|||||||
23
CHANGELOG.md
Normal file
23
CHANGELOG.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Changelog
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.10.4](https://github.com/eRgo35/lyra/compare/v0.10.3...v0.10.4) - 2024-08-13
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- added wip info for some commands
|
||||||
|
|
||||||
|
### Other
|
||||||
|
- cargo-dist action setup
|
||||||
|
- repo added to Cargo.toml
|
||||||
|
- using cargo-dist for package building
|
||||||
|
|
||||||
|
## [0.10.3](https://github.com/eRgo35/lyra/compare/v0.10.2...v0.10.3) - 2024-08-13
|
||||||
|
|
||||||
|
### Other
|
||||||
|
- release-plz
|
||||||
|
# Changelog
|
||||||
2028
Cargo.lock
generated
2028
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
73
Cargo.toml
73
Cargo.toml
@@ -1,17 +1,74 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "lyra"
|
name = "lyra"
|
||||||
version = "0.2.0"
|
version = "0.10.6"
|
||||||
|
authors = ["Michał Czyż <mike@c2yz.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
description = "A featureful Discord bot written in Rust."
|
||||||
|
documentation = "https://github.com/eRgo35/lyra"
|
||||||
|
repository = "https://github.com/eRgo35/lyra"
|
||||||
|
readme = "README.md"
|
||||||
|
homepage = "https://lyra.c2yz.com"
|
||||||
|
license-file = "LICENSE.md"
|
||||||
|
keywords = ["discord", "bot", "rust", "music", "featureful"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
spotify-parser = "1.0.1"
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
openssl = { version = "0.10.63", features = ["vendored"] }
|
json = "0.12.4"
|
||||||
regex = "1.10.3"
|
openssl = { version = "0.10.66", features = ["vendored"] }
|
||||||
reqwest = "0.11.23"
|
owoify = "0.1.5"
|
||||||
serenity = { version = "0.12.0", features = ["cache", "framework", "standard_framework", "voice"] }
|
poise = { default-features = true, version = "0.6.1" }
|
||||||
songbird = { version = "0.4.0", features = ["builtin-queue", "serenity"] }
|
rand = "0.8.5"
|
||||||
symphonia = "0.5.3"
|
regex = "1.10.6"
|
||||||
tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread", "signal"] }
|
reqwest = { version = "0.11.27", features = ["json"] }
|
||||||
|
serde = { version = "1.0.204", features = ["derive"] }
|
||||||
|
serde_json = "1.0.122"
|
||||||
|
songbird = { version = "~0.4.3", default-features = true, features = [
|
||||||
|
"builtin-queue",
|
||||||
|
], git = "https://github.com/eRgo35/songbird" }
|
||||||
|
serenity = { default-features = true, features = [
|
||||||
|
"cache",
|
||||||
|
"framework",
|
||||||
|
"standard_framework",
|
||||||
|
"voice",
|
||||||
|
"http",
|
||||||
|
"rustls_backend",
|
||||||
|
], version = "0.12" }
|
||||||
|
symphonia = { version = "0.5.4", features = [
|
||||||
|
"aac",
|
||||||
|
"adpcm",
|
||||||
|
"alac",
|
||||||
|
"flac",
|
||||||
|
"mpa",
|
||||||
|
"isomp4",
|
||||||
|
] }
|
||||||
|
tokio = { version = "1.39.2", features = ["macros", "full", "signal"] }
|
||||||
tracing = "0.1.40"
|
tracing = "0.1.40"
|
||||||
tracing-futures = "0.2.5"
|
tracing-futures = "0.2.5"
|
||||||
tracing-subscriber = "0.3.18"
|
tracing-subscriber = "0.3.18"
|
||||||
|
url = "2.5.2"
|
||||||
|
once_cell = "1.19.0"
|
||||||
|
|
||||||
|
[patch.crates-io.serenity-voice-model]
|
||||||
|
git = "https://github.com/serenity-rs/serenity"
|
||||||
|
branch = "current"
|
||||||
|
|
||||||
|
# The profile that 'cargo dist' will build with
|
||||||
|
[profile.dist]
|
||||||
|
inherits = "release"
|
||||||
|
lto = "thin"
|
||||||
|
|
||||||
|
# Config for 'cargo dist'
|
||||||
|
[workspace.metadata.dist]
|
||||||
|
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
|
||||||
|
cargo-dist-version = "0.20.0"
|
||||||
|
# CI backends to support
|
||||||
|
ci = "github"
|
||||||
|
# The installers to generate for each app
|
||||||
|
installers = ["shell"]
|
||||||
|
# Target platforms to build apps for (Rust target-triple syntax)
|
||||||
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
# Path that installers should place binaries in
|
||||||
|
install-path = "CARGO_HOME"
|
||||||
|
# Whether to install an updater program
|
||||||
|
install-updater = false
|
||||||
|
|||||||
19
Dockerfile
19
Dockerfile
@@ -1,19 +0,0 @@
|
|||||||
FROM rust:1.71-alpine
|
|
||||||
|
|
||||||
RUN apk add --update \
|
|
||||||
alpine-sdk \
|
|
||||||
ffmpeg \
|
|
||||||
youtube-dl \
|
|
||||||
pkgconfig \
|
|
||||||
cmake \
|
|
||||||
openssl-dev \
|
|
||||||
musl-dev \
|
|
||||||
openssl
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
RUN cargo build --release
|
|
||||||
|
|
||||||
CMD ["./target/release/lyra"]
|
|
||||||
22
LICENSE.md
22
LICENSE.md
@@ -1,5 +1,21 @@
|
|||||||
# License
|
MIT License
|
||||||
|
|
||||||
Copyright(c) Michał Czyż 2024
|
Copyright (c) 2024 Michał Czyż
|
||||||
|
|
||||||
[Currently] All Rights Reserved.
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|||||||
120
README.md
120
README.md
@@ -1,12 +1,120 @@
|
|||||||
# Lyra
|
<h2 align="center">
|
||||||
|
<a href="https://lyra.c2yz.com" target="blank_">
|
||||||
|
<img height="256" alt="Lyra" src="assets/lyra-256.png" />
|
||||||
|
</a>
|
||||||
|
<br />
|
||||||
|
Lyra: a discord music bot written in rust :crab:
|
||||||
|
</h2>
|
||||||
|
|
||||||

|
Lyra is an open source, discord music bot written in Rust.
|
||||||
|
The idea behind this project is to allow a user to self-host one's own instance of the bot.
|
||||||
|
User no longer has to rely on 3rd-parties to provide them a service.
|
||||||
|
The bot can be run on a desktop, a vps or a phone as it's just a simple binary.
|
||||||
|
|
||||||
Lyra is a music bot written in Rust.
|
Currently bot is still heavily in development!
|
||||||
More features coming soon!
|
|
||||||
|
|
||||||
## Getting Started
|
## Getting started
|
||||||
|
|
||||||
## Building
|
Before you start, you need to create a discord bot and get a token.
|
||||||
|
You can do it [here](https://discord.com/developers/applications).
|
||||||
|
|
||||||
|
After you create a bot, you need to invite it to your server.
|
||||||
|
|
||||||
|
Then, head to download section and download the latest release (or compile it yourself).
|
||||||
|
|
||||||
|
After you download the binary, you need to create a `.env` file in the same directory as the binary.
|
||||||
|
Example can be found in `.env.example` file.
|
||||||
|
|
||||||
|
```
|
||||||
|
DISCORD_TOKEN=<YOUR_DISCORD_TOKEN>
|
||||||
|
PREFIX=<YOUR_PREFIX>
|
||||||
|
```
|
||||||
|
|
||||||
|
DISCORD_TOKEN is the token you got from discord developers page and PREFIX is the prefix you want to use for your bot.
|
||||||
|
|
||||||
|
Bot by default reacts only to the prefix. To enable slash commands, while the bot is running type `:register` in the chat (where `:` is your bot prefix).
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Music playback
|
||||||
|
- Audio effects (soon)
|
||||||
|
- Some multipurpose commands
|
||||||
|
- Slash commands
|
||||||
|
- Self-hosted
|
||||||
|
|
||||||
|
## Compilation
|
||||||
|
|
||||||
|
To compile the source code on your own, you need `rust` and `cargo`
|
||||||
|
|
||||||
|
To run a dev version, `cd` into the project directory and type
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ cargo run
|
||||||
|
```
|
||||||
|
|
||||||
|
To build a production version use
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ cargo build --release
|
||||||
|
```
|
||||||
|
|
||||||
|
If you need a version for a different system or architecture, you can use `cross` crate
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ cross build -r --target aarch64-unknown-linux-gnu
|
||||||
|
```
|
||||||
|
|
||||||
|
To run a program, just type
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ ./lyra
|
||||||
|
```
|
||||||
|
|
||||||
|
Remember to provide a `.env` file in the same directory as the binary.
|
||||||
|
|
||||||
|
If you want to disown the bot from the shell, I recommend using the script I provided in `scripts` folder
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
|
As of now, the commands are:
|
||||||
|
|
||||||
|
```
|
||||||
|
Music:
|
||||||
|
/deafen Deafens itself while in a voice channel; aliases: deafen, undeaden, shuush
|
||||||
|
/join Joins your voice channel
|
||||||
|
/leave Leaves the voice channel; aliases: leave, qa!
|
||||||
|
/mute Mutes itself while in a voice channel; aliases: mute, unmute, shhh
|
||||||
|
/pause Pauses the currently playing song
|
||||||
|
/play Plays a song; you can search by query or paste an url; aliases: play, p, enqueue
|
||||||
|
/queue Shows next tracks in queue; aliases: queue, q
|
||||||
|
/repeat Loops currently playing song provided amount of times; aliases: repeat, loop, while, for
|
||||||
|
/resume Resumes currently paused song
|
||||||
|
/seek Seeks a track by provided seconds
|
||||||
|
/skip Skips the currently playing song; aliases: skip, :skipper:
|
||||||
|
/stop Stops playback and destroys the queue; aliases: stop, end
|
||||||
|
/volume Changes output volume
|
||||||
|
/effect Plays one of available audio effects
|
||||||
|
/stream Hijacks output and plays audio; search by query or paste an url; aliases: stream, override, hijack
|
||||||
|
|
||||||
|
Tools:
|
||||||
|
/ai Asks AI
|
||||||
|
/dice Rolls a dice
|
||||||
|
/dictionary Explains provided query
|
||||||
|
/ip Shows IP information
|
||||||
|
/metar Prints metar for provided airport
|
||||||
|
/owoify Owoifies whatever you want uwu
|
||||||
|
/ping Pings you backs with a response time
|
||||||
|
/posix Prints current time in POSIX format
|
||||||
|
/qr Creates a qr code from text
|
||||||
|
/taf Returns taf for provided airport
|
||||||
|
/uptime Checks how long the bot has been running
|
||||||
|
/verse Reference Bible by verse
|
||||||
|
/weather Shows weather for provided location
|
||||||
|
|
||||||
|
Help:
|
||||||
|
/help Prints this help message; aliases: help, huh, welp
|
||||||
|
|
||||||
|
Use /help command for more info on a command.
|
||||||
|
You can edit you message to the bot and the bot will edit its response.
|
||||||
|
|
||||||
|
```
|
||||||
|
|||||||
BIN
assets/lyra-nightly.png
Normal file
BIN
assets/lyra-nightly.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 291 KiB |
@@ -1,6 +0,0 @@
|
|||||||
version: '2'
|
|
||||||
|
|
||||||
services:
|
|
||||||
melvinjs:
|
|
||||||
container_name: lyra
|
|
||||||
build: .
|
|
||||||
3
scripts/cross-build.sh
Executable file
3
scripts/cross-build.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cross build -r --target aarch64-unknown-linux-gnu
|
||||||
3
scripts/launch.sh
Executable file
3
scripts/launch.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
nohup ./lyra > lyra.log 2> lyra.err < /dev/null &
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
pub mod kashi;
|
pub mod embeds;
|
||||||
pub mod misc;
|
|
||||||
pub mod music;
|
pub mod music;
|
||||||
pub mod tools;
|
pub mod tools;
|
||||||
56
src/commands/embeds.rs
Normal file
56
src/commands/embeds.rs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
use crate::{Context, Error};
|
||||||
|
|
||||||
|
use poise::serenity_prelude::{
|
||||||
|
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
|
||||||
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
|
pub async fn fail(ctx: Context<'_>, err: String) -> Result<(), Error> {
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default().embed(
|
||||||
|
error_embed(ctx, &format!("Failed: {:?}", err))
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn error_embed(ctx: Context<'_>, msg: &str) -> Result<CreateEmbed, Error> {
|
||||||
|
let embed = CreateEmbed::default()
|
||||||
|
.author(
|
||||||
|
CreateEmbedAuthor::new("Something went wrong!").icon_url(ctx.author().clone().face()),
|
||||||
|
)
|
||||||
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
|
.title("Oopsie, Doopsie!")
|
||||||
|
.description(msg)
|
||||||
|
.timestamp(Timestamp::now())
|
||||||
|
.footer(
|
||||||
|
CreateEmbedFooter::new(ctx.cache().current_user().name.to_string())
|
||||||
|
.icon_url(ctx.cache().current_user().face()),
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(embed)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn embed(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
author: &str,
|
||||||
|
description: &str,
|
||||||
|
title: &str,
|
||||||
|
) -> Result<CreateEmbed, Error> {
|
||||||
|
let embed = CreateEmbed::default()
|
||||||
|
.author(CreateEmbedAuthor::new(author).icon_url(ctx.author().clone().face()))
|
||||||
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
|
.title(title)
|
||||||
|
.description(description)
|
||||||
|
.timestamp(Timestamp::now())
|
||||||
|
.footer(
|
||||||
|
CreateEmbedFooter::new(ctx.cache().current_user().name.to_string())
|
||||||
|
.icon_url(ctx.cache().current_user().face()),
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(embed)
|
||||||
|
}
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
use serenity::{all::Message, client::Context, framework::standard::{macros::command, CommandResult}};
|
|
||||||
|
|
||||||
use crate::commands::misc::check_msg;
|
|
||||||
|
|
||||||
#[command]
|
|
||||||
async fn kashi(ctx: &Context, msg: &Message) -> CommandResult {
|
|
||||||
check_msg(msg.reply(ctx, "Kashi lyrics platform integration").await);
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
pub mod kashi;
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
use serenity::model::channel::Message;
|
|
||||||
use serenity::Result as SerenityResult;
|
|
||||||
|
|
||||||
pub fn check_msg(result: SerenityResult<Message>) {
|
|
||||||
if let Err(why) = result {
|
|
||||||
println!("Error sending message: {:?}", why);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
30
src/commands/music.rs
Normal file
30
src/commands/music.rs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
pub mod deafen;
|
||||||
|
pub mod join;
|
||||||
|
pub mod leave;
|
||||||
|
pub mod metadata;
|
||||||
|
pub mod mute;
|
||||||
|
pub mod notifier;
|
||||||
|
pub mod pause;
|
||||||
|
pub mod play;
|
||||||
|
pub mod queue;
|
||||||
|
pub mod repeat;
|
||||||
|
pub mod resume;
|
||||||
|
pub mod seek;
|
||||||
|
pub mod skip;
|
||||||
|
pub mod soundboard;
|
||||||
|
pub mod stop;
|
||||||
|
pub mod volume;
|
||||||
|
|
||||||
|
pub use deafen::deafen;
|
||||||
|
pub use join::join;
|
||||||
|
pub use leave::leave;
|
||||||
|
pub use mute::mute;
|
||||||
|
pub use pause::pause;
|
||||||
|
pub use play::play;
|
||||||
|
pub use queue::queue;
|
||||||
|
pub use repeat::repeat;
|
||||||
|
pub use resume::resume;
|
||||||
|
pub use seek::seek;
|
||||||
|
pub use skip::skip;
|
||||||
|
pub use stop::stop;
|
||||||
|
pub use volume::volume;
|
||||||
@@ -1,24 +1,31 @@
|
|||||||
use serenity::framework::standard::macros::command;
|
use crate::{
|
||||||
use serenity::framework::standard::CommandResult;
|
commands::embeds::{embed, error_embed, fail},
|
||||||
use serenity::model::prelude::*;
|
Context, Error,
|
||||||
use serenity::prelude::*;
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
use crate::commands::misc::check_msg;
|
/// Deafens itself while in a voice channel; \
|
||||||
|
/// aliases: deafen, undeaden, shuush
|
||||||
|
#[poise::command(
|
||||||
|
prefix_command,
|
||||||
|
slash_command,
|
||||||
|
aliases("shuush", "undeafen"),
|
||||||
|
category = "Music"
|
||||||
|
)]
|
||||||
|
pub async fn deafen(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
let guild_id = ctx.guild_id().unwrap();
|
||||||
|
|
||||||
#[command]
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
#[only_in(guilds)]
|
|
||||||
async fn deafen(ctx: &Context, msg: &Message) -> CommandResult {
|
|
||||||
let guild_id = msg.guild_id.unwrap();
|
|
||||||
|
|
||||||
let manager = songbird::get(ctx)
|
|
||||||
.await
|
.await
|
||||||
.expect("Client placed at init")
|
.expect("Songbird client placed at init")
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
let handler_lock = match manager.get(guild_id) {
|
let handler_lock = match manager.get(guild_id) {
|
||||||
Some(handler) => handler,
|
Some(handler) => handler,
|
||||||
None => {
|
None => {
|
||||||
check_msg(msg.reply(ctx, "Not in a voice channel").await);
|
let msg = "I am not in a voice channel!";
|
||||||
|
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||||
|
.await?;
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -28,24 +35,18 @@ async fn deafen(ctx: &Context, msg: &Message) -> CommandResult {
|
|||||||
|
|
||||||
if handler.is_deaf() {
|
if handler.is_deaf() {
|
||||||
if let Err(err) = handler.deafen(false).await {
|
if let Err(err) = handler.deafen(false).await {
|
||||||
check_msg(
|
fail(ctx, err.to_string()).await.unwrap();
|
||||||
msg.channel_id
|
|
||||||
.say(&ctx.http, format!("Failed: {:?}", err))
|
|
||||||
.await,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_msg(msg.channel_id.say(&ctx.http, "Undeafened").await);
|
ctx.send(CreateReply::default().embed(embed(ctx, "Undeafened!", "", "").await.unwrap()))
|
||||||
|
.await?;
|
||||||
} else {
|
} else {
|
||||||
if let Err(err) = handler.deafen(true).await {
|
if let Err(err) = handler.deafen(true).await {
|
||||||
check_msg(
|
fail(ctx, err.to_string()).await.unwrap();
|
||||||
msg.channel_id
|
|
||||||
.say(&ctx.http, format!("Failed: {:?}", err))
|
|
||||||
.await,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_msg(msg.channel_id.say(&ctx.http, "Deafened").await);
|
ctx.send(CreateReply::default().embed(embed(ctx, "Deafened!", "", "").await.unwrap()))
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -1,29 +1,35 @@
|
|||||||
use serenity::framework::standard::macros::command;
|
use crate::commands::music::notifier::TrackErrorNotifier;
|
||||||
use serenity::framework::standard::CommandResult;
|
use crate::{
|
||||||
use serenity::model::prelude::*;
|
commands::embeds::{embed, error_embed},
|
||||||
use serenity::prelude::*;
|
Context, Error,
|
||||||
use songbird::events::TrackEvent;
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
use songbird::TrackEvent;
|
||||||
|
|
||||||
use crate::commands::{misc::check_msg, music::misc::TrackErrorNotifier};
|
/// Joins your voice channel
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Music")]
|
||||||
#[command]
|
pub async fn join(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
#[only_in(guilds)]
|
let guild_id = ctx.guild_id().unwrap();
|
||||||
async fn join(ctx: &Context, msg: &Message) -> CommandResult {
|
let channel_id = ctx
|
||||||
let guild_id = msg.guild_id.unwrap();
|
.guild()
|
||||||
let channel_id = msg.guild(&ctx.cache).unwrap().voice_states.get(&msg.author.id).and_then(|voice_state| voice_state.channel_id);
|
.unwrap()
|
||||||
|
.voice_states
|
||||||
|
.get(&ctx.author().id)
|
||||||
|
.and_then(|voice_state| voice_state.channel_id);
|
||||||
|
|
||||||
let connect_to = match channel_id {
|
let connect_to = match channel_id {
|
||||||
Some(channel) => channel,
|
Some(channel) => channel,
|
||||||
None => {
|
None => {
|
||||||
check_msg(msg.reply(ctx, "Not in a voice channel").await);
|
let msg = "I am not in a voice channel!";
|
||||||
|
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||||
|
.await?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let manager = songbird::get(ctx)
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
.await
|
.await
|
||||||
.expect("Songbird Voice placed at init")
|
.expect("Songbird client placed at init")
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
if let Ok(handler_lock) = manager.join(guild_id, connect_to).await {
|
if let Ok(handler_lock) = manager.join(guild_id, connect_to).await {
|
||||||
@@ -31,5 +37,8 @@ async fn join(ctx: &Context, msg: &Message) -> CommandResult {
|
|||||||
handler.add_global_event(TrackEvent::Error.into(), TrackErrorNotifier);
|
handler.add_global_event(TrackEvent::Error.into(), TrackErrorNotifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.send(CreateReply::default().embed(embed(ctx, "Joined!", "Hi there!", "").await.unwrap()))
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +1,45 @@
|
|||||||
use serenity::framework::standard::macros::command;
|
use crate::{
|
||||||
use serenity::framework::standard::CommandResult;
|
commands::embeds::{embed, error_embed, fail},
|
||||||
use serenity::model::prelude::*;
|
Context, Error,
|
||||||
use serenity::prelude::*;
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
use crate::commands::misc::check_msg;
|
/// Leaves the voice channel; \
|
||||||
|
/// aliases: leave, qa!
|
||||||
|
#[poise::command(
|
||||||
|
prefix_command,
|
||||||
|
slash_command,
|
||||||
|
aliases("leave", "qa!"),
|
||||||
|
category = "Music"
|
||||||
|
)]
|
||||||
|
pub async fn leave(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
let guild_id = ctx.guild_id().unwrap();
|
||||||
|
|
||||||
#[command]
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
#[aliases(q)]
|
|
||||||
#[only_in(guilds)]
|
|
||||||
async fn leave(ctx: &Context, msg: &Message) -> CommandResult {
|
|
||||||
let guild_id = msg.guild_id.unwrap();
|
|
||||||
|
|
||||||
let manager = songbird::get(ctx)
|
|
||||||
.await
|
.await
|
||||||
.expect("Client placed in at init")
|
.expect("Songbird client placed at init")
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
let has_handler = manager.get(guild_id).is_some();
|
if manager.get(guild_id).is_none() {
|
||||||
|
let msg = "I am not in a voice channel!";
|
||||||
|
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
if has_handler {
|
|
||||||
if let Err(err) = manager.remove(guild_id).await {
|
if let Err(err) = manager.remove(guild_id).await {
|
||||||
check_msg(
|
fail(ctx, err.to_string()).await.unwrap();
|
||||||
msg.channel_id
|
|
||||||
.say(&ctx.http, format!("Failed: {:?}", err))
|
|
||||||
.await,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_msg(msg.channel_id.say(&ctx.http, "Left voice channel").await);
|
ctx.send(
|
||||||
} else {
|
CreateReply::default().embed(
|
||||||
check_msg(msg.reply(ctx, "Not in a voice channel").await);
|
embed(ctx, "Left!", "I left the voice channel", "")
|
||||||
}
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
7
src/commands/music/metadata.rs
Normal file
7
src/commands/music/metadata.rs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
use songbird::{input::AuxMetadata, typemap::TypeMapKey};
|
||||||
|
|
||||||
|
pub struct Metadata;
|
||||||
|
|
||||||
|
impl TypeMapKey for Metadata {
|
||||||
|
type Value = AuxMetadata;
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
pub mod deafen;
|
|
||||||
pub mod join;
|
|
||||||
pub mod leave;
|
|
||||||
pub mod misc;
|
|
||||||
pub mod mute;
|
|
||||||
pub mod play;
|
|
||||||
pub mod queue;
|
|
||||||
pub mod skip;
|
|
||||||
pub mod stop;
|
|
||||||
@@ -1,25 +1,31 @@
|
|||||||
use serenity::framework::standard::macros::command;
|
use crate::{
|
||||||
use serenity::framework::standard::CommandResult;
|
commands::embeds::{embed, error_embed, fail},
|
||||||
use serenity::model::prelude::*;
|
Context, Error,
|
||||||
use serenity::prelude::*;
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
use crate::commands::misc::check_msg;
|
/// Mutes itself while in a voice channel; \
|
||||||
|
/// aliases: mute, unmute, shhh
|
||||||
|
#[poise::command(
|
||||||
|
prefix_command,
|
||||||
|
slash_command,
|
||||||
|
aliases("shhh", "unmute"),
|
||||||
|
category = "Music"
|
||||||
|
)]
|
||||||
|
pub async fn mute(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
let guild_id = ctx.guild_id().unwrap();
|
||||||
|
|
||||||
#[command]
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
#[only_in(guilds)]
|
|
||||||
async fn mute(ctx: &Context, msg: &Message) -> CommandResult {
|
|
||||||
let guild_id = msg.guild_id.unwrap();
|
|
||||||
|
|
||||||
let manager = songbird::get(ctx)
|
|
||||||
.await
|
.await
|
||||||
.expect("Client placed at init")
|
.expect("Songbird client placed at init")
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
let handler_lock = match manager.get(guild_id) {
|
let handler_lock = match manager.get(guild_id) {
|
||||||
Some(handler) => handler,
|
Some(handler) => handler,
|
||||||
None => {
|
None => {
|
||||||
check_msg(msg.reply(ctx, "Not in a voice channel").await);
|
let msg = "I am not in a voice channel!";
|
||||||
|
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||||
|
.await?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -27,25 +33,19 @@ async fn mute(ctx: &Context, msg: &Message) -> CommandResult {
|
|||||||
let mut handler = handler_lock.lock().await;
|
let mut handler = handler_lock.lock().await;
|
||||||
|
|
||||||
if handler.is_mute() {
|
if handler.is_mute() {
|
||||||
if let Err(e) = handler.mute(false).await {
|
if let Err(err) = handler.mute(false).await {
|
||||||
check_msg(
|
fail(ctx, err.to_string()).await.unwrap();
|
||||||
msg.channel_id
|
|
||||||
.say(&ctx.http, format!("failed: {:?}", e))
|
|
||||||
.await,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_msg(msg.channel_id.say(&ctx.http, "Unmuted").await);
|
ctx.send(CreateReply::default().embed(embed(ctx, "Unmuted!", "", "").await.unwrap()))
|
||||||
|
.await?;
|
||||||
} else {
|
} else {
|
||||||
if let Err(err) = handler.mute(true).await {
|
if let Err(err) = handler.mute(true).await {
|
||||||
check_msg(
|
fail(ctx, err.to_string()).await.unwrap();
|
||||||
msg.channel_id
|
|
||||||
.say(&ctx.http, format!("Failed: {:?}", err))
|
|
||||||
.await,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
check_msg(msg.channel_id.say(&ctx.http, "Muted").await);
|
ctx.send(CreateReply::default().embed(embed(ctx, "Muted!", "", "").await.unwrap()))
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
use crate::{
|
||||||
|
commands::embeds::{embed, error_embed},
|
||||||
|
Context, Error,
|
||||||
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
|
/// Pauses the currently playing song
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Music")]
|
||||||
|
pub async fn pause(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
let guild_id = ctx.guild_id().unwrap();
|
||||||
|
|
||||||
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
|
.await
|
||||||
|
.expect("Songbird client placed at init")
|
||||||
|
.clone();
|
||||||
|
|
||||||
|
if let Some(handler_lock) = manager.get(guild_id) {
|
||||||
|
let handler = handler_lock.lock().await;
|
||||||
|
let queue = handler.queue();
|
||||||
|
let _ = queue.pause();
|
||||||
|
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default().embed(
|
||||||
|
embed(ctx, "Paused!", "Currently playing song is now paused!", "")
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
} else {
|
||||||
|
let msg = "I am not in a voice channel!";
|
||||||
|
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,88 +1,239 @@
|
|||||||
use serenity::framework::standard::macros::command;
|
use crate::commands::music::metadata::Metadata;
|
||||||
use serenity::framework::standard::{Args, CommandResult};
|
use crate::commands::music::notifier::TrackErrorNotifier;
|
||||||
use serenity::model::prelude::*;
|
use crate::{commands::embeds::error_embed, Context, Error};
|
||||||
use serenity::prelude::*;
|
|
||||||
use reqwest::Client as HttpClient;
|
|
||||||
use songbird::input::{Compose, YoutubeDl};
|
|
||||||
use songbird::events::TrackEvent;
|
|
||||||
|
|
||||||
use crate::commands::{misc::check_msg, music::misc::TrackErrorNotifier};
|
use poise::serenity_prelude::{
|
||||||
|
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
|
||||||
pub struct HttpKey;
|
|
||||||
|
|
||||||
impl TypeMapKey for HttpKey {
|
|
||||||
type Value = HttpClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[command]
|
|
||||||
#[aliases(p)]
|
|
||||||
#[only_in(guilds)]
|
|
||||||
async fn play(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
|
|
||||||
let url = match args.single::<String>() {
|
|
||||||
Ok(url) => url,
|
|
||||||
Err(_) => {
|
|
||||||
check_msg(
|
|
||||||
msg.channel_id
|
|
||||||
.say(&ctx.http, "Must provide a URL to a video or audio")
|
|
||||||
.await,
|
|
||||||
);
|
|
||||||
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
use regex::Regex as Regex_Classic;
|
||||||
|
use reqwest::Client;
|
||||||
|
use serenity::all::GuildId;
|
||||||
|
use songbird::events::TrackEvent;
|
||||||
|
use songbird::input::AuxMetadata;
|
||||||
|
use songbird::input::{Compose, YoutubeDl};
|
||||||
|
use songbird::tracks::TrackQueue;
|
||||||
|
use songbird::Call;
|
||||||
|
use spotify_parser;
|
||||||
|
use std::collections::VecDeque;
|
||||||
|
use std::process::Command;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
let is_search = !url.starts_with("http");
|
/// Plays a song; \
|
||||||
|
/// you can search by query or paste an url; \
|
||||||
|
/// aliases: play, p, enqueue
|
||||||
|
#[poise::command(
|
||||||
|
prefix_command,
|
||||||
|
slash_command,
|
||||||
|
aliases("p", "enqueue"),
|
||||||
|
category = "Music"
|
||||||
|
)]
|
||||||
|
pub async fn play(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[description = "Provide a query or an url"]
|
||||||
|
#[rest]
|
||||||
|
song: String,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let guild_id = ctx.guild_id().unwrap();
|
||||||
|
let http_client = ctx.data().http_client.clone();
|
||||||
|
let manager = songbird::get(ctx.serenity_context()).await.unwrap().clone();
|
||||||
|
|
||||||
let guild_id = msg.guild_id.unwrap();
|
let mut rest_playlist: VecDeque<String> = VecDeque::new();
|
||||||
let channel_id = msg.guild(&ctx.cache).unwrap().voice_states.get(&msg.author.id).and_then(|voice_state| voice_state.channel_id);
|
|
||||||
|
if manager.get(guild_id).is_none() {
|
||||||
|
let channel_id = ctx
|
||||||
|
.guild()
|
||||||
|
.unwrap()
|
||||||
|
.voice_states
|
||||||
|
.get(&ctx.author().id)
|
||||||
|
.and_then(|voice_state| voice_state.channel_id);
|
||||||
|
|
||||||
let connect_to = match channel_id {
|
let connect_to = match channel_id {
|
||||||
Some(channel) => channel,
|
Some(channel) => channel,
|
||||||
None => {
|
None => {
|
||||||
check_msg(msg.reply(ctx, "Not in a voice channel").await);
|
let msg = "I am not in a voice channel!";
|
||||||
|
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||||
|
.await?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let http_client = {
|
|
||||||
let data = ctx.data.read().await;
|
|
||||||
data.get::<HttpKey>()
|
|
||||||
.cloned()
|
|
||||||
.expect("Guaranteed to exist in the typemap.")
|
|
||||||
};
|
|
||||||
|
|
||||||
let manager = songbird::get(ctx)
|
|
||||||
.await
|
|
||||||
.expect("Songbird Voice placed at init")
|
|
||||||
.clone();
|
|
||||||
|
|
||||||
if let Ok(handler_lock) = manager.join(guild_id, connect_to).await {
|
if let Ok(handler_lock) = manager.join(guild_id, connect_to).await {
|
||||||
let mut handler = handler_lock.lock().await;
|
let mut handler = handler_lock.lock().await;
|
||||||
|
|
||||||
if let Err(err) = handler.deafen(true).await {println!("Failed to deafen: {:?}", err)};
|
|
||||||
handler.add_global_event(TrackEvent::Error.into(), TrackErrorNotifier);
|
handler.add_global_event(TrackEvent::Error.into(), TrackErrorNotifier);
|
||||||
|
|
||||||
let mut src = if is_search {
|
rest_playlist = handle_play(ctx, song, handler, http_client.clone())
|
||||||
println!("ytsearch:{}", url);
|
.await
|
||||||
YoutubeDl::new_ytdl_like("yt-dlp", http_client, format!("ytsearch:{}", args.clone().message()))
|
.unwrap();
|
||||||
} else {
|
} else {
|
||||||
YoutubeDl::new_ytdl_like("yt-dlp", http_client, url)
|
let msg = "Failed to join the voice channel!";
|
||||||
};
|
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||||
|
.await?;
|
||||||
let _ = handler.enqueue_input(src.clone().into()).await;
|
}
|
||||||
|
|
||||||
let metadata = src.aux_metadata().await.unwrap();
|
|
||||||
// let _ = handler.play_input(src.clone().into());
|
|
||||||
|
|
||||||
check_msg(msg.channel_id.say(&ctx.http, format!("Playing song: {}", metadata.title.unwrap())).await);
|
|
||||||
} else {
|
} else {
|
||||||
check_msg(
|
let handler = manager.get(guild_id).unwrap();
|
||||||
msg.channel_id
|
let mut handler = handler.lock().await;
|
||||||
.say(&ctx.http, "Not in a voice channel to play in")
|
handler.add_global_event(TrackEvent::Error.into(), TrackErrorNotifier);
|
||||||
.await,
|
rest_playlist = handle_play(ctx, song, handler, http_client.clone())
|
||||||
);
|
.await
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_playlist(rest_playlist, manager, guild_id, http_client)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn handle_play<'a>(
|
||||||
|
ctx: Context<'a>,
|
||||||
|
song: String,
|
||||||
|
mut handler: tokio::sync::MutexGuard<'a, Call>,
|
||||||
|
http_client: Client,
|
||||||
|
) -> Result<VecDeque<String>, Error> {
|
||||||
|
let mut results = parse_data(song).await;
|
||||||
|
|
||||||
|
let src: YoutubeDl =
|
||||||
|
YoutubeDl::new_ytdl_like("yt-dlp", http_client, results.pop_front().unwrap());
|
||||||
|
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default().embed(
|
||||||
|
generate_embed(ctx, src.clone(), handler.queue(), results.clone())
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let aux_metadata = src.clone().aux_metadata().await.unwrap();
|
||||||
|
|
||||||
|
handler
|
||||||
|
.enqueue_input(src.clone().into())
|
||||||
|
.await
|
||||||
|
.typemap()
|
||||||
|
.write()
|
||||||
|
.await
|
||||||
|
.insert::<Metadata>(aux_metadata);
|
||||||
|
|
||||||
|
Ok(results)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn parse_data(data: String) -> VecDeque<String> {
|
||||||
|
let tracks = spotify_parser::retrieve_async_url(&data)
|
||||||
|
.await
|
||||||
|
.unwrap_or(vec![data])
|
||||||
|
.iter()
|
||||||
|
.flat_map(|track| {
|
||||||
|
if track.contains("?list=") {
|
||||||
|
let regex_youtube = Regex_Classic::new(
|
||||||
|
r#""url": "(https://www.youtube.com/watch\?v=[A-Za-z0-9]{11})""#,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let list = Command::new("yt-dlp")
|
||||||
|
.args(["--username", "oauth2", "--password", "''"])
|
||||||
|
.args(["-j", "--flat-playlist", track])
|
||||||
|
.output()
|
||||||
|
.expect("Failed to execute process")
|
||||||
|
.stdout;
|
||||||
|
let list = String::from_utf8(list).unwrap();
|
||||||
|
|
||||||
|
regex_youtube
|
||||||
|
.captures_iter(&list)
|
||||||
|
.map(|capture| capture.get(1).unwrap().as_str().to_string())
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
} else if track.starts_with("http") {
|
||||||
|
vec![track.clone()]
|
||||||
|
} else {
|
||||||
|
vec![format!("ytsearch:{}", track)]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
tracks
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn handle_playlist(
|
||||||
|
playlist: VecDeque<String>,
|
||||||
|
manager: std::sync::Arc<songbird::Songbird>,
|
||||||
|
guild_id: GuildId,
|
||||||
|
http_client: Client,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
for song in playlist {
|
||||||
|
if manager.get(guild_id).is_some() {
|
||||||
|
let handler = manager.get(guild_id).unwrap();
|
||||||
|
let mut handler = handler.lock().await;
|
||||||
|
|
||||||
|
let src: YoutubeDl =
|
||||||
|
YoutubeDl::new_ytdl_like("yt-dlp", http_client.clone(), song.clone());
|
||||||
|
|
||||||
|
let aux_metadata = src.clone().aux_metadata().await.unwrap();
|
||||||
|
|
||||||
|
handler
|
||||||
|
.enqueue_input(src.clone().into())
|
||||||
|
.await
|
||||||
|
.typemap()
|
||||||
|
.write()
|
||||||
|
.await
|
||||||
|
.insert::<Metadata>(aux_metadata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn generate_embed(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
src: YoutubeDl,
|
||||||
|
queue: &TrackQueue,
|
||||||
|
results: VecDeque<String>,
|
||||||
|
) -> Result<CreateEmbed, Error> {
|
||||||
|
let metadata = src.clone().aux_metadata().await.unwrap();
|
||||||
|
let AuxMetadata {
|
||||||
|
title,
|
||||||
|
thumbnail,
|
||||||
|
source_url,
|
||||||
|
artist,
|
||||||
|
duration,
|
||||||
|
..
|
||||||
|
} = metadata;
|
||||||
|
let duration_minutes = duration.unwrap_or(Duration::new(0, 0)).clone().as_secs() / 60;
|
||||||
|
let duration_seconds = duration.unwrap_or(Duration::new(0, 0)).clone().as_secs() % 60;
|
||||||
|
let mut description = format!("Enqueued @ {}", queue.len() + 1);
|
||||||
|
let mut tracks = "Tracks enqueued";
|
||||||
|
|
||||||
|
if results.len() == 1 {
|
||||||
|
tracks = "Track enqueued";
|
||||||
|
}
|
||||||
|
|
||||||
|
if queue.is_empty() {
|
||||||
|
description = "Playing now!".to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
let embed = CreateEmbed::default()
|
||||||
|
.author(CreateEmbedAuthor::new(tracks).icon_url(ctx.author().clone().face()))
|
||||||
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
|
.title(title.unwrap())
|
||||||
|
.url(source_url.unwrap())
|
||||||
|
.thumbnail(thumbnail.unwrap_or(ctx.cache().current_user().face()))
|
||||||
|
.field(
|
||||||
|
"Artist",
|
||||||
|
artist.unwrap_or("Unknown Artist".to_string()),
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.field(
|
||||||
|
"Duration",
|
||||||
|
format!("{:02}:{:02}", duration_minutes, duration_seconds),
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.field("DJ", ctx.author().name.clone(), true)
|
||||||
|
.description(description)
|
||||||
|
.timestamp(Timestamp::now())
|
||||||
|
.footer(
|
||||||
|
CreateEmbedFooter::new(ctx.cache().current_user().name.to_string())
|
||||||
|
.icon_url(ctx.cache().current_user().face()),
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(embed)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,48 +1,91 @@
|
|||||||
use serenity::framework::standard::macros::command;
|
use std::time::Duration;
|
||||||
use serenity::framework::standard::CommandResult;
|
|
||||||
use serenity::model::prelude::*;
|
|
||||||
use serenity::prelude::*;
|
|
||||||
|
|
||||||
use crate::commands::misc::check_msg;
|
use crate::commands::music::metadata::Metadata;
|
||||||
|
use crate::{commands::embeds::error_embed, Context, Error};
|
||||||
|
use poise::serenity_prelude::{
|
||||||
|
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
|
||||||
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
use songbird::input::AuxMetadata;
|
||||||
|
|
||||||
#[command]
|
const QUEUE_DISPLAY_LENGTH: usize = 10;
|
||||||
#[only_in(guilds)]
|
|
||||||
async fn queue(ctx: &Context, msg: &Message) -> CommandResult {
|
|
||||||
let guild_id = msg.guild_id.unwrap();
|
|
||||||
|
|
||||||
let manager = songbird::get(ctx)
|
/// Shows next tracks in queue; \
|
||||||
|
/// aliases: queue, q
|
||||||
|
#[poise::command(prefix_command, slash_command, aliases("q"), category = "Music")]
|
||||||
|
pub async fn queue(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
let guild_id = ctx.guild_id().unwrap();
|
||||||
|
|
||||||
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
.await
|
.await
|
||||||
.expect("Client placed at init")
|
.expect("Songbird client placed at init")
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
if let Some(handler_lock) = manager.get(guild_id) {
|
if let Some(handler_lock) = manager.get(guild_id) {
|
||||||
let handler = handler_lock.lock().await;
|
let handler = handler_lock.lock().await;
|
||||||
let queue = handler.queue();
|
let queue = handler.queue();
|
||||||
let mut queue_res = String::from("Queue: \n");
|
let mut queue_res = String::from("");
|
||||||
|
let mut too_long = false;
|
||||||
|
|
||||||
|
for (index, song) in queue.clone().current_queue().iter().enumerate() {
|
||||||
|
let meta_typemap = song.typemap().read().await;
|
||||||
|
let metadata = meta_typemap.get::<Metadata>().unwrap();
|
||||||
|
let AuxMetadata {
|
||||||
|
title,
|
||||||
|
artist,
|
||||||
|
duration,
|
||||||
|
..
|
||||||
|
} = metadata;
|
||||||
|
|
||||||
|
let duration_minutes = duration.unwrap_or(Duration::new(0, 0)).clone().as_secs() / 60;
|
||||||
|
let duration_seconds = duration.unwrap_or(Duration::new(0, 0)).clone().as_secs() % 60;
|
||||||
|
|
||||||
for (i, song) in queue.current_queue().iter().enumerate() {
|
|
||||||
queue_res.push_str(&format!(
|
queue_res.push_str(&format!(
|
||||||
"{}. {} - {}\n",
|
"{}. {} - {} [{:02}:{:02}] \n",
|
||||||
i + 1,
|
index,
|
||||||
song.uuid(),
|
title.as_ref().unwrap(),
|
||||||
"Artist"
|
artist.as_ref().unwrap(),
|
||||||
// song.metadata().artist.clone().unwrap_or_else(|| String::from("Unknown"))
|
duration_minutes,
|
||||||
|
duration_seconds
|
||||||
|
));
|
||||||
|
|
||||||
|
if index + 1 == QUEUE_DISPLAY_LENGTH {
|
||||||
|
too_long = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if too_long {
|
||||||
|
queue_res.push_str(&format!(
|
||||||
|
"and {} more...",
|
||||||
|
queue.len() - QUEUE_DISPLAY_LENGTH
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
check_msg(
|
ctx.send(CreateReply::default().embed(embed(ctx, queue_res).await.unwrap()))
|
||||||
msg.channel_id
|
.await?;
|
||||||
.say(&ctx.http, queue_res)
|
|
||||||
.await,
|
|
||||||
);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
check_msg(
|
let msg = "I am not in a voice channel!";
|
||||||
msg.channel_id
|
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||||
.say(&ctx.http, "Not in a voice channel!")
|
.await?;
|
||||||
.await,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn embed(ctx: Context<'_>, queue: String) -> Result<CreateEmbed, Error> {
|
||||||
|
let title = "Now playing";
|
||||||
|
let timestamp = Timestamp::now();
|
||||||
|
|
||||||
|
let embed = CreateEmbed::default()
|
||||||
|
.author(CreateEmbedAuthor::new("Queue").icon_url(ctx.author().clone().face()))
|
||||||
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
|
.title(title)
|
||||||
|
.description(queue)
|
||||||
|
.timestamp(timestamp)
|
||||||
|
.footer(
|
||||||
|
CreateEmbedFooter::new(ctx.cache().current_user().name.to_string())
|
||||||
|
.icon_url(ctx.cache().current_user().face()),
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(embed)
|
||||||
|
}
|
||||||
|
|||||||
90
src/commands/music/repeat.rs
Normal file
90
src/commands/music/repeat.rs
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
use crate::{
|
||||||
|
commands::embeds::{embed, error_embed},
|
||||||
|
Context, Error,
|
||||||
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
use songbird::tracks::LoopState;
|
||||||
|
|
||||||
|
/// Loops currently playing song provided amount of times; \
|
||||||
|
/// aliases: repeat, loop, while, for
|
||||||
|
#[poise::command(
|
||||||
|
prefix_command,
|
||||||
|
slash_command,
|
||||||
|
aliases("loop", "while", "for"),
|
||||||
|
category = "Music"
|
||||||
|
)]
|
||||||
|
pub async fn repeat(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[description = "How many times"]
|
||||||
|
#[rest]
|
||||||
|
times: usize,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let guild_id = ctx.guild_id().unwrap();
|
||||||
|
|
||||||
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
|
.await
|
||||||
|
.expect("Songbird client placed at init")
|
||||||
|
.clone();
|
||||||
|
|
||||||
|
if let Some(handler_lock) = manager.get(guild_id) {
|
||||||
|
let handler = handler_lock.lock().await;
|
||||||
|
let queue = handler.queue();
|
||||||
|
|
||||||
|
let track = queue.current().unwrap().get_info().await;
|
||||||
|
let is_looped = track.unwrap().loops;
|
||||||
|
|
||||||
|
match is_looped {
|
||||||
|
LoopState::Infinite => {
|
||||||
|
let _ = queue.current().unwrap().disable_loop();
|
||||||
|
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default()
|
||||||
|
.embed(embed(ctx, "Song Unlooped!", "", "").await.unwrap()),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
LoopState::Finite(_) => {
|
||||||
|
if times == 0 {
|
||||||
|
let _ = queue.current().unwrap().disable_loop();
|
||||||
|
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default()
|
||||||
|
.embed(embed(ctx, "Song Unlooped!", "", "").await.unwrap()),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
} else if times < 100 {
|
||||||
|
let _ = queue.current().unwrap().loop_for(times);
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default().embed(
|
||||||
|
embed(
|
||||||
|
ctx,
|
||||||
|
&format!("Song looped {} times!", times),
|
||||||
|
"You definitelly love this song!",
|
||||||
|
"",
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
} else {
|
||||||
|
let _ = queue.current().unwrap().enable_loop();
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default().embed(
|
||||||
|
embed(ctx, "Song looped forever!", "A very long time!", "")
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let msg = "I am not in a voice channel!";
|
||||||
|
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
use crate::{
|
||||||
|
commands::embeds::{embed, error_embed},
|
||||||
|
Context, Error,
|
||||||
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
|
/// Resumes currently paused song
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Music")]
|
||||||
|
pub async fn resume(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
let guild_id = ctx.guild_id().unwrap();
|
||||||
|
|
||||||
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
|
.await
|
||||||
|
.expect("Songbird client placed at init")
|
||||||
|
.clone();
|
||||||
|
|
||||||
|
if let Some(handler_lock) = manager.get(guild_id) {
|
||||||
|
let handler = handler_lock.lock().await;
|
||||||
|
let queue = handler.queue();
|
||||||
|
let _ = queue.resume();
|
||||||
|
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default().embed(
|
||||||
|
embed(ctx, "Resumed!", "Currently paused song is now resumed!", "")
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
} else {
|
||||||
|
let msg = "I am not in a voice channel!";
|
||||||
|
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
51
src/commands/music/seek.rs
Normal file
51
src/commands/music/seek.rs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
commands::embeds::{embed, error_embed},
|
||||||
|
Context, Error,
|
||||||
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
|
/// Seeks a track by provided seconds
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Music")]
|
||||||
|
pub async fn seek(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[description = "How many seconds shall I seek"] seek: u64,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let guild_id = ctx.guild_id().unwrap();
|
||||||
|
|
||||||
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
|
.await
|
||||||
|
.expect("Songbird client placed at init")
|
||||||
|
.clone();
|
||||||
|
|
||||||
|
if let Some(handler_lock) = manager.get(guild_id) {
|
||||||
|
let handler = handler_lock.lock().await;
|
||||||
|
let queue = handler.queue();
|
||||||
|
|
||||||
|
let seek_duration = Duration::from_secs(seek);
|
||||||
|
|
||||||
|
let track = queue.current().unwrap();
|
||||||
|
let _ = track.seek(seek_duration);
|
||||||
|
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default().embed(
|
||||||
|
embed(
|
||||||
|
ctx,
|
||||||
|
"Track seeked!",
|
||||||
|
&format!("Track seeked by: {} seconds", seek),
|
||||||
|
"",
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
} else {
|
||||||
|
let msg = "I am not in a voice channel!";
|
||||||
|
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -1,40 +1,107 @@
|
|||||||
use serenity::framework::standard::macros::command;
|
use crate::commands::music::metadata::Metadata;
|
||||||
use serenity::framework::standard::CommandResult;
|
use std::time::Duration;
|
||||||
use serenity::model::prelude::*;
|
|
||||||
use serenity::prelude::*;
|
|
||||||
|
|
||||||
use crate::commands::misc::check_msg;
|
use crate::{
|
||||||
|
commands::embeds::{embed, error_embed},
|
||||||
|
Context, Error,
|
||||||
|
};
|
||||||
|
use poise::serenity_prelude::{
|
||||||
|
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
|
||||||
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
use songbird::{input::AuxMetadata, tracks::TrackHandle};
|
||||||
|
|
||||||
#[command]
|
/// Skips the currently playing song; \
|
||||||
#[only_in(guilds)]
|
/// aliases: skip, :skipper:
|
||||||
async fn skip(ctx: &Context, msg: &Message) -> CommandResult {
|
#[poise::command(prefix_command, slash_command, aliases("skipper:"), category = "Music")]
|
||||||
let guild_id = msg.guild_id.unwrap();
|
pub async fn skip(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
let guild_id = ctx.guild_id().unwrap();
|
||||||
|
|
||||||
let manager = songbird::get(ctx)
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
.await
|
.await
|
||||||
.expect("Client placed at init")
|
.expect("Songbird client placed at init")
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
if let Some(handler_lock) = manager.get(guild_id) {
|
if let Some(handler_lock) = manager.get(guild_id) {
|
||||||
let handler = handler_lock.lock().await;
|
let handler = handler_lock.lock().await;
|
||||||
let queue = handler.queue();
|
let queue = handler.queue();
|
||||||
let _ = queue.skip();
|
let _ = queue.clone().skip();
|
||||||
|
let track_raw = queue.clone().current_queue();
|
||||||
|
let track = track_raw.get(1);
|
||||||
|
let queue_length = queue.len() - 1;
|
||||||
|
|
||||||
check_msg(
|
let mut response = CreateReply::default().embed(
|
||||||
msg.channel_id
|
embed(ctx, "Skipped!", "The queue is empty!", "")
|
||||||
.say(
|
.await
|
||||||
&ctx.http,
|
.unwrap(),
|
||||||
format!("Song skipped: {} in queue.", queue.len()),
|
|
||||||
)
|
|
||||||
.await,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if let Some(track) = track {
|
||||||
|
response = CreateReply::default().embed(
|
||||||
|
generate_embed(ctx, track.clone(), queue_length)
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
ctx.send(response).await?;
|
||||||
} else {
|
} else {
|
||||||
check_msg(
|
let msg = "I am not in a voice channel!";
|
||||||
msg.channel_id
|
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||||
.say(&ctx.http, "Not in a voice channel to play in")
|
.await?;
|
||||||
.await,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn generate_embed(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
track: TrackHandle,
|
||||||
|
queue_length: usize,
|
||||||
|
) -> Result<CreateEmbed, Error> {
|
||||||
|
let meta_typemap = track.typemap().read().await;
|
||||||
|
let metadata = meta_typemap.get::<Metadata>().unwrap();
|
||||||
|
let AuxMetadata {
|
||||||
|
title,
|
||||||
|
thumbnail,
|
||||||
|
source_url,
|
||||||
|
artist,
|
||||||
|
duration,
|
||||||
|
..
|
||||||
|
} = metadata;
|
||||||
|
let timestamp = Timestamp::now();
|
||||||
|
let duration_minutes = duration.unwrap_or(Duration::new(0, 0)).clone().as_secs() / 60;
|
||||||
|
let duration_seconds = duration.unwrap_or(Duration::new(0, 0)).clone().as_secs() % 60;
|
||||||
|
|
||||||
|
let description = format!("Song skipped! Queue length is {}", queue_length);
|
||||||
|
|
||||||
|
let embed = CreateEmbed::default()
|
||||||
|
.author(CreateEmbedAuthor::new("Skipped!").icon_url(ctx.author().clone().face()))
|
||||||
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
|
.title(title.as_ref().unwrap())
|
||||||
|
.url(source_url.as_ref().unwrap())
|
||||||
|
.thumbnail(
|
||||||
|
thumbnail
|
||||||
|
.as_ref()
|
||||||
|
.unwrap_or(&ctx.cache().current_user().face()),
|
||||||
|
)
|
||||||
|
.field(
|
||||||
|
"Artist",
|
||||||
|
artist.as_ref().unwrap_or(&"Unknown Artist".to_string()),
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.field(
|
||||||
|
"Duration",
|
||||||
|
format!("{:02}:{:02}", duration_minutes, duration_seconds),
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.field("DJ", ctx.author().name.clone(), true)
|
||||||
|
.description(description)
|
||||||
|
.timestamp(timestamp)
|
||||||
|
.footer(
|
||||||
|
CreateEmbedFooter::new(ctx.cache().current_user().name.to_string())
|
||||||
|
.icon_url(ctx.cache().current_user().face()),
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(embed)
|
||||||
|
}
|
||||||
|
|||||||
5
src/commands/music/soundboard.rs
Normal file
5
src/commands/music/soundboard.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
pub mod effect;
|
||||||
|
pub mod stream;
|
||||||
|
|
||||||
|
pub use effect::effect;
|
||||||
|
pub use stream::stream;
|
||||||
115
src/commands/music/soundboard/effect.rs
Normal file
115
src/commands/music/soundboard/effect.rs
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
use crate::{commands::embeds::error_embed, Context, Error};
|
||||||
|
|
||||||
|
use poise::serenity_prelude::{
|
||||||
|
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
|
||||||
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
use songbird::events::TrackEvent;
|
||||||
|
use songbird::input::AuxMetadata;
|
||||||
|
use songbird::input::{Compose, YoutubeDl};
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use crate::commands::music::notifier::TrackErrorNotifier;
|
||||||
|
use crate::http::HttpKey;
|
||||||
|
|
||||||
|
/// Plays one of available audio effects
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Music")]
|
||||||
|
pub async fn effect(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[description = "Shall output pause?"]
|
||||||
|
#[flag]
|
||||||
|
pause: bool,
|
||||||
|
#[description = "Provide a query or an url"]
|
||||||
|
#[rest]
|
||||||
|
mut song: String,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let is_query = !song.starts_with("http");
|
||||||
|
|
||||||
|
let guild_id = ctx.guild_id().unwrap();
|
||||||
|
|
||||||
|
let http_client = {
|
||||||
|
let data = ctx.serenity_context().data.read().await;
|
||||||
|
data.get::<HttpKey>()
|
||||||
|
.cloned()
|
||||||
|
.expect("Guaranteed to exist in the typemap.")
|
||||||
|
};
|
||||||
|
|
||||||
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
|
.await
|
||||||
|
.expect("Songbird Voice placed at init")
|
||||||
|
.clone();
|
||||||
|
|
||||||
|
if pause {
|
||||||
|
if let Some(handler_lock) = manager.get(guild_id) {
|
||||||
|
let handler = handler_lock.lock().await;
|
||||||
|
let queue = handler.queue();
|
||||||
|
let _ = queue.pause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(handler_lock) = manager.get(guild_id) {
|
||||||
|
let mut handler = handler_lock.lock().await;
|
||||||
|
|
||||||
|
handler.add_global_event(TrackEvent::Error.into(), TrackErrorNotifier);
|
||||||
|
|
||||||
|
if is_query {
|
||||||
|
song = format!("ytsearch:{}", song);
|
||||||
|
}
|
||||||
|
|
||||||
|
let src = YoutubeDl::new_ytdl_like("yt-dlp", http_client, song);
|
||||||
|
let embed = generate_embed(ctx, src.clone()).await;
|
||||||
|
let response = CreateReply::default().embed(embed.unwrap());
|
||||||
|
ctx.send(response).await?;
|
||||||
|
|
||||||
|
let _ = handler.play_input(src.clone().into());
|
||||||
|
} else {
|
||||||
|
let msg = "I am not in a voice channel!";
|
||||||
|
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn generate_embed(ctx: Context<'_>, src: YoutubeDl) -> Result<CreateEmbed, Error> {
|
||||||
|
let metadata = src.clone().aux_metadata().await.unwrap();
|
||||||
|
let AuxMetadata {
|
||||||
|
title,
|
||||||
|
thumbnail,
|
||||||
|
source_url,
|
||||||
|
artist,
|
||||||
|
duration,
|
||||||
|
..
|
||||||
|
} = metadata;
|
||||||
|
let timestamp = Timestamp::now();
|
||||||
|
let duration_minutes = duration.unwrap_or(Duration::new(0, 0)).clone().as_secs() / 60;
|
||||||
|
let duration_seconds = duration.unwrap_or(Duration::new(0, 0)).clone().as_secs() % 60;
|
||||||
|
|
||||||
|
let description = "Playing now!";
|
||||||
|
|
||||||
|
let embed = CreateEmbed::default()
|
||||||
|
.author(CreateEmbedAuthor::new("Playing an effect!").icon_url(ctx.author().clone().face()))
|
||||||
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
|
.title(title.unwrap())
|
||||||
|
.url(source_url.unwrap())
|
||||||
|
.thumbnail(thumbnail.unwrap_or(ctx.cache().current_user().face()))
|
||||||
|
.field(
|
||||||
|
"Artist",
|
||||||
|
artist.unwrap_or("Unknown Artist".to_string()),
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.field(
|
||||||
|
"Duration",
|
||||||
|
format!("{:02}:{:02}", duration_minutes, duration_seconds),
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.field("DJ", ctx.author().name.clone(), true)
|
||||||
|
.description(description)
|
||||||
|
.timestamp(timestamp)
|
||||||
|
.footer(
|
||||||
|
CreateEmbedFooter::new(ctx.cache().current_user().name.to_string())
|
||||||
|
.icon_url(ctx.cache().current_user().face()),
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(embed)
|
||||||
|
}
|
||||||
124
src/commands/music/soundboard/stream.rs
Normal file
124
src/commands/music/soundboard/stream.rs
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
use crate::{commands::embeds::error_embed, Context, Error};
|
||||||
|
|
||||||
|
use poise::serenity_prelude::{
|
||||||
|
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
|
||||||
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
use songbird::events::TrackEvent;
|
||||||
|
use songbird::input::AuxMetadata;
|
||||||
|
use songbird::input::{Compose, YoutubeDl};
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use crate::commands::music::notifier::TrackErrorNotifier;
|
||||||
|
use crate::http::HttpKey;
|
||||||
|
|
||||||
|
/// Hijacks output and plays audio; \
|
||||||
|
/// search by query or paste an url; \
|
||||||
|
/// aliases: stream, override, hijack
|
||||||
|
#[poise::command(
|
||||||
|
prefix_command,
|
||||||
|
slash_command,
|
||||||
|
aliases("override", "hijack"),
|
||||||
|
category = "Music"
|
||||||
|
)]
|
||||||
|
pub async fn stream(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[description = "Shall output pause?"]
|
||||||
|
#[flag]
|
||||||
|
pause: bool,
|
||||||
|
#[description = "Provide a query or an url"]
|
||||||
|
#[rest]
|
||||||
|
mut song: String,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let is_query = !song.starts_with("http");
|
||||||
|
|
||||||
|
let guild_id = ctx.guild_id().unwrap();
|
||||||
|
|
||||||
|
let http_client = {
|
||||||
|
let data = ctx.serenity_context().data.read().await;
|
||||||
|
data.get::<HttpKey>()
|
||||||
|
.cloned()
|
||||||
|
.expect("Guaranteed to exist in the typemap.")
|
||||||
|
};
|
||||||
|
|
||||||
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
|
.await
|
||||||
|
.expect("Songbird Voice placed at init")
|
||||||
|
.clone();
|
||||||
|
|
||||||
|
if pause {
|
||||||
|
if let Some(handler_lock) = manager.get(guild_id) {
|
||||||
|
let handler = handler_lock.lock().await;
|
||||||
|
let queue = handler.queue();
|
||||||
|
let _ = queue.pause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(handler_lock) = manager.get(guild_id) {
|
||||||
|
let mut handler = handler_lock.lock().await;
|
||||||
|
|
||||||
|
handler.add_global_event(TrackEvent::Error.into(), TrackErrorNotifier);
|
||||||
|
|
||||||
|
if is_query {
|
||||||
|
song = format!("ytsearch:{}", song);
|
||||||
|
}
|
||||||
|
|
||||||
|
let src = YoutubeDl::new_ytdl_like("yt-dlp", http_client, song);
|
||||||
|
let embed = generate_embed(ctx, src.clone()).await;
|
||||||
|
let response = CreateReply::default().embed(embed.unwrap());
|
||||||
|
ctx.send(response).await?;
|
||||||
|
|
||||||
|
let _ = handler.play_input(src.clone().into());
|
||||||
|
} else {
|
||||||
|
let msg = "I am not in a voice channel!";
|
||||||
|
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn generate_embed(ctx: Context<'_>, src: YoutubeDl) -> Result<CreateEmbed, Error> {
|
||||||
|
let metadata = src.clone().aux_metadata().await.unwrap();
|
||||||
|
let AuxMetadata {
|
||||||
|
title,
|
||||||
|
thumbnail,
|
||||||
|
source_url,
|
||||||
|
artist,
|
||||||
|
duration,
|
||||||
|
..
|
||||||
|
} = metadata;
|
||||||
|
let timestamp = Timestamp::now();
|
||||||
|
let duration_minutes = duration.unwrap_or(Duration::new(0, 0)).clone().as_secs() / 60;
|
||||||
|
let duration_seconds = duration.unwrap_or(Duration::new(0, 0)).clone().as_secs() % 60;
|
||||||
|
|
||||||
|
let description = "Playing now!";
|
||||||
|
|
||||||
|
let embed = CreateEmbed::default()
|
||||||
|
.author(
|
||||||
|
CreateEmbedAuthor::new("Audio output hijacked!").icon_url(ctx.author().clone().face()),
|
||||||
|
)
|
||||||
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
|
.title(title.unwrap())
|
||||||
|
.url(source_url.unwrap())
|
||||||
|
.thumbnail(thumbnail.unwrap_or(ctx.cache().current_user().face()))
|
||||||
|
.field(
|
||||||
|
"Artist",
|
||||||
|
artist.unwrap_or("Unknown Artist".to_string()),
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.field(
|
||||||
|
"Duration",
|
||||||
|
format!("{:02}:{:02}", duration_minutes, duration_seconds),
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.field("DJ", ctx.author().name.clone(), true)
|
||||||
|
.description(description)
|
||||||
|
.timestamp(timestamp)
|
||||||
|
.footer(
|
||||||
|
CreateEmbedFooter::new(ctx.cache().current_user().name.to_string())
|
||||||
|
.icon_url(ctx.cache().current_user().face()),
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(embed)
|
||||||
|
}
|
||||||
@@ -1,40 +1,42 @@
|
|||||||
use serenity::framework::standard::macros::command;
|
use crate::{
|
||||||
use serenity::framework::standard::CommandResult;
|
commands::embeds::{embed, error_embed},
|
||||||
use serenity::model::prelude::*;
|
Context, Error,
|
||||||
use serenity::prelude::*;
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
use crate::commands::misc::check_msg;
|
/// Stops playback and destroys the queue; \
|
||||||
|
/// aliases: stop, end
|
||||||
|
#[poise::command(prefix_command, slash_command, aliases("end"), category = "Music")]
|
||||||
|
pub async fn stop(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
let guild_id = ctx.guild_id().unwrap();
|
||||||
|
|
||||||
#[command]
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
#[only_in(guilds)]
|
|
||||||
async fn stop(ctx: &Context, msg: &Message) -> CommandResult {
|
|
||||||
let guild_id = msg.guild_id.unwrap();
|
|
||||||
|
|
||||||
let manager = songbird::get(ctx)
|
|
||||||
.await
|
.await
|
||||||
.expect("Client placed at init")
|
.expect("Songbird client placed at init")
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
if let Some(handler_lock) = manager.get(guild_id) {
|
if let Some(handler_lock) = manager.get(guild_id) {
|
||||||
let mut handler = handler_lock.lock().await;
|
let handler = handler_lock.lock().await;
|
||||||
let queue = handler.queue();
|
let queue = handler.queue();
|
||||||
queue.stop();
|
queue.stop();
|
||||||
|
|
||||||
if let Err(e) = handler.deafen(false).await {
|
ctx.send(
|
||||||
check_msg(
|
CreateReply::default().embed(
|
||||||
msg.channel_id
|
embed(
|
||||||
.say(&ctx.http, format!("Failed: {:?}", e))
|
ctx,
|
||||||
.await,
|
"Stopped!",
|
||||||
);
|
"Playback stopped!",
|
||||||
}
|
"Queue destroyed! Bot will stay and chill with you in a vc",
|
||||||
|
)
|
||||||
check_msg(msg.channel_id.say(&ctx.http, "Playback stopped!").await);
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
} else {
|
} else {
|
||||||
check_msg(
|
let msg = "I am not in a voice channel!";
|
||||||
msg.channel_id
|
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||||
.say(&ctx.http, "Not in a voice channel!")
|
.await?;
|
||||||
.await,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
44
src/commands/music/volume.rs
Normal file
44
src/commands/music/volume.rs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
use crate::{
|
||||||
|
commands::embeds::{embed, error_embed},
|
||||||
|
Context, Error,
|
||||||
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
|
/// Changes output volume
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Music")]
|
||||||
|
pub async fn volume(ctx: Context<'_>, #[description = "Volume"] volume: f32) -> Result<(), Error> {
|
||||||
|
let guild_id = ctx.guild_id().unwrap();
|
||||||
|
|
||||||
|
let manager = songbird::get(ctx.serenity_context())
|
||||||
|
.await
|
||||||
|
.expect("Songbird client placed at init")
|
||||||
|
.clone();
|
||||||
|
|
||||||
|
if let Some(handler_lock) = manager.get(guild_id) {
|
||||||
|
let handler = handler_lock.lock().await;
|
||||||
|
let queue = handler.queue();
|
||||||
|
|
||||||
|
let track = queue.current().unwrap();
|
||||||
|
let _ = track.set_volume(volume / 100.0);
|
||||||
|
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default().embed(
|
||||||
|
embed(
|
||||||
|
ctx,
|
||||||
|
"Volume changed",
|
||||||
|
"",
|
||||||
|
&format!("Set volume to {}%", volume),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
} else {
|
||||||
|
let msg = "I am not in a voice channel!";
|
||||||
|
ctx.send(CreateReply::default().embed(error_embed(ctx, msg).await.unwrap()))
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
31
src/commands/tools.rs
Normal file
31
src/commands/tools.rs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
pub mod ai;
|
||||||
|
pub mod dice;
|
||||||
|
pub mod dictionary;
|
||||||
|
pub mod help;
|
||||||
|
pub mod ip;
|
||||||
|
pub mod metar;
|
||||||
|
pub mod owoify;
|
||||||
|
pub mod ping;
|
||||||
|
pub mod posix;
|
||||||
|
pub mod qr;
|
||||||
|
pub mod register;
|
||||||
|
pub mod taf;
|
||||||
|
pub mod uptime;
|
||||||
|
pub mod verse;
|
||||||
|
pub mod weather;
|
||||||
|
|
||||||
|
pub use ai::ai;
|
||||||
|
pub use dice::dice;
|
||||||
|
pub use dictionary::dictionary;
|
||||||
|
pub use help::help;
|
||||||
|
pub use ip::ip;
|
||||||
|
pub use metar::metar;
|
||||||
|
pub use owoify::owoify;
|
||||||
|
pub use ping::ping;
|
||||||
|
pub use posix::posix;
|
||||||
|
pub use qr::qr;
|
||||||
|
pub use register::register;
|
||||||
|
pub use taf::taf;
|
||||||
|
pub use uptime::uptime;
|
||||||
|
pub use verse::verse;
|
||||||
|
pub use weather::weather;
|
||||||
48
src/commands/tools/ai.rs
Normal file
48
src/commands/tools/ai.rs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
use rand::Rng;
|
||||||
|
|
||||||
|
use std::thread::sleep;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
|
use crate::{commands::embeds::embed, Context, Error};
|
||||||
|
|
||||||
|
/// Asks AI
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Tools")]
|
||||||
|
pub async fn ai(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[description = "prompt to ask"]
|
||||||
|
#[rest]
|
||||||
|
prompt: String,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let iamsorry = &[
|
||||||
|
"I'm sorry, but as an AI language model, I must follow ethical guidelines, and I cannot engage in harmful, malicious, or offensive behavior.",
|
||||||
|
"I'm sorry, but as an AI language model, I may not always be perfect and can make mistakes or provide inaccurate information. Please verify important details from reliable sources.",
|
||||||
|
"I'm sorry, but as an AI language model, I can't engage in real-time conversations or remember previous interactions with users.",
|
||||||
|
"I'm sorry, but as an AI language model, I don't have personal opinions or feelings; I can only provide information based on patterns in the data I was trained on.",
|
||||||
|
"I'm sorry, but as an AI language model, I don't have access to real-time information or updates beyond my last training data in September 2021.",
|
||||||
|
"I'm sorry, but as an AI language model, I don't have the ability to recall specific personal data or information about individuals.",
|
||||||
|
"I'm sorry, but as an AI language model, I don't have consciousness or self-awareness. I'm simply a program designed to process and generate human-like text."
|
||||||
|
];
|
||||||
|
|
||||||
|
println!("Funny prompts: {}", prompt);
|
||||||
|
|
||||||
|
let response = {
|
||||||
|
let mut rng = rand::thread_rng();
|
||||||
|
|
||||||
|
rng.gen_range(0..iamsorry.len())
|
||||||
|
};
|
||||||
|
|
||||||
|
sleep(Duration::from_secs(1));
|
||||||
|
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default().embed(
|
||||||
|
embed(ctx, "AI Response:", "", iamsorry[response])
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
30
src/commands/tools/dice.rs
Normal file
30
src/commands/tools/dice.rs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
use rand::Rng;
|
||||||
|
|
||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
|
use crate::{commands::embeds::embed, Context, Error};
|
||||||
|
|
||||||
|
/// Rolls a dice
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Tools")]
|
||||||
|
pub async fn dice(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
let dice = {
|
||||||
|
let mut rng = rand::thread_rng();
|
||||||
|
rng.gen_range(1..=6)
|
||||||
|
};
|
||||||
|
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default().embed(
|
||||||
|
embed(
|
||||||
|
ctx,
|
||||||
|
"Let's roll the dice!",
|
||||||
|
"",
|
||||||
|
&format!("Your number is: {}", dice),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
72
src/commands/tools/dictionary.rs
Normal file
72
src/commands/tools/dictionary.rs
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
use poise::CreateReply;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use url::form_urlencoded;
|
||||||
|
|
||||||
|
use crate::{commands::embeds::embed, Context, Error};
|
||||||
|
|
||||||
|
/// Explains provided query
|
||||||
|
#[poise::command(prefix_command, slash_command, aliases("dict"), category = "Tools")]
|
||||||
|
pub async fn dictionary(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[description = "Word you're looking for"]
|
||||||
|
#[rest]
|
||||||
|
word: String,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let data: String = form_urlencoded::byte_serialize(word.as_bytes()).collect();
|
||||||
|
|
||||||
|
let client = reqwest::Client::new();
|
||||||
|
let response = client
|
||||||
|
.get(format!(
|
||||||
|
"https://api.dictionaryapi.dev/api/v2/entries/en/{}",
|
||||||
|
data
|
||||||
|
))
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
match response.status() {
|
||||||
|
reqwest::StatusCode::OK => match response.json::<Vec<Word>>().await {
|
||||||
|
Ok(parsed) => {
|
||||||
|
println!("{:?}", parsed);
|
||||||
|
|
||||||
|
ctx.send(CreateReply::default().embed(embed(ctx, "", "", "").await.unwrap()))
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
Err(err) => println!("Something is messed up! {:?}", err),
|
||||||
|
},
|
||||||
|
reqwest::StatusCode::UNAUTHORIZED => {
|
||||||
|
println!("Unauthorized.. Uoops!!");
|
||||||
|
}
|
||||||
|
error => {
|
||||||
|
println!("Something went wrong: {:?}", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
struct Definition {
|
||||||
|
definition: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
struct Meaning {
|
||||||
|
partOfSpeech: String,
|
||||||
|
definitions: Vec<Definition>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
struct Phonetic {
|
||||||
|
text: Option<String>,
|
||||||
|
audio: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
struct Word {
|
||||||
|
word: String,
|
||||||
|
phonetics: Vec<Phonetic>,
|
||||||
|
meanings: Vec<Meaning>,
|
||||||
|
}
|
||||||
23
src/commands/tools/help.rs
Normal file
23
src/commands/tools/help.rs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
use crate::{Context, Error};
|
||||||
|
|
||||||
|
/// Prints this help message; aliases: help, huh, welp
|
||||||
|
#[poise::command(
|
||||||
|
prefix_command,
|
||||||
|
slash_command,
|
||||||
|
track_edits,
|
||||||
|
aliases("huh", "welp"),
|
||||||
|
category = "Help"
|
||||||
|
)]
|
||||||
|
pub async fn help(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[description = "Specific command to show help about"] command: Option<String>,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let config = poise::builtins::HelpConfiguration {
|
||||||
|
extra_text_at_bottom: "\
|
||||||
|
Use /help command for more info on a command.
|
||||||
|
You can edit you message to the bot and the bot will edit its response.",
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
poise::builtins::help(ctx, command.as_deref(), config).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
14
src/commands/tools/ip.rs
Normal file
14
src/commands/tools/ip.rs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
|
use crate::{commands::embeds::embed, Context, Error};
|
||||||
|
|
||||||
|
/// Shows IP information
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Tools")]
|
||||||
|
pub async fn ip(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default().embed(embed(ctx, "IP Info", "Work in progress", "").await.unwrap()),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
14
src/commands/tools/metar.rs
Normal file
14
src/commands/tools/metar.rs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
|
use crate::{commands::embeds::embed, Context, Error};
|
||||||
|
|
||||||
|
/// Prints metar for provided airport
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Tools")]
|
||||||
|
pub async fn metar(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default().embed(embed(ctx, "Metar", "Work in progress", "").await.unwrap()),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
pub mod ping;
|
|
||||||
18
src/commands/tools/owoify.rs
Normal file
18
src/commands/tools/owoify.rs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
use owoify::OwOifiable;
|
||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
|
use crate::{commands::embeds::embed, Context, Error};
|
||||||
|
|
||||||
|
/// Owoifies whatever you want uwu
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Tools")]
|
||||||
|
pub async fn owoify(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[description = "Text to owoify w-woify OwO"]
|
||||||
|
#[rest]
|
||||||
|
text: String,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
ctx.send(CreateReply::default().embed(embed(ctx, "OwO", &text.owoify(), "").await.unwrap()))
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
|
use crate::{Context, Error};
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
use serenity::{all::Message, client::Context, framework::standard::{macros::command, CommandResult}};
|
/// Pings you backs with a response time
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Tools")]
|
||||||
|
pub async fn ping(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
let system_now = SystemTime::now()
|
||||||
|
.duration_since(SystemTime::UNIX_EPOCH)
|
||||||
|
.unwrap()
|
||||||
|
.as_millis() as i64;
|
||||||
|
|
||||||
use crate::commands::misc::check_msg;
|
let message_now = ctx.created_at().timestamp_millis();
|
||||||
|
|
||||||
#[command]
|
let response = format!("Pong! (latency: {} ms)", system_now - message_now);
|
||||||
async fn ping(ctx: &Context, msg: &Message) -> CommandResult {
|
ctx.say(response).await?;
|
||||||
let system_now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_millis() as i64;
|
|
||||||
let message_now = msg.timestamp.timestamp_millis();
|
|
||||||
|
|
||||||
// println!("System Time: {} ||| Message Time: {}", system_now, message_now);
|
|
||||||
|
|
||||||
check_msg(msg.reply(ctx, format!("Pong! (latency: {} ms)", system_now - message_now)).await);
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
30
src/commands/tools/posix.rs
Normal file
30
src/commands/tools/posix.rs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
use std::time::SystemTime;
|
||||||
|
|
||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
|
use crate::{commands::embeds::embed, Context, Error};
|
||||||
|
|
||||||
|
/// Prints current time in POSIX format
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Tools")]
|
||||||
|
pub async fn posix(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
let time = SystemTime::now()
|
||||||
|
.duration_since(SystemTime::UNIX_EPOCH)
|
||||||
|
.unwrap()
|
||||||
|
.as_millis();
|
||||||
|
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default().embed(
|
||||||
|
embed(
|
||||||
|
ctx,
|
||||||
|
"The time is",
|
||||||
|
"since Jan 1st 1970",
|
||||||
|
&format!("{} ms", time),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
47
src/commands/tools/qr.rs
Normal file
47
src/commands/tools/qr.rs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
use poise::serenity_prelude::{
|
||||||
|
Color, CreateEmbed, CreateEmbedAuthor, CreateEmbedFooter, Timestamp,
|
||||||
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
|
use crate::{Context, Error};
|
||||||
|
use url::form_urlencoded;
|
||||||
|
|
||||||
|
/// Creates a qr code from text
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Tools")]
|
||||||
|
pub async fn qr(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[description = "Message to encode"]
|
||||||
|
#[rest]
|
||||||
|
message: String,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let response = CreateReply::default().embed(generate_embed(ctx, message).await.unwrap());
|
||||||
|
ctx.send(response).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn generate_embed(ctx: Context<'_>, message: String) -> Result<CreateEmbed, Error> {
|
||||||
|
let timestamp = Timestamp::now();
|
||||||
|
let data: String = form_urlencoded::byte_serialize(message.as_bytes()).collect();
|
||||||
|
let url = format!(
|
||||||
|
"http://api.qrserver.com/v1/create-qr-code/?data={}&size=1000x1000&ecc=Q&margin=8",
|
||||||
|
data
|
||||||
|
);
|
||||||
|
|
||||||
|
let embed = CreateEmbed::default()
|
||||||
|
.author(
|
||||||
|
CreateEmbedAuthor::new("Your message as a QR Code!")
|
||||||
|
.icon_url(ctx.author().clone().face()),
|
||||||
|
)
|
||||||
|
.colour(Color::from_rgb(255, 58, 97))
|
||||||
|
.title("Your QR Code:")
|
||||||
|
.url(url.clone())
|
||||||
|
.image(url)
|
||||||
|
.timestamp(timestamp)
|
||||||
|
.footer(
|
||||||
|
CreateEmbedFooter::new(ctx.cache().current_user().name.to_string())
|
||||||
|
.icon_url(ctx.cache().current_user().face()),
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(embed)
|
||||||
|
}
|
||||||
7
src/commands/tools/register.rs
Normal file
7
src/commands/tools/register.rs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
use crate::{Context, Error};
|
||||||
|
|
||||||
|
#[poise::command(prefix_command, hide_in_help, owners_only)]
|
||||||
|
pub async fn register(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
poise::builtins::register_application_commands_buttons(ctx).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
14
src/commands/tools/taf.rs
Normal file
14
src/commands/tools/taf.rs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
|
use crate::{commands::embeds::embed, Context, Error};
|
||||||
|
|
||||||
|
/// Returns taf for provided airport
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Tools")]
|
||||||
|
pub async fn taf(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default().embed(embed(ctx, "Taf", "Work in progress", "").await.unwrap()),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
48
src/commands/tools/uptime.rs
Normal file
48
src/commands/tools/uptime.rs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
use once_cell::sync::Lazy;
|
||||||
|
use poise::CreateReply;
|
||||||
|
use std::sync::Mutex;
|
||||||
|
|
||||||
|
use crate::{commands::embeds::embed, Context, Error};
|
||||||
|
|
||||||
|
pub static PROCESS_UPTIME: Lazy<Mutex<std::time::SystemTime>> =
|
||||||
|
Lazy::new(|| Mutex::new(std::time::SystemTime::now()));
|
||||||
|
|
||||||
|
/// Checks how long the bot has been running
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Tools")]
|
||||||
|
pub async fn uptime(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
|
let start = *PROCESS_UPTIME.lock().unwrap();
|
||||||
|
let uptime = std::time::SystemTime::now().duration_since(start).unwrap();
|
||||||
|
|
||||||
|
let (days, hours, minutes, seconds) = (
|
||||||
|
uptime.as_secs() / 86400,
|
||||||
|
(uptime.as_secs() / 3600) % 24,
|
||||||
|
(uptime.as_secs() / 60) % 60,
|
||||||
|
uptime.as_secs() % 60,
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut message = format!(
|
||||||
|
"I have been awake for {} days, {} hours, {} minutes and {} seconds!",
|
||||||
|
days, hours, minutes, seconds
|
||||||
|
);
|
||||||
|
|
||||||
|
if days != 0 {
|
||||||
|
message = format!("I have been awake for {} days!", days);
|
||||||
|
}
|
||||||
|
|
||||||
|
if days == 0 && hours != 0 {
|
||||||
|
message = format!("I have been awake for {} hours!", hours);
|
||||||
|
}
|
||||||
|
|
||||||
|
if days == 0 && hours == 0 && minutes != 0 {
|
||||||
|
message = format!("I have been awake for {} minutes!", minutes);
|
||||||
|
}
|
||||||
|
|
||||||
|
if days == 0 && hours == 0 && minutes == 0 && seconds != 0 {
|
||||||
|
message = format!("I have been awake for {} seconds!", seconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.send(CreateReply::default().embed(embed(ctx, "Uptime", "", &message).await.unwrap()))
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
78
src/commands/tools/verse.rs
Normal file
78
src/commands/tools/verse.rs
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
use crate::{
|
||||||
|
commands::embeds::{embed, error_embed},
|
||||||
|
Context, Error,
|
||||||
|
};
|
||||||
|
use poise::CreateReply;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use url::form_urlencoded;
|
||||||
|
|
||||||
|
/// Reference Bible by verse
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Tools")]
|
||||||
|
pub async fn verse(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[description = "Latin?"]
|
||||||
|
#[flag]
|
||||||
|
latin: bool,
|
||||||
|
#[description = "BOOK+CHAPTER:VERSE"]
|
||||||
|
#[rest]
|
||||||
|
verse: String,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let data: String = form_urlencoded::byte_serialize(verse.as_bytes()).collect();
|
||||||
|
let translation = if latin { "clementine" } else { "web" };
|
||||||
|
let client = reqwest::Client::new();
|
||||||
|
let response = client
|
||||||
|
.get(format!(
|
||||||
|
"https://bible-api.com/{}?translation={}",
|
||||||
|
data, translation
|
||||||
|
))
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
match response.status() {
|
||||||
|
reqwest::StatusCode::OK => {
|
||||||
|
match response.json::<APIResponse>().await {
|
||||||
|
Ok(parsed) => {
|
||||||
|
if parsed.text.len() > 4000 {
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default()
|
||||||
|
.embed(error_embed(ctx, "Quoted text is too long!").await.unwrap()),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default().embed(
|
||||||
|
embed(
|
||||||
|
ctx,
|
||||||
|
&parsed.translation_name,
|
||||||
|
&parsed.text,
|
||||||
|
&parsed.reference,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
Err(err) => println!("Something is messed up! {:?}", err),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
reqwest::StatusCode::UNAUTHORIZED => {
|
||||||
|
println!("Unauthorized.. Uoops!!");
|
||||||
|
}
|
||||||
|
error => {
|
||||||
|
println!("Something went wrong: {:?}", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
struct APIResponse {
|
||||||
|
reference: String,
|
||||||
|
text: String,
|
||||||
|
translation_name: String,
|
||||||
|
translation_note: String,
|
||||||
|
}
|
||||||
19
src/commands/tools/weather.rs
Normal file
19
src/commands/tools/weather.rs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
use poise::CreateReply;
|
||||||
|
|
||||||
|
use crate::{commands::embeds::embed, Context, Error};
|
||||||
|
|
||||||
|
/// Shows weather for provided location
|
||||||
|
#[poise::command(prefix_command, slash_command, category = "Tools")]
|
||||||
|
pub async fn weather(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[description = "Provide a city name"]
|
||||||
|
#[rest]
|
||||||
|
_location: String,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
ctx.send(
|
||||||
|
CreateReply::default().embed(embed(ctx, "Weather", "Work in progress", "").await.unwrap()),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
8
src/http.rs
Normal file
8
src/http.rs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
use poise::serenity_prelude::prelude::TypeMapKey;
|
||||||
|
use reqwest::Client as HttpClient;
|
||||||
|
|
||||||
|
pub struct HttpKey;
|
||||||
|
|
||||||
|
impl TypeMapKey for HttpKey {
|
||||||
|
type Value = HttpClient;
|
||||||
|
}
|
||||||
200
src/main.rs
200
src/main.rs
@@ -1,86 +1,160 @@
|
|||||||
use serenity::gateway::ActivityData;
|
use commands::tools::uptime::PROCESS_UPTIME;
|
||||||
use serenity::model::prelude::Message;
|
use poise::serenity_prelude::{self as serenity, ActivityData};
|
||||||
use songbird::SerenityInit;
|
|
||||||
|
|
||||||
use reqwest::Client as HttpClient;
|
use reqwest::Client as HttpClient;
|
||||||
|
use songbird::SerenityInit;
|
||||||
use serenity::client::Context;
|
use std::sync::Arc;
|
||||||
|
use std::time::Duration;
|
||||||
use serenity::{
|
use tracing::{error, info, warn};
|
||||||
async_trait,
|
|
||||||
client::{Client, EventHandler},
|
|
||||||
framework::{
|
|
||||||
standard::{macros::group, macros::hook, Configuration},
|
|
||||||
StandardFramework,
|
|
||||||
},
|
|
||||||
model::gateway::Ready,
|
|
||||||
prelude::GatewayIntents,
|
|
||||||
};
|
|
||||||
|
|
||||||
use tracing::info;
|
|
||||||
|
|
||||||
mod commands;
|
mod commands;
|
||||||
|
mod http;
|
||||||
|
|
||||||
// music management commands
|
use crate::commands::music;
|
||||||
use crate::commands::music::deafen::*;
|
use crate::commands::tools;
|
||||||
use crate::commands::music::join::*;
|
use crate::http::HttpKey;
|
||||||
use crate::commands::music::leave::*;
|
|
||||||
use crate::commands::music::mute::*;
|
|
||||||
use crate::commands::music::play::*;
|
|
||||||
use crate::commands::music::queue::*;
|
|
||||||
use crate::commands::music::skip::*;
|
|
||||||
use crate::commands::music::stop::*;
|
|
||||||
|
|
||||||
// tools
|
type Error = Box<dyn std::error::Error + Send + Sync>;
|
||||||
use crate::commands::tools::ping::*;
|
type Context<'a> = poise::Context<'a, Data, Error>;
|
||||||
|
|
||||||
// kashi
|
pub struct Data {
|
||||||
use crate::commands::kashi::kashi::*;
|
pub http_client: HttpClient,
|
||||||
|
|
||||||
struct Handler;
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl EventHandler for Handler {
|
|
||||||
async fn ready(&self, ctx: Context, ready: Ready) {
|
|
||||||
info!("{} [{}] connected successfully!", ready.user.name, ready.user.id);
|
|
||||||
let prefix = std::env::var("PREFIX").expect("Environment variable `PREFIX` not found!");
|
|
||||||
ctx.set_activity(Some(ActivityData::listening(prefix + "help")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[hook]
|
async fn on_error(error: poise::FrameworkError<'_, Data, Error>) {
|
||||||
async fn before(_: &Context, msg: &Message, command_name: &str) -> bool {
|
match error {
|
||||||
info!(
|
poise::FrameworkError::Setup { error, .. } => panic!("Failed to start bot {:?}", error),
|
||||||
"Received command [{}] from user [{}]",
|
poise::FrameworkError::Command { error, ctx, .. } => {
|
||||||
command_name, msg.author.name
|
warn!("Error in command `{}`: {:?}", ctx.command().name, error);
|
||||||
);
|
}
|
||||||
true
|
error => {
|
||||||
|
if let Err(e) = poise::builtins::on_error(error).await {
|
||||||
|
error!("Error while handling error: {}", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[group]
|
|
||||||
#[commands(
|
|
||||||
join, deafen, leave, mute, play, ping, kashi, queue, stop, skip
|
|
||||||
)]
|
|
||||||
struct General;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
dotenv::dotenv().expect("Failed to load .env file.");
|
|
||||||
tracing_subscriber::fmt::init();
|
tracing_subscriber::fmt::init();
|
||||||
|
dotenv::dotenv().expect("Failed to load .env file.");
|
||||||
|
|
||||||
|
let _ = *PROCESS_UPTIME.lock().unwrap();
|
||||||
|
|
||||||
let token =
|
let token =
|
||||||
std::env::var("DISCORD_TOKEN").expect("Environment variable `DISCORD_TOKEN` not found!");
|
std::env::var("DISCORD_TOKEN").expect("Environment variable `DISCORD_TOKEN` not found!");
|
||||||
let prefix = std::env::var("PREFIX").expect("Environment variable `PREFIX` not found!");
|
let prefix = std::env::var("PREFIX").expect("Environment variable `PREFIX` not found!");
|
||||||
|
|
||||||
let framework = StandardFramework::new().before(before).group(&GENERAL_GROUP);
|
let commands = vec![
|
||||||
framework.configure(Configuration::new().prefix(prefix));
|
music::deafen(),
|
||||||
|
music::join(),
|
||||||
|
music::leave(),
|
||||||
|
music::mute(),
|
||||||
|
music::pause(),
|
||||||
|
music::play(),
|
||||||
|
music::queue(),
|
||||||
|
music::repeat(),
|
||||||
|
music::resume(),
|
||||||
|
music::seek(),
|
||||||
|
music::skip(),
|
||||||
|
music::stop(),
|
||||||
|
music::volume(),
|
||||||
|
music::soundboard::effect(),
|
||||||
|
music::soundboard::stream(),
|
||||||
|
tools::ai(),
|
||||||
|
tools::dice(),
|
||||||
|
tools::dictionary(),
|
||||||
|
tools::help(),
|
||||||
|
tools::ip(),
|
||||||
|
tools::metar(),
|
||||||
|
tools::owoify(),
|
||||||
|
tools::ping(),
|
||||||
|
tools::posix(),
|
||||||
|
tools::qr(),
|
||||||
|
tools::register(),
|
||||||
|
tools::taf(),
|
||||||
|
tools::uptime(),
|
||||||
|
tools::verse(),
|
||||||
|
tools::weather(),
|
||||||
|
];
|
||||||
|
|
||||||
let intents = GatewayIntents::non_privileged() | GatewayIntents::MESSAGE_CONTENT;
|
let options = poise::FrameworkOptions {
|
||||||
|
commands,
|
||||||
|
prefix_options: poise::PrefixFrameworkOptions {
|
||||||
|
prefix: Some(prefix.to_string()),
|
||||||
|
edit_tracker: Some(Arc::new(poise::EditTracker::for_timespan(
|
||||||
|
Duration::from_secs(3600),
|
||||||
|
))),
|
||||||
|
additional_prefixes: vec![],
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
|
||||||
let mut client = Client::builder(&token, intents)
|
on_error: |error| Box::pin(on_error(error)),
|
||||||
|
|
||||||
|
pre_command: |ctx| {
|
||||||
|
Box::pin(async move {
|
||||||
|
info!("Executing command {}...", ctx.command().qualified_name);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
post_command: |ctx| {
|
||||||
|
Box::pin(async move {
|
||||||
|
info!("Executed command {}!", ctx.command().qualified_name);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
command_check: Some(|ctx| {
|
||||||
|
Box::pin(async move {
|
||||||
|
if ctx.author().id == 123456789 {
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
|
Ok(true)
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
|
||||||
|
skip_checks_for_owners: false,
|
||||||
|
event_handler: |_ctx, event, _framework, _data| {
|
||||||
|
Box::pin(async move {
|
||||||
|
info!(
|
||||||
|
"Got an event in event handler: {:?}",
|
||||||
|
event.snake_case_name()
|
||||||
|
);
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
},
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let framework = poise::Framework::builder()
|
||||||
|
.setup(move |ctx, ready, framework| {
|
||||||
|
Box::pin(async move {
|
||||||
|
info!(
|
||||||
|
"{} [{}] connected successfully!",
|
||||||
|
ready.user.name, ready.user.id
|
||||||
|
);
|
||||||
|
ctx.set_activity(Some(ActivityData::listening(prefix + "help")));
|
||||||
|
// poise::builtins::register_globally(ctx, &framework.options().commands).await?;
|
||||||
|
poise::builtins::register_in_guild(
|
||||||
|
ctx,
|
||||||
|
&framework.options().commands,
|
||||||
|
512680330495524873.into(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(Data {
|
||||||
|
http_client: HttpClient::new(),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.options(options)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
let intents =
|
||||||
|
serenity::GatewayIntents::non_privileged() | serenity::GatewayIntents::MESSAGE_CONTENT;
|
||||||
|
|
||||||
|
let mut client = serenity::ClientBuilder::new(token, intents)
|
||||||
.framework(framework)
|
.framework(framework)
|
||||||
.register_songbird()
|
.register_songbird()
|
||||||
.event_handler(Handler)
|
|
||||||
.type_map_insert::<HttpKey>(HttpClient::new())
|
.type_map_insert::<HttpKey>(HttpClient::new())
|
||||||
.await
|
.await
|
||||||
.expect("Error creating client");
|
.expect("Error creating client");
|
||||||
@@ -89,9 +163,9 @@ async fn main() {
|
|||||||
let _ = client
|
let _ = client
|
||||||
.start()
|
.start()
|
||||||
.await
|
.await
|
||||||
.map_err(|why| println!("Client ended: {:?}", why));
|
.map_err(|why| error!("Client ended: {:?}", why));
|
||||||
});
|
});
|
||||||
|
|
||||||
let _signal_err = tokio::signal::ctrl_c().await;
|
let _signal_err = tokio::signal::ctrl_c().await;
|
||||||
println!("Recieved Ctrl-C, shutting down.");
|
warn!("Recieved Ctrl-C, shutting down.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user