Skip to content

Commit

Permalink
misc fixes, mainly just adding logging
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Dec 28, 2023
1 parent 3c6d792 commit 7c5edf1
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ SERVER_ID=
SAY_LOGS_CHANNEL=
LOGS_CHANNEL=
SIMULATED_BAN_SHARE_LOGS_CHANNEL=
BAN_LOGS_CHANNEL=

# These arent needed outside of production
MAVEN_REPO=
Expand Down
2 changes: 1 addition & 1 deletion src/logIssueAnalyzers/optifine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const optifineAnalyzer: Analyzer = async (log) => {
if (matchesOptifine?.[1] == 'true') {
return {
name: 'Optifine Warning Disabled',
value: 'You appeared to have disabled the Optifine warning. Many issues you might encounter are caused by Optifine. You will most likely get any support due to this.',
value: 'You appeared to have disabled the Optifine warning. Many issues you might encounter are caused by Optifine. You will not get any support due to this.',
};
} else {
return {
Expand Down
1 change: 1 addition & 0 deletions src/types/environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ declare global {
SERVER_ID: string;
SAY_LOGS_CHANNEL: string;
LOGS_CHANNEL: string;
BAN_LOGS_CHANNEL: string;
MAVEN_REPO: string;
GITHUB_STATUS_CHANNEL: string;
GITHUB_SECRET: string;
Expand Down
51 changes: 45 additions & 6 deletions src/webserver/banshare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const banButton = new Button(
'ban',
async (interaction, data:{userId:string}) => {
const reason =
'aero banshare: ' +
'simulated banshare: ' +
(interaction.message.embeds[0].fields[3].value ??
'no reason provided');
const modal = new ModalBuilder()
Expand All @@ -30,20 +30,58 @@ const banButton = new Button(
.setValue(reason)
)
);
interaction.showModal(modal);
await interaction.showModal(modal);
interaction
.awaitModalSubmit({
filter: (interaction) =>
interaction.customId == modal.data.custom_id,
time: 300_000,
})
.then((modalResponse) => {
.then(async (modalResponse) => {
interaction.guild?.bans.create(data.userId, {
reason: modalResponse.components[0].components[0].value,
});
interaction.reply(
`<@${data.userId}> (\`${data.userId}\`) was banned.`
);
await interaction.reply({
content: `<@${data.userId}> (\`${data.userId}\`) was banned.`,
ephemeral: true,
});
await interaction.update({
components: [
new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setLabel('ban')
.setStyle(ButtonStyle.Danger)
.setDisabled(true)
),
],
});
if (interaction.guild != null) {
const channel = await interaction.guild.channels.fetch(
process.env.BAN_LOGS_CHANNEL
);
if (channel?.isTextBased()) {
channel.send({
embeds: [
new EmbedBuilder()
.setTitle('User Banned via Banshare')
.setDescription(
`<@!${data.userId}> was banned!`
)
.setFields([
{
name: 'Reason',
value: modalResponse.components[0]
.components[0].value,
},
{
name: 'By',
value: interaction.user.username,
},
]),
],
});
}
}
});
}
);
Expand Down Expand Up @@ -85,6 +123,7 @@ const handleBan = async (client: Client, req: Request) => {
const embed = new EmbedBuilder()
.setTitle(`Incoming ban from ${server}`)
.addFields(
{ name: 'User', value: `<@!${user.id}>` },
{ name: 'Username', value: user.username },
{ name: 'User ID', value: user.id },
{ name: 'Present in server', value: `${present}` },
Expand Down

0 comments on commit 7c5edf1

Please sign in to comment.