Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add text command deprecation feature switches #1486

Draft
wants to merge 3 commits into
base: slash-commands-master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,10 @@
"title": "Round Finished"
}
},
"slashCommandReminder": {
"description": "Slash commands have new features that make them easier to use such as command name and option auto-complete! Commands have also been re-organized to be easier to use. Start by using / instead of ,",
"title": "Text commands will soon be disabled."
},
"songPlaying": {
"description": "Starting new round in 3 seconds...",
"title": "Error Playing Song"
Expand All @@ -1244,6 +1248,10 @@
"description": "Failed to find songs matching this criteria. Try to broaden your search.",
"title": "Song Query Error"
},
"textCommandsDisabled": {
"description": "Text commands have been disabled. Please use the new and improved slash commands! Start by using / instead of ,",
"title": "Text Commands Disabled"
},
"unrecognizedGroups": {
"added": "added",
"description": "One or more of the specified group names was not recognized. Those groups that matched are {{matchedGroupsAction}}. Please ensure that the group name matches exactly with the list provided by {{helpGroups}}.\nThe following groups were **not** recognized:\n {{unmatchedGroups}}\n{{solution}}",
Expand Down
8 changes: 8 additions & 0 deletions i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,10 @@
"title": "라운드 종료"
}
},
"slashCommandReminder": {
"description": "Slash commands have new features that make them easier to use such as command name and option auto-complete! Commands have also been re-organized to be easier to use. Start by using / instead of , [to be translated]",
"title": "Text commands will soon be disabled. [to be translated]"
},
"songPlaying": {
"description": "3초 후에 새 라운드 시작됩니다...",
"title": "노래를 재생하는 동안 오류가 발생했습니다"
Expand All @@ -1244,6 +1248,10 @@
"description": "이 기준과 일치하는 노래를 찾지 못했습니다. 검색 범위를 넓히십시오.",
"title": "노래 검색 오류"
},
"textCommandsDisabled": {
"description": "Text commands have been disabled. Please use the new and improved slash commands! Start by using / instead of , [to be translated]",
"title": "Text Commands Disabled [to be translated]"
},
"unrecognizedGroups": {
"added": "추가",
"description": "지정된 그룹 이름 중 하나 이상이 인식되지 않습니다. (일치하는 그룹은 {{matchedGroupsAction}}이며 그룹 이름이 {{helpGroups}}에서 제공한 목록과 정확히 일치하는지 확인하세요.)\n\n다음 그룹은 **인식되지 않습니다**.\n\n{{unmatchedGroups}}\n{{solution}}",
Expand Down
2 changes: 1 addition & 1 deletion src/events/client/interactionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,5 @@ export default async function interactionCreateHandler(
}

const executionTime = await measureExecutionTime(interactionPromise);
logger.info(` ${interactionName} took ${executionTime}ms`);
logger.info(`${interactionName} took ${executionTime}ms`);
}
40 changes: 40 additions & 0 deletions src/events/client/messageCreate.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import * as uuid from "uuid";
import { IPCLogger } from "../../logger";
import { delay } from "../../helpers/utils";
import {
getDebugLogHeader,
sendErrorMessage,
sendInfoMessage,
sendOptionsMessage,
} from "../../helpers/discord_utils";
import Eris from "eris";
import GuildPreference from "../../structures/guild_preference";
import KmqConfiguration from "../../kmq_configuration";
import LocalizationManager from "../../helpers/localization_manager";
import MessageContext from "../../structures/message_context";
import Session from "../../structures/session";
Expand Down Expand Up @@ -94,6 +97,43 @@ export default async function messageCreateHandler(
return;
}

// disable text commands if command is user facing (i.e has help documentation)
if (
invokedCommand.help &&
KmqConfiguration.Instance.textCommandsDisabled()
) {
sendErrorMessage(messageContext, {
title: LocalizationManager.localizer.translate(
message.guildID,
"misc.failure.textCommandsDisabled.title"
),
description: LocalizationManager.localizer.translate(
message.guildID,
"misc.failure.textCommandsDisabled.description"
),
});
return;
}

// periodically encourage user to use slash commands instead
if (
Math.random() < 0.1 &&
KmqConfiguration.Instance.slashCommandRemindersEnabled()
) {
sendInfoMessage(messageContext, {
title: LocalizationManager.localizer.translate(
message.guildID,
"misc.failure.slashCommandReminder.title"
),
description: LocalizationManager.localizer.translate(
message.guildID,
"misc.failure.slashCommandReminder.description"
),
});

await delay(1500);
taahamahdi marked this conversation as resolved.
Show resolved Hide resolved
}

if (
validate(
message,
Expand Down
8 changes: 8 additions & 0 deletions src/kmq_configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,12 @@ export default class KmqConfiguration {
disallowMigrations(): boolean {
return this.config["disallowMigrations"] ?? false;
}

textCommandsDisabled(): boolean {
return this.config["textCommandsDisabled"] ?? false;
}

slashCommandRemindersEnabled(): boolean {
return this.config["slashCommandRemindersEnabled"] ?? false;
}
}