Skip to content

Commit

Permalink
update deps, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bemoty committed Aug 1, 2023
1 parent 4780865 commit 9a90b80
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 332 deletions.
23 changes: 13 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,30 @@
"type": "git",
"url": "git+https://github.com/josholaus/doofus-rick.git"
},
"author": "",
"contributors": [
"Joshua Winkler <[email protected]>",
"Nicolaus Rossi <[email protected]>"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/josholaus/doofus-rick/issues"
},
"homepage": "https://github.com/josholaus/doofus-rick#readme",
"devDependencies": {
"@discordjs/rest": "^1.7.1",
"@types/node": "^20.2.3",
"@types/node-cron": "^3.0.7",
"nodemon": "^2.0.22",
"prettier": "^2.8.8",
"@discordjs/rest": "^2.0.0",
"@types/node": "^20.4.5",
"@types/node-cron": "^3.0.8",
"nodemon": "^3.0.1",
"prettier": "^3.0.0",
"rimraf": "^5.0.1",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
"typescript": "^5.1.6"
},
"dependencies": {
"discord.js": "^14.11.0",
"dotenv": "^16.0.3",
"discord.js": "^14.12.1",
"dotenv": "^16.3.1",
"log4js": "^6.9.1",
"mongodb": "^5.5.0",
"mongodb": "^5.7.0",
"node-cron": "^3.0.2",
"uuid": "^9.0.0"
}
Expand Down
12 changes: 8 additions & 4 deletions scripts/deploy-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Simply add a SlashCommandBuilder to the `commands` array while using the desired building functions.
For more information, see
https://discordjs.guide/popular-topics/builders.html#slash-command-builders
https://discordjs.guide/creating-your-bot/command-deployment.html#command-registration
*/

const { SlashCommandBuilder } = require('@discordjs/builders')
Expand All @@ -31,11 +31,15 @@ const commands = [
new SlashCommandBuilder()
.setName('noproductive')
.setDescription('Moves everyone from the productive zone to general'),
new SlashCommandBuilder().setName('chuen').setDescription('Who wants to chill?'),
new SlashCommandBuilder()
.setName('send')
.setDescription('Sends a message')
.addStringOption((option) => option.setName('id').setDescription('The target user id').setRequired(true))
.setDescription('Sends a message to a user')
.addUserOption((option) => option.setName('user').setDescription('The target user').setRequired(true))
.addStringOption((option) => option.setName('message').setDescription('The message to send').setRequired(true)),
new SlashCommandBuilder()
.setName('sendchannel')
.setDescription('Sends a message to a channel')
.addChannelOption((option) => option.setName('channel').setDescription('The target channel').setRequired(true))
.addStringOption((option) => option.setName('message').setDescription('The message to send').setRequired(true)),
].map((command) => command.toJSON())

Expand Down
10 changes: 5 additions & 5 deletions src/CommandRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ICommand } from './commands/ICommand'
import * as Commands from './commands'
import { ICommand } from './commands/ICommand'

interface CommandEntry {
name: string
Expand Down Expand Up @@ -31,14 +31,14 @@ const commands: CommandEntry[] = [
name: 'noproductive',
command: new Commands.NoProductiveCommand(),
},
{
name: 'chuen',
command: new Commands.ChuenCommand(),
},
{
name: 'send',
command: new Commands.SendCommand(),
},
{
name: 'sendchannel',
command: new Commands.SendChannelCommand(),
},
]

class CommandRegistry {
Expand Down
105 changes: 0 additions & 105 deletions src/commands/ChuenCommand.ts

This file was deleted.

28 changes: 28 additions & 0 deletions src/commands/SendChannelCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { CacheType, CommandInteraction, TextChannel } from 'discord.js'
import { ICommand } from './ICommand'

const allowedUsers = ['155046312411267072', '275342581821603842']

export default class SendChannelCommand implements ICommand {
async execute(interaction: CommandInteraction<CacheType>): Promise<void> {
if (!allowedUsers.includes(interaction.member?.user.id ?? 'null')) {
await interaction.reply({ content: 'des deafst du ned du santla', ephemeral: true })
return
}
const target = interaction.options.get('channel')
const message = interaction.options.get('message')?.value
if (target && message) {
try {
const channel = interaction.guild?.channels.cache.find(c => c.id === target.value)
if (!channel) throw {}
if (!(channel instanceof TextChannel)) throw {}
await (channel as TextChannel).send(message as string)
await interaction.reply({ content: 'ok', ephemeral: true })
} catch (_) {
await interaction.reply({ content: 'gehd ned', ephemeral: true })
}
} else {
await interaction.reply({ content: 'tua normal', ephemeral: true })
}
}
}
13 changes: 6 additions & 7 deletions src/commands/SendCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@ const allowedUsers = ['155046312411267072', '275342581821603842']
export default class SendCommand implements ICommand {
async execute(interaction: CommandInteraction<CacheType>): Promise<void> {
if (!allowedUsers.includes(interaction.member?.user.id ?? 'null')) {
await interaction.reply({ content: 'des deaf lei da joshi', ephemeral: true })
await interaction.reply({ content: 'des deafst du ned du santla', ephemeral: true })
return
}
const target = interaction.options.get('id')?.value
const target = interaction.options.getUser('user')
const message = interaction.options.get('message')?.value
if (target && message) {
try {
const user = await interaction.client.users.fetch(target as string)
const userDM = await user.createDM()
const userDM = await target.createDM()
userDM.send(message as string)
await interaction.reply({ content: 'message sent', ephemeral: true })
await interaction.reply({ content: 'ok', ephemeral: true })
} catch (_) {
await interaction.reply({ content: 'could not send message', ephemeral: true })
await interaction.reply({ content: 'gehd ned', ephemeral: true })
}
} else {
await interaction.reply({ content: 'invalid arguments', ephemeral: true })
await interaction.reply({ content: 'tua normal', ephemeral: true })
}
}
}
9 changes: 5 additions & 4 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export { default as NoProductiveCommand } from './NoProductiveCommand'
export { default as PingCommand } from './PingCommand'
export { default as VitalsCommand } from './VitalsCommand'
export { default as QuoteCommand } from './QuoteCommand'
export { default as RandomQuoteCommand } from './RandomQuoteCommand'
export { default as VotekickCommand } from './VotekickCommand'
export { default as NoProductiveCommand } from './NoProductiveCommand'
export { default as ChuenCommand } from './ChuenCommand'
export { default as SendChannelCommand } from './SendChannelCommand'
export { default as SendCommand } from './SendCommand'
export { default as VitalsCommand } from './VitalsCommand'
export { default as VotekickCommand } from './VotekickCommand'

Loading

0 comments on commit 9a90b80

Please sign in to comment.