Skip to content

Commit cd3f4a1

Browse files
authored
Merge pull request #207 from Ohtuproju2021syksy/v13
V13 to main
2 parents 9d0be28 + 4bd9733 commit cd3f4a1

18 files changed

+360
-10
lines changed

documentation/commands.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ Command | Description | Example
3030
`/edit_course` | Edit course information, e.g. course code, fullname, or nickname. Must be used inside a course. | `/edit_course nickname ohpe`
3131
`/edit_topic` | Edit channel topic, replacing an already existing topic. | `/edit_topic perusteet`
3232
`/enable_bridge` | Enable bridge in a Discord text channel. Must be used inside a course and in a non-default text channel. | `/enable_bridge`
33+
`/hide_channel` | Make the channel hidden from regular users. Also disables the bridge in the channel. Must be used inside a course and in a non-default text channel. | `/hide_channel`
3334
`/hide_course` | Make the given course private, disabling joining with `/join` | `/hide_course ohpe`
3435
`/lock_chat` | Lock the given course, disabling messaging by regular users | `/lock_chat ohpe`
3536
`/rename_channel` | Rename a Discord text channel. Must be used inside a course and in a non-default text channel. | `/rename_channel questions`
3637
`/status` | Get full status of course. Must be used inside a course. | `/status`
38+
`/unhide_channel` | Make the channel visible to regular users. Also enables the bridge in the channel. Must be used inside a course and in a non-default text channel. | `/unhide_channel`
3739
`/unhide_course` | Make the given course public, enabling joining with `/join`. | `/unhide_course ohpe`
3840
`/unlock_chat` | Unlock the given course, enabling messaging by regular users. | `/unlock_chat ohpe`
3941

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## /hide_channel
2+
3+
- :heavy_check_mark: Must be used in a non-default text channel.
4+
- :heavy_check_mark: Reply with an ephemeral message - is only visible to the user of the interaction.
5+
- :heavy_check_mark: Response includes the interaction status.
6+
7+
- :x: All members can use this command.
8+
- :x: Needs arguments.
9+
- :x: Can be used in every channel.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## /unhide_channel
2+
3+
- :heavy_check_mark: Must be used in a non-default text channel.
4+
- :heavy_check_mark: Reply with an ephemeral message - is only visible to the user of the interaction.
5+
- :heavy_check_mark: Response includes the interaction status.
6+
7+
- :x: All members can use this command.
8+
- :x: Needs arguments.
9+
- :x: Can be used in every channel.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## /instructor_disconnect
2+
3+
- :heavy_check_mark: Can be used in every channel.
4+
- :heavy_check_mark: Reply with an ephemeral message - is only visible to the user of the interaction.
5+
- :heavy_check_mark: Needs argument: user to disconnect from voice chat.
6+
- :heavy_check_mark: Admin and faculty can disconnect anyone from any voice chat.
7+
- :heavy_check_mark: Instructor can disconnect a user from course voice chat only if they are instructor in that specific course.
8+
- :x: All members can use this command.
9+
- :x: Can give the intructor role to a member who is not on the course.

documentation/usermanual-admin.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,22 @@ Command | Explanation | Arguments
124124
[/edit_course](./commands/faculty/edit_course.md) | Edit course information, options; coursecode, full name, nickname | :heavy_check_mark:
125125
[/edit_topic](./commands/faculty/edit_topic.md) | Edit topic, must be used in a course channel, e.g., /edit_topic A new topic. | :heavy_check_mark:
126126
[/enable_bridge](./commands/faculty/enable_bridge.md) | Enable the bridge between Telegram and the (non-default) course channel it is used in. | :x:
127+
[/hide_channel](./commands/faculty/hide_channel.md)| Make the channel hidden from regular users, e.g., /hide_channel. Also disables the bridge in the channel. | :x:
127128
[/hide_course](./commands/faculty/hide_course.md)| Make given course private, e.g., /hide_course weba. | :heavy_check_mark:
128129
[/lock_chat](./commands/faculty/lock_chat.md) | Lock the chat (meaning only instructors and faculty can post messages) of a given course | :heavy_check_mark:
129130
[/remove_instructors](./commands/faculty/remove_instructors.md) | Remove instructor role from (multiple) users, e.g., /remove_instructors @user1 @user2. | :heavy_check_mark:
130131
[/rename_channel](./commands/faculty/rename_channel.md) | Rename the non-default course text channel the command is used in, e.g., /rename_channel feedback. | :heavy_check_mark:
131132
[/status](./commands/faculty/status.md) | Used in course channel returns general info about the course | :heavy_check_mark:
133+
[/unhide_channel](./commands/faculty/unhide_channel.md)| Make the channel visible to regular users, e.g., /unhide_channel. Also enables the bridge in the channel. | :x:
132134
[/unhide_course](./commands/faculty/unhide_course.md) | Make given course public, e.g., /unhide_course weba. | :heavy_check_mark:
133135
[/unlock_chat](./commands/faculty/unlock_chat.md) | Unlock the chat of a given course | :heavy_check_mark:
134136

