Add notice channel sending functionality
All checks were successful
Test / build (push) Successful in 12s
All checks were successful
Test / build (push) Successful in 12s
This commit is contained in:
parent
afafe246a8
commit
40a9764192
3 changed files with 64 additions and 2 deletions
|
@ -65,7 +65,7 @@ export class CoreClient extends Client {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log("Data Source Initialized");
|
console.log("Data Source Initialized");
|
||||||
|
|
||||||
this._timerHelper.AddTimer("*/5 * * * *", "Europe/London", AutoKick, true);
|
this._timerHelper.AddTimer("0 * * * *", "Europe/London", AutoKick, true);
|
||||||
|
|
||||||
this._timerHelper.StartAllTimers();
|
this._timerHelper.StartAllTimers();
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
export default class EmbedColours {
|
export default class EmbedColours {
|
||||||
public static readonly Ok = 0x3050ba;
|
public static readonly Ok = 0x3050ba;
|
||||||
|
public static readonly Warning = 0xffbf00;
|
||||||
|
public static readonly Danger = 0xd2042d;
|
||||||
}
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
|
import { EmbedBuilder } from "discord.js";
|
||||||
import {CoreClient} from "../client/client";
|
import {CoreClient} from "../client/client";
|
||||||
import AutoKickConfig from "../database/entities/AutoKickConfig";
|
import AutoKickConfig from "../database/entities/AutoKickConfig";
|
||||||
|
import EmbedColours from "../constants/EmbedColours";
|
||||||
|
|
||||||
export default async function AutoKick() {
|
export default async function AutoKick() {
|
||||||
const client = CoreClient.baseClient;
|
const client = CoreClient.baseClient;
|
||||||
|
@ -31,7 +33,65 @@ export default async function AutoKick() {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
if (whenToKick < now) {
|
if (whenToKick < now) {
|
||||||
await member.kick("Auto Kicked");
|
// await member.kick("Auto Kicked");
|
||||||
|
console.log("Kicked");
|
||||||
|
|
||||||
|
if (config.NoticeChannelId) {
|
||||||
|
const channel = guild.channels.cache.find(x => x.id == config.NoticeChannelId) || await guild.channels.fetch(config.NoticeChannelId);
|
||||||
|
|
||||||
|
if (!channel?.isSendable()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setTitle("Auto Kicked User")
|
||||||
|
.setColor(EmbedColours.Danger)
|
||||||
|
.setThumbnail(member.avatarURL())
|
||||||
|
.addFields([
|
||||||
|
{
|
||||||
|
name: "User",
|
||||||
|
value: `<@${member.user.id}> \`${member.user.username}\``,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
await channel.send({
|
||||||
|
embeds: [ embed ],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (config.NoticeChannelId && config.NoticeTime) {
|
||||||
|
const whenToNotice = new Date(whenToKick.getMilliseconds() - config.NoticeTime);
|
||||||
|
|
||||||
|
const channel = guild.channels.cache.find(x => x.id == config.NoticeChannelId) || await guild.channels.fetch(config.NoticeChannelId);
|
||||||
|
|
||||||
|
if (!channel?.isSendable()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (now.getMonth() == whenToNotice.getMonth()
|
||||||
|
&& now.getDate() == whenToNotice.getDate()
|
||||||
|
&& now.getHours() == whenToNotice.getHours()) {
|
||||||
|
const embed = new EmbedBuilder()
|
||||||
|
.setTitle("Auto Kick Notice")
|
||||||
|
.setColor(EmbedColours.Warning)
|
||||||
|
.setThumbnail(member.avatarURL())
|
||||||
|
.addFields([
|
||||||
|
{
|
||||||
|
name: "User",
|
||||||
|
value: `<@${member.user.id}> \`${member.user.username}\``,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "When To Kick",
|
||||||
|
value: `<t:${whenToKick.getMilliseconds()}:R>`,
|
||||||
|
inline: true,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
await channel.send({
|
||||||
|
embeds: [ embed ],
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue