-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from nathen418/nate-goldsborough
Rewrite of CSSC-bot in Typescript using Discord.js and WOKCommands (Part 1-5)
- Loading branch information
Showing
33 changed files
with
2,211 additions
and
504 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
**/__pycache__ | ||
**/__pycache__ | ||
.vscode | ||
.env | ||
node_modules | ||
unused-commands | ||
d.py/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
**TODO** | ||
- Add validation that roles exist in the server | ||
- Add code to create roles that do not exist in the server if required | ||
- Add error checking anytime roles are accessed | ||
- Add error checking where necessary | ||
- Add a few other misc features | ||
- Remove lots of unoptimized and duplicate code. Refactor functions that can be refactored. | ||
- When WOKCommands [updates to Discord.js v14](https://github.com/AlexzanderFlores/WOKCommands/issues/228), update WOKcommands | ||
- Add logging for most functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { MessageEmbed, MessageActionRow, MessageSelectMenu } from "discord.js"; | ||
import { ICommand } from "wokcommands"; | ||
|
||
export default { | ||
name: "staffPoll", | ||
category: "owner", | ||
description: "Posts the College Staff Poll", | ||
slash: true, | ||
testOnly: false, | ||
guildOnly: true, | ||
requiredPermissions: ["SEND_MESSAGES"], | ||
ownerOnly: true, | ||
|
||
callback: async ({ client, interaction: msgInt }) => { | ||
// Define embeds used in this command | ||
const infoEmbed = new MessageEmbed() | ||
.setTitle("Choose a role") | ||
.setColor("#0099ff") | ||
.setDescription("Select the option with your current occupation at UWM.") | ||
.setFooter({ | ||
text: `Delivered in: ${client.ws.ping}ms | CSSC-Bot | ${process.env.VERSION}`, | ||
iconURL: "https://playantares.com/resources/CSSC-bot/icon.jpg", | ||
}); | ||
|
||
// Create row one of the buttons for the poll | ||
const row = new MessageActionRow().addComponents( | ||
new MessageSelectMenu() | ||
.setCustomId("collegeStaffPoll") | ||
.setPlaceholder("Select an option") | ||
.addOptions( | ||
{ | ||
label: "Tutor", | ||
value: "tutor", | ||
}, | ||
{ | ||
label: "SI Leader", | ||
value: "sileader", | ||
}, | ||
{ | ||
label: "TA", | ||
value: "ta", | ||
}, | ||
{ | ||
label: "Professor", | ||
value: "professor", | ||
}, | ||
{ | ||
label: "Student Employee", | ||
value: "studentemployee", | ||
} | ||
) | ||
); | ||
|
||
// Send the embed and message component rows | ||
msgInt.reply({ embeds: [infoEmbed], components: [row] }); | ||
}, | ||
} as ICommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { MessageEmbed, MessageActionRow, MessageSelectMenu } from "discord.js"; | ||
import { ICommand } from "wokcommands"; | ||
|
||
export default { | ||
name: "yearPoll", | ||
category: "owner", | ||
description: "Posts the College Year Poll", | ||
slash: true, | ||
testOnly: false, | ||
guildOnly: true, | ||
requiredPermissions: ["SEND_MESSAGES"], | ||
ownerOnly: true, | ||
|
||
callback: async ({ client, interaction: msgInt }) => { | ||
// Define embeds used in this command | ||
const infoEmbed = new MessageEmbed() | ||
.setTitle("Choose a role") | ||
.setColor("#0099ff") | ||
.setDescription("Select the button with your current college year.") | ||
.setFooter({ | ||
text: `Delivered in: ${client.ws.ping}ms | CSSC-Bot | ${process.env.VERSION}`, | ||
iconURL: "https://playantares.com/resources/CSSC-bot/icon.jpg", | ||
}); | ||
|
||
|
||
// Create row one of the buttons for the poll | ||
const row = new MessageActionRow().addComponents( | ||
new MessageSelectMenu() | ||
.setCustomId("collegeYearPoll") | ||
.setPlaceholder("Select an option.") | ||
.addOptions( | ||
{ | ||
label: "Prefrosh", | ||
value: "prefrosh", | ||
}, | ||
{ | ||
label: "Freshman", | ||
value: "freshman", | ||
}, | ||
{ | ||
label: "Sophomore", | ||
value: "sophomore", | ||
}, | ||
{ | ||
label: "Junior", | ||
value: "junior", | ||
}, | ||
{ | ||
label: "Senior", | ||
value: "senior", | ||
}, | ||
{ | ||
label: "Graduate Student", | ||
value: "graduatestudent", | ||
}, | ||
{ | ||
label: "Alumni", | ||
value: "alumni", | ||
} | ||
) | ||
); | ||
|
||
// Send the embed and message component rows | ||
msgInt.reply({ embeds: [infoEmbed], components: [row] }); | ||
}, | ||
} as ICommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { GuildMember } from "discord.js"; | ||
import { ICommand } from "wokcommands"; | ||
import { returnRoles as roleDictionary } from "../../definitions"; | ||
import { removePrevRole } from "../../rolesOps"; | ||
|
||
export default { | ||
name: "clear", | ||
category: "user", | ||
description: "removes all roles the bot has assigned to a user", | ||
slash: true, | ||
testOnly: false, | ||
guildOnly: true, | ||
requiredPermissions: ["SEND_MESSAGES"], | ||
|
||
callback: async ({ interaction }) => { | ||
// Remove roles from user | ||
if (!interaction.member) return; | ||
const member = interaction.member as GuildMember; | ||
removePrevRole(member, 0); | ||
removePrevRole(member, 1); | ||
// Reply to the user | ||
interaction.reply({ content: "Cleared all roles that I have assigned to you.", ephemeral: true }); | ||
}, | ||
} as ICommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { MessageEmbed, TextChannel } from "discord.js"; | ||
import { ICommand } from "wokcommands"; | ||
|
||
export default { | ||
name: "github", | ||
category: "user", | ||
description: "Sends an embed with a link to the github repo for the bot.", | ||
slash: true, | ||
testOnly: false, | ||
guildOnly: true, | ||
requiredPermissions: ["SEND_MESSAGES"], | ||
|
||
callback: async ({ client, interaction }) => { | ||
// Embed values | ||
const color = "#0099ff"; | ||
const thumbnail = "https://playantares.com/resources/CSSC-bot/cssc-server-icon.png"; | ||
const title = "Github"; | ||
const description = "Click here to go to the CSSC-bot repo: \n https://github.com/llisaeva/CSSC-Bot"; | ||
const footer = `Delivered in: ${client.ws.ping}ms | CSSC-bot | ${process.env.VERSION}`; | ||
const footerIcon = "https://playantares.com/resources/CSSC-bot/icon.jpg"; | ||
|
||
// Embed construction | ||
const Embed = new MessageEmbed() | ||
.setColor(color) | ||
.setTitle(title) | ||
.setThumbnail(thumbnail) | ||
.setDescription(description) | ||
.setFooter({ text: footer, iconURL: footerIcon }); | ||
|
||
interaction.reply({ embeds: [Embed] }); | ||
}, | ||
} as ICommand; |
Oops, something went wrong.