Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
25 changes: 19 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
---
name: CI

permissions:
actions: write
checks: write
contents: write
id-token: write
pull-requests: write
security-events: write
statuses: write

on:
push:
branches: [ master ]
Expand All @@ -16,7 +25,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup rust
uses: ./.github/actions/setup-rust
Expand All @@ -32,7 +41,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup rust
uses: ./.github/actions/setup-rust
Expand All @@ -51,7 +60,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup rust
uses: ./.github/actions/setup-rust
Expand All @@ -67,11 +76,15 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# super-linter needs the full git history to get the
# list of files that changed across commits
fetch-depth: 0

- name: Lint Code Base
uses: github/super-linter/slim@v4
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_EDITORCONFIG: false
VALIDATE_EDITORCONFIG: false
13 changes: 11 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
---
name: Release

permissions:
actions: write
checks: write
contents: write
id-token: write
pull-requests: write
security-events: write
statuses: write

on:
release:
types: [ published ]
Expand All @@ -10,7 +19,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}

Expand All @@ -31,4 +40,4 @@ jobs:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./x86_64-linux.zip
asset_content_type: application/zip
asset_name: x86_64-linux.zip
asset_name: x86_64-linux.zip
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ panic = "abort"
incremental = true

[dependencies]
tokio = { version = "*", features = ["macros", "rt-multi-thread", "time"] }
serenity = { version = "*", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] }
clap = { version = "*", features = ["derive"] }
tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread", "time"] }
serenity = { default-features = false, features = ["http", "model", "utils", "rustls_backend", "client", "gateway"], version = "0.12.1" }
clap = { version = "4.5.4", features = ["derive"] }
4 changes: 2 additions & 2 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.65.0"
channel = "1.78.0"
components = ["rustfmt", "clippy"]
targets = ["x86_64-unknown-linux-gnu"]
targets = ["x86_64-unknown-linux-gnu"]
2 changes: 2 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
RUSTFLAGS="-C link-arg=-s" cargo build --release --target "$1"
2 changes: 2 additions & 0 deletions scripts/pack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
./scripts/publish-x86-64-Linux.sh && cp LICENSE output/ && zip -9 -r x86_64-linux.zip output/
2 changes: 2 additions & 0 deletions scripts/publish-x86-64-Linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
./scripts/publish.sh x86_64-unknown-linux-gnu
2 changes: 2 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
./scripts/build.sh "$1" && mkdir -p "./output/" && cp "./target/$1/release/dstub" "./output/dstub" && cp LICENSE "./output/" && mkdir -p "./output/"
2 changes: 2 additions & 0 deletions scripts/run-clippy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
cargo clippy --release -- -D warnings
76 changes: 42 additions & 34 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,54 +1,62 @@
use clap::{Parser, ValueEnum};
use tokio::time::sleep;
use std::time::Duration;
use serenity::model::user::OnlineStatus;
use serenity::model::gateway::{Activity, GatewayIntents};
use serenity::model::user::OnlineStatus;
use serenity::prelude::*;
use std::time::Duration;
use tokio::time::sleep;

#[derive(Parser, Debug, Clone)]
#[command(author, version, about, long_about = None)]
struct Args {
#[arg(short, long)]
token: String,
#[arg(short, long)]
token: String,

#[arg(short, long)]
status_message: String,
#[arg(short, long)]
status_message: String,

#[arg(value_enum)]
status_type: Status,
#[arg(value_enum)]
status_type: Status,
}

#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug)]
enum Status {
/// Show online status
Online,
/// Show online status
Online,

/// Show Do Not Disturb status
DoNotDisturb,
/// Show Do Not Disturb status
DoNotDisturb,

/// Show Idle status
Idle,
/// Show Idle status
Idle,
}

#[tokio::main]
async fn main() {
let args = Args::parse();

let mut client = Client::builder(&args.token, GatewayIntents::empty()).await.unwrap();
let manager = client.shard_manager.clone();
tokio::spawn(async move {
let status = match args.status_type {
Status::Online => OnlineStatus::Online,
Status::DoNotDisturb => OnlineStatus::DoNotDisturb,
Status::Idle => OnlineStatus::Idle
};
sleep(Duration::from_secs(15)).await;

for shard in manager.lock().await.runners.lock().await.iter_mut() {
shard.1.runner_tx.set_presence(Some(Activity::playing(args.status_message.clone())), status);
}
});
if let Err(why) = client.start_autosharded().await {
println!("Client error: {:?}", why);
}
let args = Args::parse();

let mut client = Client::builder(&args.token, GatewayIntents::empty())
.await
.unwrap();

let manager = client.shard_manager.clone();

tokio::spawn(async move {
let status = match args.status_type {
Status::Online => OnlineStatus::Online,
Status::DoNotDisturb => OnlineStatus::DoNotDisturb,
Status::Idle => OnlineStatus::Idle,
};
sleep(Duration::from_secs(15)).await;

for shard in manager.runners.lock().await.iter_mut() {
shard
.1
.runner_tx
.set_presence(Some(ActivityData::playing(args.status_message.clone())), status);
}
});

if let Err(why) = client.start_autosharded().await {
println!("Client error: {:?}", why);
}
}