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

Adds a link rule #89

Merged
merged 2 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ $ export SHICKA_RECORD_DEFAULT_CHANNEL=<your-record-default-channel-here>
$ export SHICKA_REFUSAL_DEFAULT_CHANNEL=<your-refusal-default-channel-here>
$ export SHICKA_VERIFICATION_DEFAULT_CHANNEL=<your-verification-default-channel-here>
$ export SHICKA_VERIFICATION_VERIFIED_ROLE=<your-verfication-verified-role-here>
$ export SHICKA_LINK_DEFAULT_ALERT_ACTION_CHANNEL=<your-link-default-alert-action-channel-here>
$ export SHICKA_LINK_DEFAULT_EXEMPT_CHANNELS=<your-link-default-exempt-channels-here>
$ export SHICKA_LINK_DEFAULT_EXEMPT_ROLES=<your-link-default-exempt-roles-here>
$ export SHICKA_LINK_REACTION_EMOJI=<your-link-reaction-emoji-here>
$ export SHICKA_LINK_OVERRIDE_RULES_CHANNEL=<your-link-override-rules-channel-here>
$ export SHICKA_RULE7_DEFAULT_ALERT_ACTION_CHANNEL=<your-rule7-default-alert-action-channel-here>
$ export SHICKA_RULE7_DEFAULT_EXEMPT_CHANNELS=<your-rule7-default-exempt-channels-here>
$ export SHICKA_RULE7_DEFAULT_EXEMPT_ROLES=<your-rule7-default-exempt-roles-here>
Expand Down Expand Up @@ -127,4 +132,6 @@ $ npm start

### Rules

- `link` flags messages which contain a hyperlink as such in the given channel (set to `$SHICKA_LINK_DEFAULT_ALERT_ACTION_CHANNEL` by default) except when posted in any of the given exempted channels (set to `$SHICKA_LINK_DEFAULT_EXEMPT_CHANNELS` by default), when posted by non-administrator members having any of the given exempted roles (set to `$SHICKA_LINK_DEFAULT_EXEMPT_ROLES` by default) or when posted by administrator members

