-
Notifications
You must be signed in to change notification settings - Fork 717
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from saiteja-madha/feat-flagtr
Feat flag-tr
- Loading branch information
Showing
9 changed files
with
346 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
const { Command, CommandContext } = require("@src/structures"); | ||
const db = require("@schemas/guild-schema"); | ||
|
||
module.exports = class FlagTranslation extends Command { | ||
constructor(client) { | ||
super(client, { | ||
name: "flagtr", | ||
description: "setup flag translation", | ||
minArgsCount: 1, | ||
subcommands: [ | ||
{ | ||
trigger: "<ON|OFF>", | ||
description: "enable or disable translation by flags", | ||
}, | ||
{ | ||
trigger: "status", | ||
description: "flag translation status", | ||
}, | ||
{ | ||
trigger: "add <#channel(s)>", | ||
description: "add channels where flag translation must occur", | ||
}, | ||
{ | ||
trigger: "remove <#channel(s)>", | ||
description: "remove channels with flag translations enabled", | ||
}, | ||
], | ||
category: "ADMIN", | ||
userPermissions: ["ADMINISTRATOR"], | ||
}); | ||
} | ||
|
||
/** | ||
* @param {CommandContext} ctx | ||
*/ | ||
async run(ctx) { | ||
const { args, message } = ctx; | ||
const input = args[0].toLowerCase(); | ||
const mentions = message.mentions.channels.map((ch) => ch.id); | ||
const settings = await db.getSettings(message.guild); | ||
|
||
switch (input) { | ||
case "add": | ||
if (mentions.size === 0) return message.reply("Incorrect usage! You need to mentions channels"); | ||
let toAdd = [...new Set([...mentions, ...settings.flag_translation.channels])]; | ||
await db.setFlagTrChannels(message.guildId, toAdd); | ||
ctx.reply("Success! Configuration saved"); | ||
break; | ||
|
||
case "remove": | ||
if (mentions.size === 0) return message.reply("Incorrect usage! You need to mentions channels"); | ||
let newIds = settings.flag_translation.channels.filter((item) => !mentions.includes(item)); | ||
await db.setFlagTrChannels(message.guildId, newIds); | ||
ctx.reply("Success! Configuration saved"); | ||
break; | ||
|
||
case "status": | ||
if (!settings.flag_translation.enabled) return await ctx.reply("Flag translation is disabled in this server"); | ||
let channels = settings.flag_translation.channels | ||
.filter((id) => message.guild.channels.cache.has(id)) | ||
.map((id) => message.guild.channels.cache.get(id).toString()) | ||
.join(", "); | ||
|
||
if (!channels) return ctx.reply("Flag translation is enabled in all channels"); | ||
ctx.reply("Flag translation is enabled in following channels: \n" + channels); | ||
break; | ||
|
||
default: | ||
let status; | ||
if (input === "none" || input === "off" || input === "disable") status = false; | ||
else if (input === "on" || input === "enable") status = true; | ||
else return message.reply("Incorrect Command Usage"); | ||
|
||
await db.flagTranslation(message.guildId, status); | ||
ctx.reply(`Configuration saved! Flag translation is now ${status ? "enabled" : "disabled"}`); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
{ | ||
"GOOGLE_TRANSLATE": { | ||
"auto": "Automatic", | ||
"af": "Afrikaans", | ||
"sq": "Albanian", | ||
"am": "Amharic", | ||
"ar": "Arabic", | ||
"hy": "Armenian", | ||
"az": "Azerbaijani", | ||
"eu": "Basque", | ||
"be": "Belarusian", | ||
"bn": "Bengali", | ||
"bs": "Bosnian", | ||
"bg": "Bulgarian", | ||
"ca": "Catalan", | ||
"ceb": "Cebuano", | ||
"ny": "Chichewa", | ||
"zh-CN": "Chinese (Simplified)", | ||
"zh-TW": "Chinese (Traditional)", | ||
"co": "Corsican", | ||
"hr": "Croatian", | ||
"cs": "Czech", | ||
"da": "Danish", | ||
"nl": "Dutch", | ||
"en": "English", | ||
"eo": "Esperanto", | ||
"et": "Estonian", | ||
"tl": "Filipino", | ||
"fi": "Finnish", | ||
"fr": "French", | ||
"fy": "Frisian", | ||
"gl": "Galician", | ||
"ka": "Georgian", | ||
"de": "German", | ||
"el": "Greek", | ||
"gu": "Gujarati", | ||
"ht": "Haitian Creole", | ||
"ha": "Hausa", | ||
"haw": "Hawaiian", | ||
"he": "Hebrew", | ||
"iw": "Hebrew", | ||
"hi": "Hindi", | ||
"hmn": "Hmong", | ||
"hu": "Hungarian", | ||
"is": "Icelandic", | ||
"ig": "Igbo", | ||
"id": "Indonesian", | ||
"ga": "Irish", | ||
"it": "Italian", | ||
"ja": "Japanese", | ||
"jw": "Javanese", | ||
"kn": "Kannada", | ||
"kk": "Kazakh", | ||
"km": "Khmer", | ||
"ko": "Korean", | ||
"ku": "Kurdish (Kurmanji)", | ||
"ky": "Kyrgyz", | ||
"lo": "Lao", | ||
"la": "Latin", | ||
"lv": "Latvian", | ||
"lt": "Lithuanian", | ||
"lb": "Luxembourgish", | ||
"mk": "Macedonian", | ||
"mg": "Malagasy", | ||
"ms": "Malay", | ||
"ml": "Malayalam", | ||
"mt": "Maltese", | ||
"mi": "Maori", | ||
"mr": "Marathi", | ||
"mn": "Mongolian", | ||
"my": "Myanmar (Burmese)", | ||
"ne": "Nepali", | ||
"no": "Norwegian", | ||
"ps": "Pashto", | ||
"fa": "Persian", | ||
"pl": "Polish", | ||
"pt": "Portuguese", | ||
"pa": "Punjabi", | ||
"ro": "Romanian", | ||
"ru": "Russian", | ||
"sm": "Samoan", | ||
"gd": "Scots Gaelic", | ||
"sr": "Serbian", | ||
"st": "Sesotho", | ||
"sn": "Shona", | ||
"sd": "Sindhi", | ||
"si": "Sinhala", | ||
"sk": "Slovak", | ||
"sl": "Slovenian", | ||
"so": "Somali", | ||
"es": "Spanish", | ||
"su": "Sundanese", | ||
"sw": "Swahili", | ||
"sv": "Swedish", | ||
"tg": "Tajik", | ||
"ta": "Tamil", | ||
"te": "Telugu", | ||
"th": "Thai", | ||
"tr": "Turkish", | ||
"uk": "Ukrainian", | ||
"ur": "Urdu", | ||
"uz": "Uzbek", | ||
"vi": "Vietnamese", | ||
"cy": "Welsh", | ||
"xh": "Xhosa", | ||
"yi": "Yiddish", | ||
"yo": "Yoruba", | ||
"zu": "Zulu" | ||
}, | ||
"UNICODE_LETTER": { | ||
"🇦": "a", | ||
"🇧": "b", | ||
"🇨": "c", | ||
"🇩": "d", | ||
"🇪": "e", | ||
"🇫": "f", | ||
"🇬": "g", | ||
"🇭": "h", | ||
"🇮": "i", | ||
"🇯": "j", | ||
"🇰": "k", | ||
"🇱": "l", | ||
"🇲": "m", | ||
"🇳": "n", | ||
"🇴": "o", | ||
"🇵": "p", | ||
"🇶": "q", | ||
"🇷": "r", | ||
"🇸": "s", | ||
"🇹": "t", | ||
"🇺": "u", | ||
"🇻": "v", | ||
"🇼": "w", | ||
"🇽": "x", | ||
"🇾": "y", | ||
"🇿": "z" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.