-
-
Notifications
You must be signed in to change notification settings - Fork 245
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 #973 from TheBastionBot/dev
v10.2
- Loading branch information
Showing
18 changed files
with
391 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
# EXPERIMENTAL. DO NOT USE THIS! | ||
# This will change in upcoming versions. | ||
|
||
TESSERACT_OWNER_ID= | ||
TESSERACT_BOT_ID= | ||
TESSERACT_BOT_TOKEN= | ||
TESSERACT_OWNER_ID= | ||
TESSERACT_MONGO_URI= | ||
TESSERACT_UNSAFE_MODE=FALSE | ||
|
||
BASTION_MUSIC_ACTIVITY=TRUE | ||
BASTION_SAFE_MODE=TRUE | ||
BASTION_RELAY_DMS=FALSE | ||
BASTION_API_PORT=8377 |
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
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
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,104 @@ | ||
/*! | ||
* @author TRACTION (iamtraction) | ||
* @copyright 2022 | ||
*/ | ||
import { ApplicationCommandOptionType, ChatInputCommandInteraction, PermissionFlagsBits } from "discord.js"; | ||
import { Command, Logger } from "@bastion/tesseract"; | ||
|
||
import GuildModel from "../../models/Guild"; | ||
import MemberModel from "../../models/Member"; | ||
import { COLORS } from "../../utils/constants"; | ||
|
||
class UserInfractionsCommand extends Command { | ||
constructor() { | ||
super({ | ||
name: "infractions", | ||
description: "Configure infraction actions and displays infractions of the specified user.", | ||
options: [ | ||
{ | ||
type: ApplicationCommandOptionType.Integer, | ||
name: "timeout", | ||
description: "Number of violations after which the user is timed out.", | ||
min_value: 1, | ||
}, | ||
{ | ||
type: ApplicationCommandOptionType.Integer, | ||
name: "kick", | ||
description: "Number of violations after which the user is kicked.", | ||
min_value: 1, | ||
}, | ||
{ | ||
type: ApplicationCommandOptionType.Integer, | ||
name: "ban", | ||
description: "Number of violations after which the user is banned.", | ||
min_value: 1, | ||
}, | ||
{ | ||
type: ApplicationCommandOptionType.User, | ||
name: "user", | ||
description: "The user whose infractions you want to display.", | ||
}, | ||
], | ||
userPermissions: [ PermissionFlagsBits.ModerateMembers ], | ||
}); | ||
} | ||
|
||
public async exec(interaction: ChatInputCommandInteraction<"cached">): Promise<unknown> { | ||
await interaction.deferReply(); | ||
const timeoutThreshold = interaction.options.getInteger("timeout"); | ||
const kickThreshold = interaction.options.getInteger("kick"); | ||
const banThreshold = interaction.options.getInteger("ban"); | ||
const user = interaction.options.getUser("user"); | ||
|
||
if (user) { | ||
// get member | ||
const member = user ? await interaction.guild.members.fetch(user).catch(Logger.ignore) : undefined; | ||
const memberDocument = await MemberModel.findOne({ user: user.id, guild: interaction.guildId }); | ||
|
||
if (memberDocument?.infractions?.length) { | ||
return await interaction.editReply({ | ||
embeds: [ | ||
{ | ||
color: COLORS.PRIMARY, | ||
author: { | ||
name: user.tag + (member && member.nickname ? " / " + member.nickname : ""), | ||
}, | ||
title: "Infractions", | ||
fields: memberDocument.infractions.map((infraction, i) => ({ | ||
name: `#${ i + 1 }`, | ||
value: infraction, | ||
})), | ||
footer: { | ||
text: user.id, | ||
}, | ||
}, | ||
], | ||
}); | ||
} | ||
|
||
return await interaction.editReply({ | ||
content: `${ user } has no active infractions.`, | ||
allowedMentions: { | ||
users: [], | ||
}, | ||
}); | ||
} | ||
|
||
// get guild document | ||
const guildDocument = await GuildModel.findById(interaction.guildId); | ||
|
||
if (interaction.channel.permissionsFor(interaction.member)?.has(PermissionFlagsBits.ManageGuild)) { | ||
guildDocument.infractionsTimeoutThreshold = timeoutThreshold; | ||
guildDocument.infractionsKickThreshold = kickThreshold; | ||
guildDocument.infractionsBanThreshold = banThreshold; | ||
|
||
await guildDocument.save(); | ||
|
||
return await interaction.editReply(`**Timeout**, **Kick** and **Ban** thresholds have been set to **${ timeoutThreshold || 0 }**, **${ kickThreshold || 0 }** and **${ banThreshold || 0 }** warnings, respectively.`); | ||
} | ||
|
||
return await interaction.editReply(`**Timeout**, **Kick** and **Ban** thresholds are set to **${ guildDocument.infractionsTimeoutThreshold || 0 }**, **${ guildDocument.infractionsKickThreshold || 0 }** and **${ guildDocument.infractionsBanThreshold || 0 }** warnings, respectively.`); | ||
} | ||
} | ||
|
||
export = UserInfractionsCommand; |
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,41 @@ | ||
/*! | ||
* @author TRACTION (iamtraction) | ||
* @copyright 2022 | ||
*/ | ||
import { ButtonInteraction, ComponentType, TextInputStyle } from "discord.js"; | ||
import { MessageComponent } from "@bastion/tesseract"; | ||
|
||
import MessageComponents from "../utils/components"; | ||
|
||
class VerificationButton extends MessageComponent { | ||
constructor() { | ||
super({ | ||
id: MessageComponents.VerificationButton, | ||
scope: "guild", | ||
}); | ||
} | ||
|
||
public async exec(interaction: ButtonInteraction<"cached">): Promise<unknown> { | ||
return interaction.showModal({ | ||
custom_id: MessageComponents.VerificationModal, | ||
title: "Are you a human?", | ||
components: [ | ||
{ | ||
type: ComponentType.ActionRow, | ||
components: [ | ||
{ | ||
custom_id: MessageComponents.VerificationTextInput, | ||
type: ComponentType.TextInput, | ||
label: "Type \"i am human\" to verify yourself.", | ||
placeholder: "i am human", | ||
required: true, | ||
style: TextInputStyle.Short, | ||
}, | ||
], | ||
}, | ||
], | ||
}); | ||
} | ||
} | ||
|
||
export = VerificationButton; |
Oops, something went wrong.