137+
#### Instructor specific commands ####
138+
139+
Command | Explanation | Arguments
140+
--------|-------------|----------:
141+
[/instructor_disconnect](./commands/instructor/instructor_disconnect.md) | Disconnect another user from a voice chat, e.g., /instructor_disconnect @user1. | :heavy_check_mark:
142+
135143
#### General commands ####
136144

137145
Command | Explanation | Arguments

documentation/usermanual-faculty.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ To be able to use all the faculty commands, you need to authenticate yourself. U
3838

3939
You can create new course with command `/create_course`. Give the command and after that give the _course code_, course´s _full name_ and course´s _nickname_. Nickname is optional and if not given then the coursecode will be also course´s nickname. **Note** that nickname is the value that is used as course´s name that users see on the Discord´s left column. So, we prefer that you give your course a short nickname because it is more readable on Discord for the users. **Note** also that nickname is a unique value.
4040

41-
#### Multilingual course name
42-
43-
If your course has multilingual course name, enter all the information in the _full name_ field.
44-
4541
#### Open university course
4642

4743
If your course is an open university course, use the abbreviation **MOOC** in the _full name_ field next to your course name.
@@ -120,10 +116,20 @@ The `/create_poll` command allows you to create a poll that is placed in the sam
120116

121117
## Disabling the bridge on a text channel
122118

123-
Users with faculty rights can disable the bridge between a certain course channel and Telegram. This can be used e.g. on off-topic course channels where there's a lot of discussion that could flood the Telegram chat with messages not directly related to the course. Note that the bridge can be disabled only on non-default channels, that is channels which were created individually with `/create_channel` after the course was created. You can check in which channels the bridge is disabled with the command `/status`.
119+
Users with faculty rights can disable the bridge between a certain course channel and Telegram. This can be used e.g. on off-topic course channels where there's a lot of discussion that could flood the Telegram chat with messages not directly related to the course. Note that the bridge can be disabled only on non-default channels, that is channels which were created individually with `/create_channel` after the course was created. To disable the bridge on a channel, write the command `/disable_bridge` on that channel. You can check in which channels the bridge is disabled with the command `/status`.
124120

125121
To enable the bridge on a channel, write the command `/enable_bridge` on that channel.
126122

123+
## Hiding a text channel from regular users
124+
125+
Users with faculty rights can hide a text channel from regular users inside a course. This can be used to e.g. make a private chat for course instructors. Note that the bridge can be disabled only on non-default channels, that is channels which were created individually with `/create_channel` after the course was created. To hide a text channel, write the command `/hide_channel` on that channel. Note that the command also disables the bridge on that channel, so that instructor specific conversations won't accidentally leak to Telegram.
126+
127+
To reveal the channel to regular users, write the command `/unhide_channel` on that channel. Note that the command also enables the bridge on that channel.
128+
129+
### Disconnecting users from voice chat
130+
131+
You can disconnect another user from any voice chat with the command `/instructor_disconnect`. Simply type `/instructor_disconnect @user1` in any chat.
132+
127133
#### Faculty specific commands ####
128134

