diff --git a/.env.example b/.env.example index cb02aca4..0a03ee76 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,6 @@ DISCORD_TOKEN= +DISCORD_DEV_GUILD= +DISCORD_SUPPORT_INVITE= DISCORD_PREFIX= PGHOST= @@ -13,3 +15,5 @@ AI_TOKEN= AI_URL= NODE_ENV= + +DATABASE_URL= diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..3bbb6e12 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,132 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at the +[Support Server](https://discord.gg/AbUw9fh). +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available +at [https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 00000000..f78bb7d4 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,17 @@ +# Contributing + +**The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the [Discord Server](https://discord.gg/VArQNt9PvC) instead of opening an issue – you will get redirected there anyway.** + +If you wish to contribute to the project, feel free to fork the repository and submit a +pull request. We use ESLint to enforce a consistent coding style, so having that set up in your editor of choice +is a great boon to your development process. + +## Setup + +To get ready to work on the codebase, please do the following: + +1. Fork & clone the repository, and make sure you're on the **main** branch +2. Run `npm ci` +3. Code! +4. Run `npm run test` to run ESLint and the TypeScript compiler +5. [Submit a pull request](https://github.com/Fluorinebot/fluorine/compare) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index f4fccc01..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,10 +0,0 @@ -this is my story how being a bus and a juice is - - -if you are born on september 9th expect my bus driving into your house soon - -i hear people all the time saying kurwa when they go on ku **bus** and i become sad because they are mad at me ........... - - -At least im good as a juice : pensive: -Polish monkeys (Nfts) are idiots Lol diff --git a/i18n/en-US.json b/i18n/en-US.json index 2d5fb3b0..9f08703d 100644 --- a/i18n/en-US.json +++ b/i18n/en-US.json @@ -195,6 +195,8 @@ "STATS_COMMAND_COUNT": "Command count", "STATS_SERVER_COUNT": "Server count", "STATS_USER_COUNT": "User count", + "SUPPORT_TITLE": "Need some help?", + "SUPPORT_DESCRIPTION": "Join the support server [here]({{- link}})", "TIMEOUT": "Timeout", "TIMEOUT_BOT_PERMISSIONS_MISSING": "I can't timeout this member, I don't have permissions needed to timeout!", "TIMEOUT_DURATION_INVALID": "The duration you provided is invalid!", diff --git a/i18n/pl.json b/i18n/pl.json index 444bbbff..e905de9d 100644 --- a/i18n/pl.json +++ b/i18n/pl.json @@ -188,6 +188,8 @@ "STATS_COMMAND_COUNT": "Ilość komend", "STATS_SERVER_COUNT": "Ilość serwerów", "STATS_USER_COUNT": "Ilość użytkowników", + "SUPPORT_TITLE": "Potrzebujesz pomocy?", + "SUPPORT_DESCRIPTION": "Dołącz na serwer support [tutaj]({{- link}})", "TIMEOUT": "Przerwa", "TIMEOUT_BOT_PERMISSIONS_MISSING": "Nie mogę wyciszyć tego członka, nie posiadam potrzebnych permisji!", "TIMEOUT_DURATION_INVALID": "Podałeś nieprawidłową długość wyciszenia!", diff --git a/src/classes/Client.ts b/src/classes/Client.ts index e5da6d74..5bcaee84 100644 --- a/src/classes/Client.ts +++ b/src/classes/Client.ts @@ -39,6 +39,7 @@ export default class FluorineClient extends Client { version = process.env.npm_package_version; devs = ['707675871355600967', '478823932913516544', '348591272476540928']; + support = process.env.DISCORD_SUPPORT_INVITE; restModule = new REST({ version: '10' }); db = new Database(); @@ -55,7 +56,10 @@ export default class FluorineClient extends Client { Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS ], partials: ['MESSAGE'], - allowedMentions: { repliedUser: false } + allowedMentions: { repliedUser: false }, + presence: { + activities: [{ name: 'with dangerous chemicals | /help', type: 'PLAYING' }] + } }); } diff --git a/src/classes/modules/CasesModule.ts b/src/classes/modules/CasesModule.ts index 46e54cd4..937b749b 100644 --- a/src/classes/modules/CasesModule.ts +++ b/src/classes/modules/CasesModule.ts @@ -40,6 +40,10 @@ export default class CasesModule { ]) ).rows; + if (!ret) { + return null; + } + ret.guild_id = BigInt(ret.guild_id); ret.case_creator = BigInt(ret.case_creator); ret.moderated_user = BigInt(ret.moderated_user); diff --git a/src/commands/case/index.ts b/src/commands/case/index.ts new file mode 100644 index 00000000..77e62955 --- /dev/null +++ b/src/commands/case/index.ts @@ -0,0 +1,13 @@ +import { SlashCommandBuilder } from '@discordjs/builders'; +import { PermissionFlagsBits } from 'discord-api-types/v10'; +import { Category } from 'types/structures'; + +export const data = new SlashCommandBuilder() + .setName('case') + .setNameLocalizations({ pl: 'kara' }) + .setDescription('Check moderation cases') + .setDescriptionLocalizations({ pl: 'Sprawdz informacje o karze' }) + .setDefaultMemberPermissions(PermissionFlagsBits.ViewAuditLog) + .setDMPermission(false); + +export const category: Category = 'moderation'; diff --git a/src/commands/list-cases.ts b/src/commands/case/list.ts similarity index 86% rename from src/commands/list-cases.ts rename to src/commands/case/list.ts index a2710807..767d6a4c 100644 --- a/src/commands/list-cases.ts +++ b/src/commands/case/list.ts @@ -1,9 +1,7 @@ import FluorineClient from '@classes/Client'; import Embed from '@classes/Embed'; import { CommandInteraction, InteractionReplyOptions, MessageActionRow, MessageButton } from 'discord.js'; -import { SlashCommandBuilder } from '@discordjs/builders'; -import { PermissionFlagsBits } from 'discord-api-types/v10'; -import { Category } from 'types/structures'; +import { SlashCommandSubcommandBuilder } from '@discordjs/builders'; import { splitArray } from '@util/splitArr'; export async function run(client: FluorineClient, interaction: CommandInteraction<'cached'>) { @@ -73,13 +71,11 @@ export async function run(client: FluorineClient, interaction: CommandInteractio interaction.reply(replyOptions); } -export const data = new SlashCommandBuilder() - .setName('list-cases') - .setNameLocalizations({ pl: 'lista-kar' }) +export const data = new SlashCommandSubcommandBuilder() + .setName('list') + .setNameLocalizations({ pl: 'lista' }) .setDescription('Check punishments of a user') .setDescriptionLocalizations({ pl: 'Sprawdź kary użytkownika' }) - .setDefaultMemberPermissions(PermissionFlagsBits.ViewAuditLog) - .setDMPermission(false) .addUserOption(option => option .setName('user') @@ -88,5 +84,3 @@ export const data = new SlashCommandBuilder() .setDescriptionLocalizations({ pl: 'Użytkownik, którego chcesz sprawdzić' }) .setRequired(true) ); - -export const category: Category = 'tools'; diff --git a/src/commands/case.ts b/src/commands/case/view.ts similarity index 80% rename from src/commands/case.ts rename to src/commands/case/view.ts index da273933..24de6174 100644 --- a/src/commands/case.ts +++ b/src/commands/case/view.ts @@ -1,9 +1,7 @@ import FluorineClient from '@classes/Client'; import Embed from '@classes/Embed'; import { CommandInteraction } from 'discord.js'; -import { SlashCommandBuilder } from '@discordjs/builders'; -import { PermissionFlagsBits } from 'discord-api-types/v10'; -import { Category } from 'types/structures'; +import { SlashCommandSubcommandBuilder } from '@discordjs/builders'; export async function run(client: FluorineClient, interaction: CommandInteraction) { const id = interaction.options.getInteger('id'); @@ -35,13 +33,11 @@ export async function run(client: FluorineClient, interaction: CommandInteractio interaction.reply({ embeds: [embed] }); } -export const data = new SlashCommandBuilder() - .setName('case') - .setNameLocalizations({ pl: 'kara' }) +export const data = new SlashCommandSubcommandBuilder() + .setName('view') + .setNameLocalizations({ pl: 'zobacz' }) .setDescription('Check a moderation case') .setDescriptionLocalizations({ pl: 'Sprawdz informacje o karze' }) - .setDefaultMemberPermissions(PermissionFlagsBits.ViewAuditLog) - .setDMPermission(false) .addIntegerOption(option => option .setName('id') @@ -51,5 +47,3 @@ export const data = new SlashCommandBuilder() .setMinValue(1) .setRequired(true) ); - -export const category: Category = 'moderation'; diff --git a/src/commands/support.ts b/src/commands/support.ts new file mode 100644 index 00000000..dc757ec4 --- /dev/null +++ b/src/commands/support.ts @@ -0,0 +1,20 @@ +import FluorineClient from '@classes/Client'; +import Embed from '@classes/Embed'; +import { SlashCommandBuilder } from '@discordjs/builders'; +import { CommandInteraction } from 'discord.js'; +import { Category } from 'types/structures'; + +export async function run(client: FluorineClient, interaction: CommandInteraction) { + const embed = new Embed(client, interaction.locale) + .setLocaleTitle('SUPPORT_TITLE') + .setLocaleDescription('SUPPORT_DESCRIPTION', { link: client.support }); + interaction.reply({ embeds: [embed] }); +} + +export const data = new SlashCommandBuilder() + .setName('support') + .setNameLocalizations({ pl: 'support' }) + .setDescription("Get an invite link to Fluorine's support server") + .setDescriptionLocalizations({ pl: 'Zdobądź zaproszenie do serwera support Fluorine' }); + +export const category: Category = 'tools'; diff --git a/src/context/listcase.ts b/src/context/list-cases.ts similarity index 94% rename from src/context/listcase.ts rename to src/context/list-cases.ts index c0f16a4c..d3729ee5 100644 --- a/src/context/listcase.ts +++ b/src/context/list-cases.ts @@ -2,7 +2,7 @@ import FluorineClient from '@classes/Client'; import Embed from '@classes/Embed'; import { InteractionReplyOptions, MessageActionRow, MessageButton, UserContextMenuInteraction } from 'discord.js'; import { ContextMenuCommandBuilder } from '@discordjs/builders'; -import { ApplicationCommandType } from 'discord-api-types/v10'; +import { ApplicationCommandType, PermissionFlagsBits } from 'discord-api-types/v10'; import { splitArray } from '@util/splitArr'; export async function run(client: FluorineClient, interaction: UserContextMenuInteraction<'cached'>) { @@ -68,5 +68,6 @@ export async function run(client: FluorineClient, interaction: UserContextMenuIn export const data = new ContextMenuCommandBuilder() .setName('List Cases') .setNameLocalizations({ pl: 'Lista Kar' }) + .setDefaultMemberPermissions(PermissionFlagsBits.ViewAuditLog) .setDMPermission(false) .setType(ApplicationCommandType.User); diff --git a/src/events/messageCreate.ts b/src/events/messageCreate.ts index 20668846..02e99168 100644 --- a/src/events/messageCreate.ts +++ b/src/events/messageCreate.ts @@ -1,6 +1,6 @@ import FluorineClient from '@classes/Client'; import Embed from '@classes/Embed'; -import { Message } from 'discord.js'; +import { Message, MessageActionRow, MessageButton } from 'discord.js'; import { Config } from 'types/databaseTables'; export async function run(client: FluorineClient, message: Message) { @@ -67,9 +67,19 @@ export async function run(client: FluorineClient, message: Message) { if (random === 1) { const removalTimestamp = 1656676800; - message.channel.send( - `<:SlashCommands:934768130474004500> Use Slash Commands!\nPrefix commands are not supported and will be removed ! ()` - ); + await client.application.fetch(); + message.channel.send({ + content: `<:SlashCommands:934768130474004500> **Use Slash Commands!**\nPrefix (message) commands are not supported and will be removed ! ()\nIf you can't see Slash Commands, make sure to reinvite the bot`, + components: [ + new MessageActionRow().addComponents([ + new MessageButton() + .setLabel('Bot Invite') + .setStyle('LINK') + .setURL(client.generateInvite(client.application.installParams)), + new MessageButton().setLabel('Support Server').setStyle('LINK').setURL(client.support) + ]) + ] + }); } const code = client.cmds.get(command); diff --git a/src/events/ready.ts b/src/events/ready.ts index 71bfd066..411d45fd 100644 --- a/src/events/ready.ts +++ b/src/events/ready.ts @@ -1,8 +1,23 @@ import FluorineClient from '@classes/Client'; +import { Routes } from 'discord-api-types/v10'; import { performance } from 'perf_hooks'; import { Config } from 'types/databaseTables'; export async function run(client: FluorineClient) { + const devGuild = client.guilds.cache.get(process.env.DISCORD_DEV_GUILD); + const commands = await devGuild.commands.fetch(); + + if (!commands.some(c => c.name === 'deploy')) { + const route = Routes.applicationGuildCommands(client.user.id, process.env.DISCORD_DEV_GUILD); + const command = client.applicationCommands.chatInput.get('deploy'); + + await client.restModule.post(route, { + body: command.data.toJSON() + }); + + client.logger.log(`Enabled deploy commands for guild ID ${process.env.DISCORD_DEV_GUILD}.`); + } + client.guilds.cache.forEach(async g => { const guild = ( await client.db.query('SELECT logs_enabled FROM config WHERE guild_id = $1', [BigInt(g.id)])