-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update ping command and some config and formatting cleanup (#147)
- Loading branch information
Showing
16 changed files
with
357 additions
and
244 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,10 +1,10 @@ | ||
{ | ||
"singleQuote": true, | ||
"quoteProps": "as-needed", | ||
"trailingComma": "all", | ||
"bracketSpacing": true, | ||
"arrowParens": "always", | ||
"semi": true, | ||
"useTabs": false, | ||
"tabWidth": 4 | ||
} | ||
"singleQuote": true, | ||
"quoteProps": "as-needed", | ||
"trailingComma": "all", | ||
"bracketSpacing": true, | ||
"arrowParens": "always", | ||
"semi": true, | ||
"useTabs": false, | ||
"tabWidth": 4 | ||
} |
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,33 +1,33 @@ | ||
{ | ||
"name": "tauri-discord-bot", | ||
"private": true, | ||
"version": "0.0.0", | ||
"main": "src/index.ts", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "nodemon --ext ts,js,mjs,json --legacy-watch --loader tsm .", | ||
"start": "tsm ." | ||
}, | ||
"license": "MIT", | ||
"engines": { | ||
"node": "20.x" | ||
}, | ||
"dependencies": { | ||
"discord.js": "14.15.2", | ||
"dotenv": "16.4.5", | ||
"express": "4.19.2", | ||
"jellycommands": "1.0.0-next.43", | ||
"ts-node": "10.9.2", | ||
"tsm": "2.3.0", | ||
"unfurl.js": "6.3.1", | ||
"url-regex-safe": "3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/express": "4.17.21", | ||
"@types/node": "20.12.12", | ||
"@types/url-regex-safe": "1.0.2", | ||
"nodemon": "3.1.1", | ||
"prettier": "3.2.5", | ||
"typescript": "5.4.5" | ||
} | ||
"name": "tauri-discord-bot", | ||
"private": true, | ||
"version": "0.0.0", | ||
"main": "src/index.ts", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "nodemon --ext ts,js,mjs,json --legacy-watch --loader tsm .", | ||
"start": "tsm ." | ||
}, | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=20.x" | ||
}, | ||
"dependencies": { | ||
"discord.js": "14.15.2", | ||
"dotenv": "16.4.5", | ||
"express": "4.19.2", | ||
"jellycommands": "1.0.0-next.43", | ||
"ts-node": "10.9.2", | ||
"tsm": "2.3.0", | ||
"unfurl.js": "6.3.1", | ||
"url-regex-safe": "3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/express": "4.17.21", | ||
"@types/node": "20.12.12", | ||
"@types/url-regex-safe": "1.0.2", | ||
"nodemon": "3.1.1", | ||
"prettier": "3.2.5", | ||
"typescript": "5.4.5" | ||
} | ||
} |
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,5 +1,3 @@ | ||
{ | ||
"extends": [ | ||
"config:base" | ||
] | ||
"extends": ["config:base"] | ||
} |
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,60 @@ | ||
import { APIRole, Role, roleMention } from 'discord.js'; | ||
import { command } from 'jellycommands'; | ||
|
||
export default command({ | ||
name: 'ping', | ||
description: 'Ping a role', | ||
global: true, | ||
options: [ | ||
{ | ||
name: 'role', | ||
description: 'The role you want to ping', | ||
type: 'Role', | ||
required: true, | ||
}, | ||
], | ||
run: async ({ interaction }) => { | ||
// Fetch the role and make sure it's pingable. | ||
const role = interaction.options.getRole('role', true); | ||
|
||
// Fetch the member, since the interaction member might not be fully resolved. | ||
const member = await interaction.guild.members.fetch( | ||
interaction.user.id, | ||
); | ||
|
||
// Check if the role is pingable or the member has permission to ping everyone anyways. | ||
let pingable = member.permissions.has('MentionEveryone', true) | ||
? 'yes' | ||
: pingableStatus(role); | ||
|
||
if (pingable === 'no') { | ||
return await interaction.reply({ | ||
content: 'This role is not pingable.', | ||
ephemeral: true, | ||
}); | ||
} | ||
|
||
// The user has to have the role to ping it in some circumstances. | ||
if (pingable === 'self') { | ||
if (!member.roles.cache.has(role.id)) { | ||
return await interaction.reply({ | ||
content: 'You do not have permission to ping this role.', | ||
ephemeral: true, | ||
}); | ||
} | ||
} | ||
|
||
// Ping the role in a reply so that you can see the original sender of the command. | ||
await interaction.reply(`${roleMention(role.id)}`); | ||
}, | ||
}); | ||
|
||
function pingableStatus(role: Role | APIRole): 'yes' | 'no' | 'self' { | ||
if (role.name === 'working-group' || role.name.startsWith('wg-')) { | ||
return 'self'; | ||
} else if (['mod', 'moderator'].includes(role.name)) { | ||
return 'yes'; | ||
} else { | ||
return 'no'; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.