129135
Command | Explanation | Arguments
@@ -132,20 +138,28 @@ Command | Explanation | Arguments
132138
[/create_channel](./commands/faculty/create_channel.md) | Create new text channel inside a course, e.g., /create_channel feedback. | :heavy_check_mark:
133139
[/create_course](./commands/faculty/create_course.md) | Create a new course | :heavy_check_mark:
134140
[/create_poll](./commands/faculty/create_poll.md) | Create a new poll | :heavy_check_mark:
135-
[/delete_bridge](./commands/faculty/delete_bridge.md) | Delete the bridge from specified Course, e.g., /delete_bridge ohpe | :heavy_check_mark:
141+
[/delete_bridge](./commands/faculty/delete_bridge.md) | Delete the bridge from specified course, e.g., /delete_bridge ohpe | :heavy_check_mark:
136142
[/delete_channel](./commands/faculty/delete_channel.md) | Remove given text channel inside a course, e.g., /delete_channel feedback. | :heavy_check_mark:
137143
[/disable_bridge](./commands/faculty/disable_bridge.md) | Disable the bridge between Telegram and the (non-default) course channel it is used in. | :x:
138144
[/edit_course](./commands/faculty/edit_course.md) | Edit course information, options; coursecode, full name, nickname | :heavy_check_mark:
139145
[/edit_topic](./commands/faculty/edit_topic.md) | Edit topic, must be used in a course channel, e.g., /edit_topic A new topic. | :heavy_check_mark:
140146
[/enable_bridge](./commands/faculty/enable_bridge.md) | Enable the bridge between Telegram and the (non-default) course channel it is used in. | :x:
147+
[/hide_channel](./commands/faculty/hide_channel.md)| Make the channel hidden from regular users, e.g., /hide_channel. Also disables the bridge in the channel. | :x:
141148
[/hide_course](./commands/faculty/hide_course.md)| Make given course private, e.g., /hide_course weba. | :heavy_check_mark:
142149
[/lock_chat](./commands/faculty/lock_chat.md) | Lock the chat (meaning only instructors and faculty can post messages) of a given course | :heavy_check_mark:
143150
[/remove_instructors](./commands/faculty/remove_instructors.md) | Remove instructor role from (multiple) users, e.g., /remove_instructors @user1 @user2. | :heavy_check_mark:
144151
[/rename_channel](./commands/faculty/rename_channel.md) | Rename the non-default course text channel the command is used in, e.g., /rename_channel feedback. | :heavy_check_mark:
145152
[/status](./commands/faculty/status.md) | Used in course channel returns general info about the course | :heavy_check_mark:
153+
[/unhide_channel](./commands/faculty/unhide_channel.md)| Make the channel visible to regular users, e.g., /unhide_channel. Also enables the bridge in the channel. | :x:
146154
[/unhide_course](./commands/faculty/unhide_course.md) | Make given course public, e.g., /unhide_course weba. | :heavy_check_mark:
147155
[/unlock_chat](./commands/faculty/unlock_chat.md) | Unlock the chat of a given course | :heavy_check_mark:
148156

157+
#### Instructor specific commands ####
158+
159+
Command | Explanation | Arguments
160+
--------|-------------|----------:
161+
[/instructor_disconnect](./commands/instructor/instructor_disconnect.md) | Disconnect another user from a voice chat, e.g., /instructor_disconnect @user1. | :heavy_check_mark:
162+
149163
#### General commands ####
150164

