Converted main codebase to typescript
Signed-off-by: Taken <taken@mairimashita.org>
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
const { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits, userMention } = require("discord.js")
|
||||
import { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits, userMention } from "discord.js"
|
||||
import { ContextMenu } from "../interfaces"
|
||||
|
||||
module.exports = {
|
||||
export = {
|
||||
name: "congratsmessage",
|
||||
description: "Congratulate a user.",
|
||||
type: "contextmenu",
|
||||
dev: false,
|
||||
|
||||
data: new ContextMenuCommandBuilder()
|
||||
.setName("Congratulate")
|
||||
.setType(ApplicationCommandType.Message)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages),
|
||||
|
||||
/** @param { import('discord.js').ContextMenuCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
const { targetId } = interaction
|
||||
const message = await interaction.channel.messages.fetch(targetId)
|
||||
const message = await interaction.channel!.messages.fetch(targetId)
|
||||
|
||||
if (!message) {
|
||||
return interaction.reply({ content: "That user does not exist.", ephemeral: true })
|
||||
@@ -33,4 +33,4 @@ module.exports = {
|
||||
|
||||
await interaction.reply({ content: "Sent a congrats message", ephemeral: true })
|
||||
}
|
||||
}
|
||||
} as ContextMenu
|
||||
@@ -1,36 +0,0 @@
|
||||
const { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits } = require("discord.js")
|
||||
|
||||
module.exports = {
|
||||
name: "resetnick",
|
||||
description: "Reset your nickname.",
|
||||
type: "contextmenu",
|
||||
|
||||
data: new ContextMenuCommandBuilder()
|
||||
.setName("Reset Nickname")
|
||||
.setType(ApplicationCommandType.User)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames),
|
||||
|
||||
/** @param { import('discord.js').ContextMenuCommandInteraction } interaction */
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
const { targetId } = interaction
|
||||
const target = await interaction.guild.members.fetch(targetId)
|
||||
|
||||
if (!target) {
|
||||
return interaction.reply({ content: "That user does not exist.", ephemeral: true })
|
||||
}
|
||||
|
||||
if (target.id === interaction.user.id) {
|
||||
return interaction.reply({ content: "You can't reset your own nickname.", ephemeral: true })
|
||||
}
|
||||
|
||||
if (!target.manageable) {
|
||||
return interaction.reply({ content: "I cannot reset that user's nickname.", ephemeral: true })
|
||||
}
|
||||
|
||||
await target.setNickname(target.user.username, "Reset by " + interaction.user.username + "#" + interaction.user.discriminator)
|
||||
|
||||
return interaction.reply({ content: `Reset ${target.user.username}'s nickname.`, ephemeral: true })
|
||||
}
|
||||
}
|
||||
38
src/commands-contextmenu/resetnick.ts
Normal file
38
src/commands-contextmenu/resetnick.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits } from "discord.js"
|
||||
import { ContextMenu } from "../interfaces"
|
||||
|
||||
export = {
|
||||
name: "resetnick",
|
||||
description: "Reset your nickname.",
|
||||
type: "contextmenu",
|
||||
dev: false,
|
||||
|
||||
data: new ContextMenuCommandBuilder()
|
||||
.setName("Reset Nickname")
|
||||
.setType(ApplicationCommandType.User)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageNicknames),
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
const { targetId } = interaction
|
||||
const target = await interaction.guild!.members.fetch(targetId)
|
||||
|
||||
if (!target) {
|
||||
interaction.reply({ content: "That user does not exist.", ephemeral: true })
|
||||
return
|
||||
}
|
||||
|
||||
if (target.id === interaction.user.id) {
|
||||
interaction.reply({ content: "You can't reset your own nickname.", ephemeral: true })
|
||||
return
|
||||
}
|
||||
|
||||
if (!target.manageable) {
|
||||
interaction.reply({ content: "I cannot reset that user's nickname.", ephemeral: true })
|
||||
return
|
||||
}
|
||||
|
||||
await target.setNickname(target.user.username, "Reset by " + interaction.user.username + "#" + interaction.user.discriminator)
|
||||
interaction.reply({ content: `Reset ${target.user.username}'s nickname.`, ephemeral: true })
|
||||
}
|
||||
} as ContextMenu
|
||||
Reference in New Issue
Block a user