Compare commits
No commits in common. "main" and "#22_Role-Joiner" have entirely different histories.
main
...
#22_Role-J
7 changed files with 50 additions and 114 deletions
37
.gitattributes
vendored
37
.gitattributes
vendored
|
@ -1,37 +0,0 @@
|
|||
# Git config here
|
||||
* text eol=lf
|
||||
|
||||
#############################################
|
||||
# Git lfs stuff
|
||||
# Documents
|
||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||
*.doc filter=lfs diff=lfs merge=lfs -text
|
||||
*.docx filter=lfs diff=lfs merge=lfs -text
|
||||
# Excel
|
||||
*.xls filter=lfs diff=lfs merge=lfs -text
|
||||
*.xlsx filter=lfs diff=lfs merge=lfs -text
|
||||
*.xlsm filter=lfs diff=lfs merge=lfs -text
|
||||
# Powerpoints
|
||||
*.ppt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pptx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ppsx filter=lfs diff=lfs merge=lfs -text
|
||||
# Images
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.jpg filter=lfs diff=lfs merge=lfs -text
|
||||
# Video
|
||||
*.mkv filter=lfs diff=lfs merge=lfs -text
|
||||
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
||||
*.wmv filter=lfs diff=lfs merge=lfs -text
|
||||
# Misc
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
# ET4011
|
||||
*.cbe filter=lfs diff=lfs merge=lfs -text
|
||||
*.pbs filter=lfs diff=lfs merge=lfs -text
|
||||
# Open/Libre office
|
||||
# from https://www.libreoffice.org/discover/what-is-opendocument/
|
||||
*.odt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ods filter=lfs diff=lfs merge=lfs -text
|
||||
*.odp filter=lfs diff=lfs merge=lfs -text
|
||||
*.odg filter=lfs diff=lfs merge=lfs -text
|
||||
# QT
|
||||
*.ui filter=lfs diff=lfs merge=lfs -text
|
89
README.md
89
README.md
|
@ -1,58 +1,26 @@
|
|||
# Skynet Discord Bot
|
||||
This bots core purpose is to give members roles based on their status on <https://ulwolves.ie>.
|
||||
This bots core purpose is to give members roles based on their status on <ulwolves.ie>.
|
||||
It uses an api key provided by wolves to get member lists.
|
||||
|
||||
Users are able to link their wolves account to the bot and that works across discord servers.
|
||||
For example is a user links on the CompSoc Discord then they will also get their roles (automagically) on Games Dev if they are a member there.
|
||||
|
||||
## Setup - Committee
|
||||
## Commands - Admin
|
||||
|
||||
You need admin access to run any of the commands in this section.
|
||||
Either the server owner or a user with the ``Administrator`` permission.
|
||||
Either the server owner or a suer with the ``Administrator`` permission
|
||||
|
||||
### Get the API Key
|
||||
The ``api_key`` is used by the Bot in order to request information, it will be used later in the process.
|
||||
|
||||
1. Email ``keith@assurememberships.com`` from committee email and say you want an ``api_key`` for ``193.1.99.74``
|
||||
* The committee email is the one here: <https://cp.ulwolves.ie/mailbox/>
|
||||
* This may take up to a week to get the key.
|
||||
|
||||
### Setup Server
|
||||
The Bot reason for existing is being able to give members Roles.
|
||||
So we have to create those.
|
||||
|
||||
1. Create a role for Current Members.
|
||||
* You can call it whatever you want.
|
||||
* ``member-current`` is a good choice.
|
||||
* This should be a new role
|
||||
2. **Optional**: you can create a role that is given to folks who were but no longer a member.
|
||||
* ``member`` would be a good choice for this
|
||||
* If you have an existing member role this is also a good fit.
|
||||
### Getting the Skynet Discord bot
|
||||
1. Email ``keith@assurememberships.com`` from committee email and say ye want an api key for ``193.1.99.74``
|
||||
2. Create a role for current members (maybe call it ``current-member`` ?)
|
||||
3. (Optional) create a role for all past and current members (ye can use the existing ``member`` role for this, )
|
||||
4. Invite the bot https://discord.com/api/oauth2/authorize?client_id=1145761669256069270&permissions=139855185984&scope=bot
|
||||
5. Make sure the bot role ``@skynet`` is above these two roles (so it can manage them)
|
||||
6. Make sure that you have a role that gives ye administrator powers
|
||||
7. Use the command ``/add`` and insert the api key, role current and role all (desktop recommended)
|
||||
|
||||
The reason for both roles is ye have one for active members while the second is for all current and past members.
|
||||
|
||||
### Invite Bot
|
||||
1. Invite the bot https://discord.com/api/oauth2/authorize?client_id=1145761669256069270&permissions=139855185984&scope=bot
|
||||
2. Make sure the bot role ``@skynet`` is above these two roles created in the previous step
|
||||
* This is so it can manage the roles (give and remove them from users)
|
||||
|
||||
### Setup Bot
|
||||
This is where the bot is configured.
|
||||
You will need the ``api_key`` from the start of the process.
|
||||
You (personally) will need a role with ``Administrator`` permission to be able to do this.
|
||||
|
||||
1. Use the command ``/add`` and a list of options will pop up.
|
||||
2. ``api_key`` is the key you got from Keith earlier.
|
||||
3. ``role_current`` is the ``member-current`` that you created earlier.
|
||||
4. ``role_past`` (optional) is the role for all current and past members.
|
||||
5. ``bot_channel`` is a channel that folks are recommended to use the bot.
|
||||
* You can have it so folks cannot see message history
|
||||
6. ``server_name`` For example ``UL Computer Society``
|
||||
* Will be removed in the future
|
||||
7. ``wolves_link`` for example <https://ulwolves.ie/society/computer>
|
||||
* Will be removed in the future
|
||||
|
||||
At this point the bot is set up and no further action is required.
|
||||
|
||||
### Minecraft
|
||||
The bot is able to manage the whitelist of a Minecraft server managed by the Computer Society.
|
||||
Talk to us to get a server.
|
||||
|
@ -74,24 +42,29 @@ This unlinks a minecraft server from your club/society.
|
|||
|
||||
``/minecraft_delete SERVER_ID``
|
||||
|
||||
## Setup - Users
|
||||
This is to link your Discord account with your UL Wolves account.
|
||||
**You will only need to do this once**.
|
||||
## Commands - User
|
||||
|
||||
### Setup
|
||||
1. In a Discord server with the Skynet Bot enter ``/link_wolves YOUR_WOLVES_CONTACT_EMAIL``
|
||||
<img src="media/setup_user_01.png" alt="link process start" width="50%" height="50%">
|
||||
* Your ``YOUR_WOLVES_CONTACT_EMAIL`` is the email in the Contact Email here: <https://ulwolves.ie/memberships/profile>
|
||||
* This is most likely your student mail
|
||||
2. An email will be sent to you with a verification code.
|
||||
<img src="media/setup_user_02.png" alt="signup email" width="50%" height="50%">
|
||||
3. Verify the code using ``/verify CODE_FROM_EMAIL`` in Discord.
|
||||
<img src="media/setup_user_03.png" alt="verify in discord" width="50%" height="50%">
|
||||
4. Once complete your Wolves and Discord accounts will be linked.
|
||||
* Start the process using ``/link_wolves WOLVES_EMAIL``
|
||||
* The email that is in the Contact Email here: <https://ulwolves.ie/memberships/profile>
|
||||
* An email will be sent to them that they need to verify using ``/verify CODE``
|
||||
* This will only have to be done once.
|
||||
|
||||
You will get member roles on any Discord that is using the bot that you are a member of.
|
||||
* If the user is an active member on wolves
|
||||
* If they are in any servers with teh Skynet Bot
|
||||
* They will get relevant roles.
|
||||
* If they Join a server with teh bot enabled.
|
||||
* They will be granted the roles automatically
|
||||
* If the user is **not** an active member on wolves.
|
||||
* If they have no Roles
|
||||
* No change
|
||||
* If they have Past Member Role
|
||||
* No change
|
||||
* If they have both Roles
|
||||
* The current-member role will be removed from them
|
||||
* Past Member role will remain unchanged
|
||||
|
||||
### Minecraft
|
||||
You can link your Minecraft username to grant you access to any Minecraft server run by UL Computer Society.
|
||||
Users can link their Minecraft username to grant them access to any servers where teh whitelist is managed by teh bot.
|
||||
|
||||
``/link_minecraft MINECRAFT_USERNAME``
|
||||
|
|
BIN
media/setup_user_01.png
(Stored with Git LFS)
BIN
media/setup_user_01.png
(Stored with Git LFS)
Binary file not shown.
BIN
media/setup_user_02.png
(Stored with Git LFS)
BIN
media/setup_user_02.png
(Stored with Git LFS)
Binary file not shown.
BIN
media/setup_user_03.png
(Stored with Git LFS)
BIN
media/setup_user_03.png
(Stored with Git LFS)
Binary file not shown.
|
@ -133,7 +133,7 @@ pub mod link {
|
|||
"h2, h4 { font-family: Arial, Helvetica, sans-serif; }"
|
||||
}
|
||||
}
|
||||
div {
|
||||
div style="display: flex; flex-direction: column; align-items: center;" {
|
||||
h2 { "Hello from Skynet!" }
|
||||
// Substitute in the name of our recipient.
|
||||
p { "Hi " (user) "," }
|
||||
|
|
|
@ -22,7 +22,7 @@ pub mod edit {
|
|||
let role_a = if let CommandDataOptionValue::Role(role) = command
|
||||
.data
|
||||
.options
|
||||
.first()
|
||||
.get(0)
|
||||
.expect("Expected role option")
|
||||
.resolved
|
||||
.as_ref()
|
||||
|
@ -73,9 +73,14 @@ pub mod edit {
|
|||
|
||||
if let Some(x) = command.data.options.get(3) {
|
||||
let tmp = x.to_owned();
|
||||
if let Some(CommandDataOptionValue::Boolean(z)) = tmp.resolved {
|
||||
if let Some(y) = tmp.resolved {
|
||||
match y {
|
||||
CommandDataOptionValue::Boolean(z) => {
|
||||
delete = z;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let db_lock = {
|
||||
|
@ -152,8 +157,9 @@ pub mod edit {
|
|||
}
|
||||
|
||||
async fn add_server(db: &Pool<Sqlite>, server: &RoleAdder, delete: bool) -> Result<Option<RoleAdder>, Error> {
|
||||
let action;
|
||||
if delete {
|
||||
sqlx::query_as::<_, RoleAdder>(
|
||||
action = sqlx::query_as::<_, RoleAdder>(
|
||||
"
|
||||
DELETE FROM roles_adder
|
||||
WHERE server = ?1 AND role_a = ?2 AND role_b = ?3 AND role_c = ?4
|
||||
|
@ -164,9 +170,9 @@ pub mod edit {
|
|||
.bind(*server.role_b.as_u64() as i64)
|
||||
.bind(*server.role_c.as_u64() as i64)
|
||||
.fetch_optional(db)
|
||||
.await
|
||||
.await;
|
||||
} else {
|
||||
sqlx::query_as::<_, RoleAdder>(
|
||||
action = sqlx::query_as::<_, RoleAdder>(
|
||||
"
|
||||
INSERT OR REPLACE INTO roles_adder (server, role_a, role_b, role_c)
|
||||
VALUES (?1, ?2, ?3, ?4)
|
||||
|
@ -177,8 +183,10 @@ pub mod edit {
|
|||
.bind(*server.role_b.as_u64() as i64)
|
||||
.bind(*server.role_c.as_u64() as i64)
|
||||
.fetch_optional(db)
|
||||
.await
|
||||
.await;
|
||||
}
|
||||
|
||||
action
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,7 +201,7 @@ pub mod tools {
|
|||
|
||||
pub async fn on_role_change(db: &Pool<Sqlite>, ctx: &Context, mut new_data: Member) {
|
||||
// check if the role changed is part of the oens for this server
|
||||
if let Ok(role_adders) = sqlx::query_as::<_, RoleAdder>(
|
||||
if let Some(role_adders) = sqlx::query_as::<_, RoleAdder>(
|
||||
r#"
|
||||
SELECT *
|
||||
FROM roles_adder
|
||||
|
@ -203,6 +211,7 @@ pub mod tools {
|
|||
.bind(*new_data.guild_id.as_u64() as i64)
|
||||
.fetch_all(db)
|
||||
.await
|
||||
.ok()
|
||||
{
|
||||
let mut roles_add = vec![];
|
||||
let mut roles_remove = vec![];
|
||||
|
|
Loading…
Reference in a new issue