diff --git a/deno.json b/deno.json index 205a55a..d87e593 100644 --- a/deno.json +++ b/deno.json @@ -1,14 +1,24 @@ { + "compilerOptions": { + "noImplicitAny": false + }, + "lint": { + "rules": { + "exclude": [ + "no-explicit-any" + ] + } + }, "fmt": { "files": { "exclude": [ "velociraptor.yaml", - "src/deps/" + "src/deps.ts" ] }, "options": { "useTabs": true, - "lineWidth": 80, + "lineWidth": 90, "indentWidth": 4, "singleQuote": false, "proseWrap": "preserve" diff --git a/deps.ts b/deps.ts index 61e5984..4988eb9 100644 --- a/deps.ts +++ b/deps.ts @@ -1,35 +1,33 @@ export { - ActivityTypes, - addRole, - ApplicationCommandOptionTypes, - ApplicationCommandTypes, - ButtonStyles, - channelOverwriteHasPermission, - createApplicationCommand, - createBot, - deleteMessage, - editBotStatus, - getMember, - getUser, - InteractionResponseTypes, - MessageComponentTypes, - OverwriteTypes, - removeRole, - sendInteractionResponse, - sendMessage, - startBot, -} from "https://deno.land/x/discordeno@13.0.0-rc11/mod.ts"; + ActivityTypes, + addRole, + ApplicationCommandOptionTypes, + ApplicationCommandTypes, + ButtonStyles, + createApplicationCommand, + createBot, + deleteMessage, + editBotStatus, + getMember, + getUser, + InteractionResponseTypes, + MessageComponentTypes, + OverwriteTypes, + removeRole, + sendInteractionResponse, + sendMessage, + startBot, +} from "https://deno.land/x/discordeno@13.0.0-rc22/mod.ts"; export type { - Bot, - CreateGlobalApplicationCommand, - DiscordenoInteraction, - DiscordenoMember, - DiscordenoMessage, - Embed, - GuildMember, -} from "https://deno.land/x/discordeno@13.0.0-rc11/mod.ts"; + Bot, + DiscordenoInteraction, + DiscordenoMember, + DiscordenoMessage, + Embed, + GuildMember, +} from "https://deno.land/x/discordeno@13.0.0-rc22/mod.ts"; -export { config } from "https://deno.land/x/dotenv/mod.ts"; +export { config as dotenv } from "https://deno.land/x/dotenv/mod.ts"; export type { DotenvConfig } from "https://deno.land/x/dotenv/mod.ts"; diff --git a/src/buttons/announcements.ts b/src/buttons/announcements.ts index 0984d36..ce2d9c5 100644 --- a/src/buttons/announcements.ts +++ b/src/buttons/announcements.ts @@ -1,4 +1,11 @@ -import { addRole, Bot, DiscordenoInteraction, InteractionResponseTypes, removeRole, sendInteractionResponse } from "../deps/discordeno.ts"; +import { + addRole, + Bot, + DiscordenoInteraction, + InteractionResponseTypes, + removeRole, + sendInteractionResponse, +} from "../../deps.ts"; export default () => { return { diff --git a/src/buttons/helper.ts b/src/buttons/helper.ts index af3418c..e009c41 100644 --- a/src/buttons/helper.ts +++ b/src/buttons/helper.ts @@ -1,4 +1,11 @@ -import { addRole, Bot, DiscordenoInteraction, InteractionResponseTypes, removeRole, sendInteractionResponse } from "../deps/discordeno.ts"; +import { + addRole, + Bot, + DiscordenoInteraction, + InteractionResponseTypes, + removeRole, + sendInteractionResponse, +} from "../../deps.ts"; export default () => { return { diff --git a/src/commands/help.ts b/src/commands/help.ts deleted file mode 100644 index 50b20a6..0000000 --- a/src/commands/help.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { Bot, ButtonStyles, DiscordenoInteraction, InteractionResponseTypes, MessageComponentTypes, sendInteractionResponse } from "../deps/discordeno.ts"; -import { commands } from "../mod.ts"; - -export default () => { - return { - name: "help", - description: "Get help of me", - options: [], - exe: (bot: Bot, interaction: DiscordenoInteraction) => { - const cmds: string[] = []; - commands.forEach((c) => cmds.push("`" + c.name + "`")); - - const embed = { - color: 0xffe359, - title: "Mark Bot Help", - description: "Haha I am Mark Bot. You can use `/` for see all my commands", - fields: [ - { - name: "Commands", - value: cmds.join(" - "), - inline: false, - }, - ], - }; - - sendInteractionResponse(bot, interaction.id, interaction.token, { - type: InteractionResponseTypes.ChannelMessageWithSource, - data: { - embeds: [embed], - components: [ - { - type: 1, - components: [ - { - type: MessageComponentTypes.Button, - label: "GitHub", - style: ButtonStyles.Link, - url: "https://github.com/lajbel/markbot", - emoji: { id: "915652987186217020", name: "github" }, - }, - { - type: MessageComponentTypes.Button, - label: "Replit", - style: ButtonStyles.Link, - url: "https://replit.com/@slmjkdbtl/markbot", - emoji: { id: "913874499731071016", name: "replit" }, - }, - ], - }, - ], - }, - }); - }, - }; -}; diff --git a/src/commands/hi.ts b/src/commands/hi.ts index 9058b65..c16344c 100644 --- a/src/commands/hi.ts +++ b/src/commands/hi.ts @@ -1,9 +1,16 @@ -import { ApplicationCommandOptionTypes, Bot, DiscordenoInteraction, getUser, InteractionResponseTypes, sendInteractionResponse } from "../deps/discordeno.ts"; +import { + ApplicationCommandOptionTypes, + Bot, + DiscordenoInteraction, + getUser, + InteractionResponseTypes, + sendInteractionResponse, +} from "../../deps.ts"; export default () => { return { name: "hi", - description: "Oh hi", + description: "ohhi", options: [ { type: ApplicationCommandOptionTypes.User, @@ -13,12 +20,17 @@ export default () => { }, ], exe: async (bot: Bot, interaction: DiscordenoInteraction) => { - const member = interaction?.data?.resolved?.members?.first() || interaction?.member; + const member = interaction?.data?.resolved?.members?.first() || + interaction?.member; const user = await getUser(bot, member?.id!); sendInteractionResponse(bot, interaction.id, interaction.token, { type: InteractionResponseTypes.ChannelMessageWithSource, - data: { content: `Oh hi ${member?.nick ?? user?.username}` }, + data: { + content: `<:oh:952678706927775784><:hi:952678717526798398> ${ + member?.nick ?? user?.username + }`, + }, }); }, }; diff --git a/src/commands/kaboom.ts b/src/commands/kaboom.ts index 4e85a03..b8bc62e 100644 --- a/src/commands/kaboom.ts +++ b/src/commands/kaboom.ts @@ -1,9 +1,14 @@ -import { Bot, DiscordenoInteraction, InteractionResponseTypes, sendInteractionResponse } from "../deps/discordeno.ts"; +import { + Bot, + DiscordenoInteraction, + InteractionResponseTypes, + sendInteractionResponse, +} from "../../deps.ts"; export default () => { return { name: "kaboom", - description: "KaBoom!!!", + description: "make a ka-boom!!!", options: [], exe: (bot: Bot, interaction: DiscordenoInteraction) => { const funnyKaboom = [ diff --git a/src/commands/roles.ts b/src/commands/roles.ts index 4411995..1242a20 100644 --- a/src/commands/roles.ts +++ b/src/commands/roles.ts @@ -1,23 +1,23 @@ -import { - Bot, - ButtonStyles, - DiscordenoInteraction, - InteractionResponseTypes, - MessageComponentTypes, - sendInteractionResponse +import { + Bot, + ButtonStyles, + DiscordenoInteraction, + InteractionResponseTypes, + MessageComponentTypes, + sendInteractionResponse, } from "../../deps.ts"; export default () => { return { name: "roles", - description: "Get a ka-role", + description: "get a ka-role", options: [], exe: (bot: Bot, interaction: DiscordenoInteraction) => { const embed = { color: 0xffe359, title: "Roles of Kaboom Discord", description: - "<@&901298683906240582> - <:minimark:883793329647652934> - You will be mentioned by people who need help\n<@&901533627802873876> - <:cowmark:884789264745897994> - You will be mentioned for announcements", + "<@&901298683906240582> - You will be mentioned by people who need help\n<@&901533627802873876> - You will be mentioned for announcements", }; sendInteractionResponse(bot, interaction.id, interaction.token, { @@ -34,14 +34,20 @@ export default () => { label: "Helper", customId: "helper_button", style: ButtonStyles.Primary, - emoji: { id: "884813519961342002", name: "kbmhearth" }, + emoji: { + id: "884813519961342002", + name: "kbmhearth", + }, }, { type: MessageComponentTypes.Button, label: "Announcements", customId: "announcements_button", - style: ButtonStyles.Primary, - emoji: { id: "14611006838284310", name: "kbm_pineapple" }, + style: ButtonStyles.Secondary, + emoji: { + id: "914611006838284310", + name: "kbm_pineapple", + }, }, ], }, diff --git a/src/commands/tip.ts b/src/commands/tip.ts index c019311..40765ee 100644 --- a/src/commands/tip.ts +++ b/src/commands/tip.ts @@ -4,24 +4,36 @@ import { Embed, InteractionResponseTypes, sendInteractionResponse, -} from "../deps/discordeno.ts"; +} from "../../deps.ts"; export default () => { return { name: "tip", - description: "Get a tip of the Kaboom World", + description: "get a tip about the Kaboom World", options: [], exe: (bot: Bot, interaction: DiscordenoInteraction) => { const tips = [ - { t: "npm i kaboom@next", img: null }, - { t: "kaboom({\nburp: true})", img: null }, + { + t: "`npm i kaboom@next`", + img: null, + }, + { + t: "```js\nkaboom({\n burp: true,\n});```", + img: null, + }, + { + t: "mention <@&901298683906240582> for get <#883782079802908772> about kaboom", + }, + { + t: "you can use these fonts in your kaboom game without import anything: `apl386`, `apl386o`, `sink`, `sinko`", + }, ]; const tip = tips[Math.floor(Math.random() * tips.length)]; const embed: Embed = { color: 0xffe359, - title: "TIP", + title: "Kaboom TIP", description: tip.t, }; diff --git a/src/deps/discordeno.ts b/src/deps/discordeno.ts deleted file mode 100644 index 04f79b9..0000000 --- a/src/deps/discordeno.ts +++ /dev/null @@ -1,31 +0,0 @@ -export { - ActivityTypes, - addRole, - ApplicationCommandOptionTypes, - ApplicationCommandTypes, - ButtonStyles, - channelOverwriteHasPermission, - createApplicationCommand, - createBot, - deleteMessage, - editBotStatus, - getMember, - getUser, - InteractionResponseTypes, - MessageComponentTypes, - OverwriteTypes, - removeRole, - sendInteractionResponse, - sendMessage, - startBot, -} from "https://deno.land/x/discordeno@13.0.0-rc11/mod.ts"; - -export type { - Bot, - CreateGlobalApplicationCommand, - DiscordenoInteraction, - DiscordenoMember, - DiscordenoMessage, - Embed, - GuildMember, -} from "https://deno.land/x/discordeno@13.0.0-rc11/mod.ts"; diff --git a/src/deps/dotenv.ts b/src/deps/dotenv.ts deleted file mode 100644 index c2e5de7..0000000 --- a/src/deps/dotenv.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { config } from "https://deno.land/x/dotenv/mod.ts"; - -export type { DotenvConfig } from "https://deno.land/x/dotenv/mod.ts"; diff --git a/src/events/interactionCreate.ts b/src/events/interactionCreate.ts index c4beffa..b8abe6e 100644 --- a/src/events/interactionCreate.ts +++ b/src/events/interactionCreate.ts @@ -1,5 +1,5 @@ import { buttonsActions, commands } from "../mod.ts"; -import { Bot, DiscordenoInteraction } from "../deps/discordeno.ts"; +import { Bot, DiscordenoInteraction } from "../../deps.ts"; export function interactionCreate( bot: Bot, diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 2789609..a0f9a31 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -1,22 +1,17 @@ -import { - Bot, - deleteMessage, - DiscordenoMessage, - sendMessage, -} from "../deps/discordeno.ts"; +import { Bot, deleteMessage, DiscordenoMessage, sendMessage } from "../../deps.ts"; + +export function messageCreate(bot: Bot, message: DiscordenoMessage): any { + const regAI = /(https:\/\/)?((discord|discordapp).((gg\/\w+)|(com\/(invite\/\w+))))/g; -export function messageCreate(bot: Bot, message: DiscordenoMessage) { // anti-invites for users lol if ( - message.content.match( - /(https:\/\/)?((discord|discordapp).((gg\/\w+)|(com\/(invite\/\w+))))/g, - ) + message.content.match(regAI) && + !message.member?.roles.includes(883786808062787594n) ) { - sendMessage( - bot, - message.channelId, - "No send invites!!! help <@632319035102462004>", - ); + sendMessage(bot, message.channelId, { + content: "No send invites!!! help <@947683287369912330>", + }); + deleteMessage(bot, message.channelId, message.id); } } diff --git a/src/events/ready.ts b/src/events/ready.ts index 0295538..03ced05 100644 --- a/src/events/ready.ts +++ b/src/events/ready.ts @@ -1,9 +1,4 @@ -import { - ActivityTypes, - Bot, - editBotStatus, - getUser, -} from "../deps/discordeno.ts"; +import { ActivityTypes, Bot, editBotStatus, getUser } from "../../deps.ts"; export async function ready(bot: Bot) { const botUser = await getUser(bot, bot.id); @@ -13,15 +8,16 @@ export async function ready(bot: Bot) { ); const funnyStatus = [ - "Bean...", - "Your mom", + "Bean is cool", + "KABOOM", "Kaboom Server", "Family Friendly Words", "Powerful", - "Kajam 2025", + "KaJam 2025", "discord.gg/kaboom", - "Mark Z", - "Kaboom 6969", + "Markz", + "Increible Games", + "a", ]; function editFunnyStatus() { diff --git a/src/mod.ts b/src/mod.ts index 83cd181..d9312c5 100644 --- a/src/mod.ts +++ b/src/mod.ts @@ -3,27 +3,21 @@ import { Bot, createApplicationCommand, createBot, + dotenv, startBot, -} from "./deps/discordeno.ts"; - -import { config, DotenvConfig } from "./deps/dotenv.ts"; - -import { readDir } from "./util/readDir.ts"; +} from "../deps.ts"; import { interactionCreate } from "./events/interactionCreate.ts"; import { messageCreate } from "./events/messageCreate.ts"; import { ready } from "./events/ready.ts"; -const env: DotenvConfig = config(); - -const token = env.TOKEN ? env.TOKEN : Deno.env.get("TOKEN")!; -const id = env.ID ? env.ID : Deno.env.get("ID")!; +export const commands = new Map(); +export const buttonsActions = new Map(); -// bot setup -const bot: Bot = createBot({ - token: token, - botId: BigInt(id), - applicationId: BigInt(id), +export const bot: Bot = createBot({ + token: dotenv().TOKEN || Deno.env.get("TOKEN")!, + botId: BigInt(dotenv().ID || BigInt(Deno.env.get("ID")!)), + applicationId: BigInt(dotenv().ID || BigInt(Deno.env.get("ID")!)), intents: ["Guilds", "GuildMessages"], events: { interactionCreate, @@ -32,11 +26,7 @@ const bot: Bot = createBot({ }, }); -// load interactions (commands and buttons) -export const commands = new Map(); -export const buttonsActions = new Map(); - -readDir("src/commands", async (file) => { +for await (const file of Deno.readDir("src/commands")) { const cmd = await import(`./commands/${file.name}`); const command = cmd.default(); @@ -48,13 +38,13 @@ readDir("src/commands", async (file) => { }, 883781994583056384n); commands.set(command.name, command); -}); +} -readDir("src/buttons", async (file) => { +for await (const file of Deno.readDir("src/buttons")) { const btn = await import(`./buttons/${file.name}`); const button = btn.default(); buttonsActions.set(button.name, button); -}); +} startBot(bot); diff --git a/src/util/readDir.ts b/src/util/readDir.ts deleted file mode 100644 index 8d31626..0000000 --- a/src/util/readDir.ts +++ /dev/null @@ -1,10 +0,0 @@ -export async function readDir( - dir: string, - func: (file: Deno.DirEntry) => void, -) { - for await (const file of Deno.readDir(dir)) { - if (file.name.endsWith(".ts")) { - func(file); - } - } -}