151165
Command | Explanation | Arguments
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# User manual for instructors
2+
3+
### About Discord
4+
5+
To learn more about Discord in general, head over to their [official website](https://discord.com/). You can also check the [Beginner's Guide to Discord](https://support.discord.com/hc/en-us/articles/360045138571-Beginner-s-Guide-to-Discord#h_d33e3809-909b-4720-899d-db26c17bafa9).
6+
7+
The Department of Computer Science has a Discord server for course support. The server contains categories for courses where students can ask for help and offer peer support for other students. The server also has a bot that can help you with several things, including creating course categories, adding instructors for a course, editing course visibility, and more.
8+
9+
We recommend that you use the Discord application (desktop app or mobile app). If you can't or don't want to download the application, you can use a browser-based version of Discord instead.
10+
11+
### Create your Discord account
12+
13+
Create yourself a Discord account. You can do this on [Discord Website](https://discord.com/). If you already have the account, you can login [here](https://discord.com/login).
14+
15+
If you’re on a desktop or mobile device, you can directly open the Discord app on your device (You can learn more information on downloading the app [here](https://support.discord.com/hc/en-us/articles/360033931551)).
16+
17+
Once you’re at the login page, type in either _your email address_ or _phone number_ that has been officially verified to your Discord account.
18+
19+
Note: You will need to verify your phone number to your Discord account before using phone number login! [Click here](https://support.discord.com/hc/en-us/articles/360033931551) to learn how to verify your phone number to your Discord account.
20+
21+
### Joining to the Discord
22+
23+
You can join to the Helsinki University Discord server in two different ways. Join directly to the server using this [link]( https://study.cs.helsinki.fi/discord). Join directly using the course´s own link (MOOC, Moodle, etc.).
24+
25+
![commands](./images/courselink.png)
26+
27+
### How to use the bot
28+
29+
The Discord server has a bot that can help you with many things. Interaction with bot is achieved with Discord's slash commands.
30+
31+
Commands can be used by typing `/<command_name>` into the message area at the bottom of the application. You can see all the available commands as a list that opens after typing `/`. **Note that you have to manually type the commands; the bot rarely understands copy-pasted commands!**
32+
33+
### Disconnecting users from course voice chat
34+
35+
You can disconnect another user from course voice chat with the command `/instructor_disconnect`. Note that you can disconnect a user only if you are an instructor on that course. E.g. if you are a course instructor in tito, `@user1` is currently in `tito_voice`, and `@user2` is in `wepa_voice`, you can disconnect `@user1` by typing `/instructor_disconnect @user1` in any chat, whereas using `/instructor_disconnect @user2` will do nothing as you are not an instructor in wepa.
36+
37+
#### Instructor specific commands ####
38+
39+
Command | Explanation | Arguments
40+
--------|-------------|----------:
41+
[/instructor_disconnect](./commands/instructor/instructor_disconnect.md) | Disconnect another user from a voice chat, e.g., /instructor_disconnect @user1. Only works for persons in voice chat of a course you are instructor in. | :heavy_check_mark:
42+
43+
### General commands
44+
45+
Command | Explanation | Arguments
46+
--------|-------------|----------:
47+
[/auth](./commands/general/auth.md) | For faculty members with student role to acquire the faculty role. | :x:
48+
[/courses](./commands/general/courses.md) | Get public course information | :x:
49+
[/help](./commands/general/help.md) | Get help how to use slash commands. | :o:
50+
[/instructors](./commands/general/instructors.md) | Get course intructors information. | :x:
51+
[/join](./commands/general/join.md) | Joins you into the course given, e.g., /join ohpe. | :heavy_check_mark:
52+
[/leave](./commands/general/leave.md) | Remove you from the course given, e.g., /leave ohpe. | :heavy_check_mark:
53+
[/workshops](./commands/general/workshops.md) | Get workshop info for the course. | :x:
54+
55+
### Material
56+
57+
[Source code for the Bot](https://github.com/Ohtuproju2021syksy/Discord-Bot-better)

src/db/hookInit.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,25 @@ const initChannelHooks = (guild, models) => {
8383
const channelObject = guild.channels.cache.find(c => c.name === channel.name);
8484
await channelObject.setTopic(channel.topic);
8585
}
86+
87+
if (channel._changed.has("hidden")) {
88+
const course = await findCourseFromDbById(channel.courseId, courseModel);
89+
const student = await findOrCreateRoleWithName(course.name, guild);
90+
const channelObject = guild.channels.cache
91+
.find(c => c.name === channel.dataValues.name);
92+
if (channel.hidden) {
93+
await channelObject.permissionOverwrites.create(student, {
94+
VIEW_CHANNEL: false,
95+
SEND_MESSAGES: false,
96+
});
97+
}
98+
else {
99+
await channelObject.permissionOverwrites.create(student, {
100+
VIEW_CHANNEL: true,
101+
SEND_MESSAGES: true,
102+
});
103+
}
104+
}
86105
});
87106
};
88107

@@ -195,9 +214,9 @@ const initUserHooks = (guild, models) => {
195214

196215
const initCourseMemberHooks = (guild, models) => {
197216
models.CourseMember.addHook("afterCreate", async (courseMember) => {
198-
const user = await findUserByDbId(courseMember.userId, models.User);
199-
const course = await findCourseFromDbById(courseMember.courseId, models.Course);
200-
const member = guild.members.cache.get(user.discordId);
217+
const user = await findUserByDbId(courseMember.dataValues.userId, models.User);
218+
const course = await findCourseFromDbById(courseMember.dataValues.courseId, models.Course);
219+
const member = guild.members.cache.get(user.dataValues.discordId);
201220
const courseRole = guild.roles.cache.find(r => r.name === course.name);
202221
await member.roles.add(courseRole);
203222
await updateGuide(guild, models);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"use strict";
2+
const { BOOLEAN } = require("sequelize");
3+
4+
module.exports = {
5+
up: async (queryInterface) => {
6+
await queryInterface.addColumn("channel", "hidden", {
7+
type: BOOLEAN,
8+
defaultValue: false,
9+
});
10+
},
11+
down: async (queryInterface) => {
12+
await queryInterface.removeColumn("channel", "hidden");
13+
},
14+
};

src/db/models/Channel.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ module.exports = (sequelize, DataTypes) => {
3535
allowNull: true,
3636
unique: true,
3737
},
38+
hidden: {
39+
type: DataTypes.BOOLEAN,
40+
defaultValue: false,
41+
unique: false,
42+
},
3843
}, {
3944
timestamps: false,
4045
freezeTableName: true,

0 commit comments

Comments
 (0)