Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Commit

Permalink
final cleanup (#195)
Browse files Browse the repository at this point in the history
* final cleanup

* add bot invite to warning message

* suggested changes

Co-authored-by: Splatterxl <[email protected]>

Co-authored-by: Splatterxl <[email protected]>
  • Loading branch information
SuperchupuDev and splatterxl authored May 15, 2022
1 parent 107b675 commit 8c73ed8
Show file tree
Hide file tree
Showing 15 changed files with 238 additions and 36 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
DISCORD_TOKEN=
DISCORD_DEV_GUILD=
DISCORD_SUPPORT_INVITE=
DISCORD_PREFIX=

PGHOST=
Expand All @@ -13,3 +15,5 @@ AI_TOKEN=
AI_URL=

NODE_ENV=

DATABASE_URL=
132 changes: 132 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 0 additions & 10 deletions CONTRIBUTING.md

This file was deleted.

2 changes: 2 additions & 0 deletions i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down
2 changes: 2 additions & 0 deletions i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down
6 changes: 5 additions & 1 deletion src/classes/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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' }]
}
});
}

Expand Down
4 changes: 4 additions & 0 deletions src/classes/modules/CasesModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions src/commands/case/index.ts
Original file line number Diff line number Diff line change
@@ -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';
14 changes: 4 additions & 10 deletions src/commands/list-cases.ts → src/commands/case/list.ts
Original file line number Diff line number Diff line change
@@ -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'>) {
Expand Down Expand Up @@ -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')
Expand All @@ -88,5 +84,3 @@ export const data = new SlashCommandBuilder()
.setDescriptionLocalizations({ pl: 'Użytkownik, którego chcesz sprawdzić' })
.setRequired(true)
);

export const category: Category = 'tools';
14 changes: 4 additions & 10 deletions src/commands/case.ts → src/commands/case/view.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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')
Expand All @@ -51,5 +47,3 @@ export const data = new SlashCommandBuilder()
.setMinValue(1)
.setRequired(true)
);

export const category: Category = 'moderation';
20 changes: 20 additions & 0 deletions src/commands/support.ts
Original file line number Diff line number Diff line change
@@ -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';
3 changes: 2 additions & 1 deletion src/context/listcase.ts → src/context/list-cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'>) {
Expand Down Expand Up @@ -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);
18 changes: 14 additions & 4 deletions src/events/messageCreate.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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 <t:${removalTimestamp}:R>! (<t:${removalTimestamp}:D>)`
);
await client.application.fetch();
message.channel.send({
content: `<:SlashCommands:934768130474004500> **Use Slash Commands!**\nPrefix (message) commands are not supported and will be removed <t:${removalTimestamp}:R>! (<t:${removalTimestamp}:D>)\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);
Expand Down
15 changes: 15 additions & 0 deletions src/events/ready.ts
Original file line number Diff line number Diff line change
@@ -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<Config>('SELECT logs_enabled FROM config WHERE guild_id = $1', [BigInt(g.id)])
Expand Down

0 comments on commit 8c73ed8

Please sign in to comment.