- `rule7` flags messages which violate the rule 7 as such in the given channel (set to `$SHICKA_RULE7_DEFAULT_ALERT_ACTION_CHANNEL` by default) except when posted in any of the given exempted channels (set to `$SHICKA_RULE7_DEFAULT_EXEMPT_CHANNELS` by default), when posted by non-administrator members having any of the given exempted roles (set to `$SHICKA_RULE7_DEFAULT_EXEMPT_ROLES` by default) or when posted by administrator members
7 changes: 6 additions & 1 deletion src/compilations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import emojiCompilation from "./compilations/emoji.js";
import gateCompilation from "./compilations/gate.js";
import helpCompilation from "./compilations/help.js";
import leaderboardCompilation from "./compilations/leaderboard.js";
import linkCompilation from "./compilations/link.js";
import missionCompilation from "./compilations/mission.js";
import outfitCompilation from "./compilations/outfit.js";
import patchCompilation from "./compilations/patch.js";
Expand Down Expand Up @@ -44,6 +45,7 @@ type Emoji = typeof emojiCompilation;
type Gate = typeof gateCompilation;
type Help = typeof helpCompilation;
type Leaderboard = typeof leaderboardCompilation;
type Link = typeof linkCompilation;
type Mission = typeof missionCompilation;
type Outfit = typeof outfitCompilation;
type Patch = typeof patchCompilation;
Expand All @@ -62,7 +64,7 @@ type Trailer = typeof trailerCompilation;
type Update = typeof updateCompilation;
type Verification = typeof verificationCompilation;
type Verify = typeof verifyCompilation;
type Compilation = About | Application | Apply | Approval | Approve | Arrival | Bear | Chat | Count | Departure | Emoji | Gate | Help | Leaderboard | Mission | Outfit | Patch | Patching | Posting | Raw | Record | Refusal | Refuse | Roadmap | Rule7 | Soundtrack | Store | Tracker | Trailer | Update | Verification | Verify;
type Compilation = About | Application | Apply | Approval | Approve | Arrival | Bear | Chat | Count | Departure | Emoji | Gate | Help | Leaderboard | Link | Mission | Outfit | Patch | Patching | Posting | Raw | Record | Refusal | Refuse | Roadmap | Rule7 | Soundtrack | Store | Tracker | Trailer | Update | Verification | Verify;
const about: About = aboutCompilation;
const application: Application = applicationCompilation;
const apply: Apply = applyCompilation;
Expand All @@ -77,6 +79,7 @@ const emoji: Emoji = emojiCompilation;
const gate: Gate = gateCompilation;
const help: Help = helpCompilation;
const leaderboard: Leaderboard = leaderboardCompilation;
const link: Link = linkCompilation;
const mission: Mission = missionCompilation;
const outfit: Outfit = outfitCompilation;
const patch: Patch = patchCompilation;
Expand Down Expand Up @@ -111,6 +114,7 @@ export type {
Gate,
Help,
Leaderboard,
Link,
Mission,
Outfit,
Patch,
Expand Down Expand Up @@ -145,6 +149,7 @@ export {
gate,
help,
leaderboard,
link,
mission,
outfit,
patch,
Expand Down
17 changes: 17 additions & 0 deletions src/compilations/link.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type {Link} from "../dependencies.js";
import type {Localized} from "../utils/string.js";
import {link} from "../definitions.js";
import {compileAll} from "../utils/string.js";
type HelpWithChannelsLocalizations = Localized<(groups: Link["helpWithChannels"]) => string>;
type HelpWithoutChannelsLocalizations = Localized<(groups: Link["helpWithoutChannels"]) => string>;
type LinkCompilation = {
helpWithChannels: HelpWithChannelsLocalizations,
helpWithoutChannels: HelpWithoutChannelsLocalizations,
};
const helpWithChannelsLocalizations: HelpWithChannelsLocalizations = compileAll<Link["helpWithChannels"]>(link["helpWithChannels"]);
const helpWithoutChannelsLocalizations: HelpWithoutChannelsLocalizations = compileAll<Link["helpWithoutChannels"]>(link["helpWithoutChannels"]);
const linkCompilation: LinkCompilation = {
helpWithChannels: helpWithChannelsLocalizations,
helpWithoutChannels: helpWithoutChannelsLocalizations,
};
export default linkCompilation;
12 changes: 11 additions & 1 deletion src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import emojiDefinition from "./definitions/emoji.json" assert {type: "json"};
import gateDefinition from "./definitions/gate.json" assert {type: "json"};
import helpDefinition from "./definitions/help.json" assert {type: "json"};
import leaderboardDefinition from "./definitions/leaderboard.json" assert {type: "json"};
import linkDefinition from "./definitions/link.json" assert {type: "json"};
import missionDefinition from "./definitions/mission.json" assert {type: "json"};
import outfitDefinition from "./definitions/outfit.json" assert {type: "json"};
import patchDefinition from "./definitions/patch.json" assert {type: "json"};
Expand Down Expand Up @@ -172,6 +173,12 @@ type Leaderboard = {
reply: Localized<string>,
link: Localized<string>,
};
type Link = {
ruleName: string,
ruleReason: string,
helpWithChannels: Localized<string>,
helpWithoutChannels: Localized<string>,
};
type Mission = {
commandName: string,
commandDescription: Localized<string>,
Expand Down Expand Up @@ -320,7 +327,7 @@ type Verify = {
reply: Localized<string>,
noPermissionReply: Localized<string>,
};
type Definition = About | Application | Apply | Approval | Approve | Arrival | Bear | Chat | Count | Departure | Emoji | Gate | Help | Leaderboard | Mission | Outfit | Patch | Patching | Posting | Raw | Record | Refusal | Refuse | Roadmap | Rule7 | Soundtrack | Store | Tracker | Trailer | Update | Verification | Verify;
type Definition = About | Application | Apply | Approval | Approve | Arrival | Bear | Chat | Count | Departure | Emoji | Gate | Help | Leaderboard | Link | Mission | Outfit | Patch | Patching | Posting | Raw | Record | Refusal | Refuse | Roadmap | Rule7 | Soundtrack | Store | Tracker | Trailer | Update | Verification | Verify;
const about: About = aboutDefinition;
const application: Application = applicationDefinition;
const apply: Apply = applyDefinition;
Expand All @@ -335,6 +342,7 @@ const emoji: Emoji = emojiDefinition;
const gate: Gate = gateDefinition;
const help: Help = helpDefinition;
const leaderboard: Leaderboard = leaderboardDefinition;
const link: Link = linkDefinition;
const mission: Mission = missionDefinition;
const outfit: Outfit = outfitDefinition;
const patch: Patch = patchDefinition;
Expand Down Expand Up @@ -369,6 +377,7 @@ export type {
Gate,
Help,
Leaderboard,
Link,
Mission,
Outfit,
Patch,
Expand Down Expand Up @@ -403,6 +412,7 @@ export {
gate,
help,
leaderboard,
link,
mission,
outfit,
patch,
Expand Down
14 changes: 14 additions & 0 deletions src/definitions/link.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"ruleName": "link",
"ruleReason": "Flags messages which contain a hyperlink as such in the given channels",
"helpWithChannels": {
"en-US": "I flag messages which contain a hyperlink as such in $<channelMentions>",
"fr": "Je signale les messages qui contiennent un hyperlien comme tels dans $<channelMentions>",
"pt-BR": "Eu sinalizo mensagens que contêm um hiperligação por fazerem isso em $<channelMentions>"
},
"helpWithoutChannels": {
"en-US": "I flag messages which contain a hyperlink as such",
"fr": "Je signale les messages qui contiennent un hyperlien comme tels",
"pt-BR": "Eu sinalizo mensagens que contêm um hiperligação por fazerem isso"
}
}
5 changes: 4 additions & 1 deletion src/dependencies.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type EmojiDependency from "./dependencies/emoji.js";
import type GateDependency from "./dependencies/gate.js";
import type HelpDependency from "./dependencies/help.js";
import type LeaderboardDependency from "./dependencies/leaderboard.js";
import type LinkDependency from "./dependencies/link.js";
import type MissionDependency from "./dependencies/mission.js";
import type OutfitDependency from "./dependencies/outfit.js";
import type PatchDependency from "./dependencies/patch.js";
Expand Down Expand Up @@ -44,6 +45,7 @@ type Emoji = EmojiDependency;
type Gate = GateDependency;
type Help = HelpDependency;
type Leaderboard = LeaderboardDependency;
type Link = LinkDependency;
type Mission = MissionDependency;
type Outfit = OutfitDependency;
type Patch = PatchDependency;
Expand All @@ -62,7 +64,7 @@ type Trailer = TrailerDependency;
type Update = UpdateDependency;
type Verification = VerificationDependency;
type Verify = VerifyDependency;
type Dependency = About | Application | Apply | Approval | Approve | Arrival | Bear | Chat | Count | Departure | Emoji | Gate | Help | Leaderboard | Mission | Outfit | Patch | Patching | Posting | Raw | Record | Refusal | Refuse | Roadmap | Rule7 | Soundtrack | Store | Tracker | Trailer | Update | Verification | Verify;
type Dependency = About | Application | Apply | Approval | Approve | Arrival | Bear | Chat | Count | Departure | Emoji | Gate | Help | Leaderboard | Link | Mission | Outfit | Patch | Patching | Posting | Raw | Record | Refusal | Refuse | Roadmap | Rule7 | Soundtrack | Store | Tracker | Trailer | Update | Verification | Verify;
export type {Dependency as default};
export type {
About,
Expand All @@ -79,6 +81,7 @@ export type {
Gate,
Help,
Leaderboard,
Link,
Mission,
Outfit,
Patch,
Expand Down
9 changes: 9 additions & 0 deletions src/dependencies/link.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
type HelpWithChannelsGroups = {
channelMentions: () => string,
};
type HelpWithoutChannelsGroups = {};
type LinkDependency = {
helpWithChannels: HelpWithChannelsGroups,
helpWithoutChannels: HelpWithoutChannelsGroups,
};
export type {LinkDependency as default};
Binary file added src/emojis/link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/emojis/link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
AutoModerationRuleCreateOptions,
} from "discord.js";
import type {Localized} from "./utils/string.js";
import linkRule from "./rules/link.js";
import rule7Rule from "./rules/rule7.js";
type AutoModerationRuleData = Omit<AutoModerationRuleCreateOptions, "exemptChannels" | "exemptRoles" | "actions"> & {
exemptChannels?: string[],
Expand All @@ -23,6 +24,7 @@ type Rule = {
execute(execution: AutoModerationActionExecution): Promise<void>;
describe(autoModerationRule: AutoModerationRule): Localized<(groups: {}) => string>;
};
const link: Rule = linkRule;
const rule7: Rule = rule7Rule;
export type {Rule as default};
export type {
Expand All @@ -31,5 +33,6 @@ export type {
AutoModerationRuleData,
};
export {
link,
rule7,
};
Loading