feat: Setup Project
This commit is contained in:
parent
f765b8e253
commit
3b56224a5b
5
.gitignore
vendored
5
.gitignore
vendored
@ -34,6 +34,11 @@ yarn-error.log
|
||||
testem.log
|
||||
/typings
|
||||
|
||||
|
||||
/target
|
||||
|
||||
.env
|
||||
|
||||
# System Files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
9428
.pnp.cjs
generated
Executable file
9428
.pnp.cjs
generated
Executable file
File diff suppressed because one or more lines are too long
2126
.pnp.loader.mjs
generated
Normal file
2126
.pnp.loader.mjs
generated
Normal file
File diff suppressed because it is too large
Load Diff
BIN
.yarn/install-state.gz
Normal file
BIN
.yarn/install-state.gz
Normal file
Binary file not shown.
2393
Cargo.lock
generated
Normal file
2393
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
11
Cargo.toml
11
Cargo.toml
@ -1,6 +1,13 @@
|
||||
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = []
|
||||
resolver = '2'
|
||||
members = [
|
||||
'apps/bot',
|
||||
]
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
|
||||
[workspace.dependencies]
|
||||
poise = "0.6.1"
|
||||
tokio = {version = "1.45.0", features = ["rt-multi-thread"]}
|
||||
|
95
README.md
95
README.md
@ -1,95 +0,0 @@
|
||||
# BotTerre
|
||||
|
||||
<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a>
|
||||
|
||||
✨ Your new, shiny [Nx workspace](https://nx.dev) is ready ✨.
|
||||
|
||||
Run `npx nx graph` to visually explore what got created. Now, let's get you up to speed!
|
||||
|
||||
## Run tasks
|
||||
|
||||
To run tasks with Nx use:
|
||||
|
||||
```sh
|
||||
npx nx <target> <project-name>
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```sh
|
||||
npx nx build myproject
|
||||
```
|
||||
|
||||
These targets are either [inferred automatically](https://nx.dev/concepts/inferred-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) or defined in the `project.json` or `package.json` files.
|
||||
|
||||
[More about running tasks in the docs »](https://nx.dev/features/run-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
||||
|
||||
## Add new projects
|
||||
|
||||
While you could add new projects to your workspace manually, you might want to leverage [Nx plugins](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) and their [code generation](https://nx.dev/features/generate-code?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) feature.
|
||||
|
||||
To install a new plugin you can use the `nx add` command. Here's an example of adding the React plugin:
|
||||
```sh
|
||||
npx nx add @nx/react
|
||||
```
|
||||
|
||||
Use the plugin's generator to create new projects. For example, to create a new React app or library:
|
||||
|
||||
```sh
|
||||
# Generate an app
|
||||
npx nx g @nx/react:app demo
|
||||
|
||||
# Generate a library
|
||||
npx nx g @nx/react:lib some-lib
|
||||
```
|
||||
|
||||
You can use `npx nx list` to get a list of installed plugins. Then, run `npx nx list <plugin-name>` to learn about more specific capabilities of a particular plugin. Alternatively, [install Nx Console](https://nx.dev/getting-started/editor-setup?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) to browse plugins and generators in your IDE.
|
||||
|
||||
[Learn more about Nx plugins »](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) | [Browse the plugin registry »](https://nx.dev/plugin-registry?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
||||
|
||||
## Set up CI!
|
||||
|
||||
### Step 1
|
||||
|
||||
To connect to Nx Cloud, run the following command:
|
||||
|
||||
```sh
|
||||
npx nx connect
|
||||
```
|
||||
|
||||
Connecting to Nx Cloud ensures a [fast and scalable CI](https://nx.dev/ci/intro/why-nx-cloud?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) pipeline. It includes features such as:
|
||||
|
||||
- [Remote caching](https://nx.dev/ci/features/remote-cache?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
||||
- [Task distribution across multiple machines](https://nx.dev/ci/features/distribute-task-execution?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
||||
- [Automated e2e test splitting](https://nx.dev/ci/features/split-e2e-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
||||
- [Task flakiness detection and rerunning](https://nx.dev/ci/features/flaky-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
||||
|
||||
### Step 2
|
||||
|
||||
Use the following command to configure a CI workflow for your workspace:
|
||||
|
||||
```sh
|
||||
npx nx g ci-workflow
|
||||
```
|
||||
|
||||
[Learn more about Nx on CI](https://nx.dev/ci/intro/ci-with-nx#ready-get-started-with-your-provider?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
||||
|
||||
## Install Nx Console
|
||||
|
||||
Nx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ.
|
||||
|
||||
[Install Nx Console »](https://nx.dev/getting-started/editor-setup?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
||||
|
||||
## Useful links
|
||||
|
||||
Learn more:
|
||||
|
||||
- [Learn about Nx on CI](https://nx.dev/ci/intro/ci-with-nx?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
||||
- [Releasing Packages with Nx release](https://nx.dev/features/manage-releases?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
||||
- [What are Nx plugins?](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
||||
|
||||
And join the Nx community:
|
||||
- [Discord](https://go.nx.dev/community)
|
||||
- [Follow us on X](https://twitter.com/nxdevtools) or [LinkedIn](https://www.linkedin.com/company/nrwl)
|
||||
- [Our Youtube channel](https://www.youtube.com/@nxdevtools)
|
||||
- [Our blog](https://nx.dev/blog?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
|
31
Readme.md
Normal file
31
Readme.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Bot Terre
|
||||
|
||||
## Feature
|
||||
|
||||
- Trivial Daily
|
||||
|
||||
### Trivial Daily
|
||||
|
||||
- Heure configurable (Pose de la question, Relevé des gagnant optionnel)
|
||||
- Nombre de gagnant
|
||||
- Canal Configurable
|
||||
- Question Random
|
||||
- Nom de l'event
|
||||
- Embed ou Message template ?
|
||||
- List des questions
|
||||
- Points ( 1er == 3, 2eme == 2, 3eme = 1; x = 0 ?)
|
||||
- Role a ping
|
||||
|
||||
#### Command
|
||||
|
||||
- [ADMIN] trivial init : Creer une activité Trivial Daily
|
||||
- [ADMIN] trivial list : List les activité
|
||||
- [ADMIN] trivial config : Modification des paramétre de base d'un event
|
||||
- [ADMIN] trivial add-question : Ajout de question + réponse ou X réponse
|
||||
- [ADMIN] trivial del-question : Suppression de question
|
||||
- [ADMIN] trivial load-question : Charge un fichier/lien de question
|
||||
- [ADMIN] trivial choose-chan : Choix du channel
|
||||
- trivial scoreboard : Scoreboard
|
||||
- trivial score : Score d'une personne par défaut le sien
|
||||
- trivial top : Top X par défaut 3
|
||||
- [ADMIN] trivial balance : Modifie le score d'une personne +/-/=
|
11
Taskfile.yaml
Normal file
11
Taskfile.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
version: "2.0"
|
||||
|
||||
|
||||
tasks:
|
||||
init:
|
||||
desc: "Initialize the project"
|
||||
cmds:
|
||||
- echo "Initializing project..."
|
||||
- mkdir -p src tests
|
||||
- touch src/main.py tests/test_main.py
|
||||
silent: true
|
11
apps/bot/Cargo.toml
Normal file
11
apps/bot/Cargo.toml
Normal file
@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "bot"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
||||
[dependencies]
|
||||
poise = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
63
apps/bot/project.json
Normal file
63
apps/bot/project.json
Normal file
@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "bot",
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"projectType": "application",
|
||||
"sourceRoot": "apps/bot/src",
|
||||
"targets": {
|
||||
"build": {
|
||||
"cache": true,
|
||||
"executor": "@monodon/rust:build",
|
||||
"outputs": [
|
||||
"{options.target-dir}"
|
||||
],
|
||||
"options": {
|
||||
"target-dir": "dist/target/bot"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"release": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"cache": true,
|
||||
"executor": "@monodon/rust:test",
|
||||
"outputs": [
|
||||
"{options.target-dir}"
|
||||
],
|
||||
"options": {
|
||||
"target-dir": "dist/target/bot"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"release": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"cache": true,
|
||||
"executor": "@monodon/rust:lint",
|
||||
"outputs": [
|
||||
"{options.target-dir}"
|
||||
],
|
||||
"options": {
|
||||
"target-dir": "dist/target/bot"
|
||||
}
|
||||
},
|
||||
"run": {
|
||||
"executor": "@monodon/rust:run",
|
||||
"outputs": [
|
||||
"{options.target-dir}"
|
||||
],
|
||||
"options": {
|
||||
"target-dir": "dist/target/bot"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"release": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": []
|
||||
}
|
19
apps/bot/src/dotenv/mod.rs
Normal file
19
apps/bot/src/dotenv/mod.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use std::{env::set_var, io::Read};
|
||||
|
||||
|
||||
// Load environment variables from a .env file without external dependencies
|
||||
pub fn load_dot_env() {
|
||||
if let Ok(mut file) = std::fs::File::open(".env") {
|
||||
let mut contents = String::new();
|
||||
if file.read_to_string(&mut contents).is_ok() {
|
||||
for line in contents.lines() {
|
||||
if line.is_empty() || line.starts_with('#') {
|
||||
continue; // Skip empty lines and comments
|
||||
}
|
||||
if let Some((key, value)) = line.split_once('=') {
|
||||
unsafe { set_var(key.trim(), value.trim().replace("\"", "")) };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
45
apps/bot/src/main.rs
Normal file
45
apps/bot/src/main.rs
Normal file
@ -0,0 +1,45 @@
|
||||
use poise::serenity_prelude as serenity;
|
||||
|
||||
pub mod dotenv;
|
||||
|
||||
struct Data {} // User data, which is stored and accessible in all command invocations
|
||||
type Error = Box<dyn std::error::Error + Send + Sync>;
|
||||
type Context<'a> = poise::Context<'a, Data, Error>;
|
||||
|
||||
/// Displays your or another user's account creation date
|
||||
#[poise::command(slash_command, prefix_command)]
|
||||
async fn age(
|
||||
ctx: Context<'_>,
|
||||
#[description = "Selected user"] user: Option<serenity::User>,
|
||||
) -> Result<(), Error> {
|
||||
let u = user.as_ref().unwrap_or_else(|| ctx.author());
|
||||
let response = format!("{}'s account was created at {}", u.name, u.created_at());
|
||||
ctx.say(response).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
dotenv::load_dot_env(); // Load environment variables from .env file
|
||||
let token = std::env::var("DISCORD_TOKEN").expect("missing DISCORD_TOKEN");
|
||||
print!("Starting bot with token: {}", token);
|
||||
let intents = serenity::GatewayIntents::non_privileged();
|
||||
|
||||
let framework = poise::Framework::builder()
|
||||
.options(poise::FrameworkOptions {
|
||||
commands: vec![age()],
|
||||
..Default::default()
|
||||
})
|
||||
.setup(|ctx, _ready, framework| {
|
||||
Box::pin(async move {
|
||||
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
|
||||
Ok(Data {})
|
||||
})
|
||||
})
|
||||
.build();
|
||||
|
||||
let client = serenity::ClientBuilder::new(token, intents)
|
||||
.framework(framework)
|
||||
.await;
|
||||
client.unwrap().start().await.unwrap();
|
||||
}
|
14
compose.yaml
Normal file
14
compose.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
services:
|
||||
database:
|
||||
image: clickhouse/clickhouse-server:latest
|
||||
ports:
|
||||
- 8123:8123
|
||||
- 9000:9000
|
||||
ulimits:
|
||||
nofile:
|
||||
soft: 262144
|
||||
hard: 262144
|
||||
environment:
|
||||
CLICKHOUSE_USER: default
|
||||
CLICKHOUSE_PASSWORD: password
|
||||
CLICKHOUSE_DB: default
|
@ -2,7 +2,9 @@
|
||||
"name": "@bot-terre/source",
|
||||
"version": "0.0.0",
|
||||
"license": "MIT",
|
||||
"scripts": {},
|
||||
"scripts": {
|
||||
"nx": "nx"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@monodon/rust": "2.3.0"
|
||||
@ -10,5 +12,6 @@
|
||||
"devDependencies": {
|
||||
"@nx/workspace": "21.0.3",
|
||||
"nx": "21.0.3"
|
||||
}
|
||||
},
|
||||
"packageManager": "yarn@4.9.1"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user