Add typings, comment magic numbers
This commit is contained in:
parent
99c8dbabb7
commit
9a5e911cf2
5 changed files with 18 additions and 5 deletions
|
@ -1,3 +1,4 @@
|
|||
import { ContextMenuInteraction } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { ModActionsPlugin } from "src/plugins/ModActions/ModActionsPlugin";
|
||||
|
@ -10,7 +11,11 @@ import { LogsPlugin } from "../../Logs/LogsPlugin";
|
|||
import { MutesPlugin } from "../../Mutes/MutesPlugin";
|
||||
import { ContextMenuPluginType } from "../types";
|
||||
|
||||
export async function muteAction(pluginData: GuildPluginData<ContextMenuPluginType>, duration, interaction) {
|
||||
export async function muteAction(
|
||||
pluginData: GuildPluginData<ContextMenuPluginType>,
|
||||
duration: string | undefined,
|
||||
interaction: ContextMenuInteraction,
|
||||
) {
|
||||
interaction.deferReply({ ephemeral: true });
|
||||
const executingMember = await pluginData.guild.members.fetch(interaction.user.id);
|
||||
const userCfg = await pluginData.config.getMatchingConfig({
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
import { ContextMenuInteraction } from "discord.js";
|
||||
import { GuildPluginData } from "knub";
|
||||
import { UtilityPlugin } from "../../../plugins/Utility/UtilityPlugin";
|
||||
import { ContextMenuPluginType } from "../types";
|
||||
|
||||
export async function userInfoAction(pluginData: GuildPluginData<ContextMenuPluginType>, interaction) {
|
||||
export async function userInfoAction(
|
||||
pluginData: GuildPluginData<ContextMenuPluginType>,
|
||||
interaction: ContextMenuInteraction,
|
||||
) {
|
||||
interaction.deferReply({ ephemeral: true });
|
||||
const executingMember = await pluginData.guild.members.fetch(interaction.user.id);
|
||||
const userCfg = await pluginData.config.getMatchingConfig({
|
||||
|
@ -13,6 +17,10 @@ export async function userInfoAction(pluginData: GuildPluginData<ContextMenuPlug
|
|||
|
||||
if (userCfg.can_use && (await utility.hasPermission(executingMember, interaction.channelId, "can_userinfo"))) {
|
||||
const embed = await utility.userInfo(interaction.targetId, interaction.user.id);
|
||||
if (!embed) {
|
||||
await interaction.followUp({ content: "Cannot info: internal error" });
|
||||
return;
|
||||
}
|
||||
await interaction.followUp({ embeds: [embed] });
|
||||
} else {
|
||||
await interaction.followUp({ content: "Cannot info: insufficient permissions" });
|
||||
|
|
|
@ -14,7 +14,7 @@ export async function loadAllCommands(pluginData: GuildPluginData<ContextMenuPlu
|
|||
for (const [name, label] of Object.entries(hardcodedContext)) {
|
||||
if (!cfg[name]) continue;
|
||||
|
||||
const type = name.startsWith("user") ? 2 : 3;
|
||||
const type = name.startsWith("user") ? 2 : 3; // 2 = User, 3 = Message (https://discord.com/developers/docs/interactions/application-commands#user-commands)
|
||||
const data: ApplicationCommandData = {
|
||||
type,
|
||||
name: label,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GuildMember, Message } from "discord.js";
|
||||
import { GuildMember, Message, Snowflake } from "discord.js";
|
||||
import { EventEmitter } from "events";
|
||||
import { GuildCases } from "../../data/GuildCases";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GuildMember, MessageEmbedOptions } from "discord.js";
|
||||
import { GuildMember, MessageEmbedOptions, Snowflake } from "discord.js";
|
||||
import { PluginOptions } from "knub";
|
||||
import { GuildArchives } from "../../data/GuildArchives";
|
||||
import { GuildCases } from "../../data/GuildCases";
|
||||
|
|
Loading…
Add table
Reference in a new issue