Skip to content

Commit

Permalink
🤔 Updated Events to no longer take any
Browse files Browse the repository at this point in the history
  • Loading branch information
wiki-Bird committed Aug 15, 2023
1 parent 098d07f commit 420b1e1
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 20 deletions.
4 changes: 3 additions & 1 deletion src/events/buttonInteraction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ButtonInteraction } from 'discord.js';
import Event from '../types/Event';


const buttonInteraction: Event = {
// const buttonInteraction: Event = {
const buttonInteraction: Event<[ButtonInteraction]> = {
name: 'buttonInteraction',
execute: function (){
console.log("Button interaction event fired.");
Expand Down
7 changes: 4 additions & 3 deletions src/events/guildBanAdd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { MessageEmbed, TextChannel, GuildBan } from 'discord.js';
import Event from '../types/Event';
import { ref } from '..';

const guildBanAdd: Event = {
// const guildBanAdd: Event = {
const guildBanAdd: Event<[GuildBan]> = {
name: 'guildBanAdd',
execute: async function (ban: GuildBan) {
let channelToSend;
Expand All @@ -21,10 +22,10 @@ const guildBanAdd: Event = {

if (!latestBan) return console.log(`${ban.user.tag} was banned from ${ban.guild.name} but no audit log could be found.`);

const { executor, target, reason } = latestBan;
const { executor, reason } = latestBan;


if (reason !== null || reason !== undefined) {
if (reason !== null && reason !== undefined) {
reasonGiven = reason!;
}

Expand Down
4 changes: 3 additions & 1 deletion src/events/guildCreate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Guild } from 'discord.js';
import Event from '../types/Event';

const guildCreate: Event = {
// const guildCreate: Event = {
const guildCreate: Event<[Guild]> = {
name: 'guildCreate',
execute: function () {
console.log("Joined a new server");
Expand Down
7 changes: 4 additions & 3 deletions src/events/guildDelete.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Interaction } from 'discord.js';
import { Guild } from 'discord.js';
import Event from '../types/Event';

const guildDelete: Event = {
// const guildDelete: Event = {
const guildDelete: Event<[Guild]> = {
name: 'guildDelete',
execute: function(interaction: Interaction) {
execute: function() {
console.log("Left a server");

}
Expand Down
7 changes: 4 additions & 3 deletions src/events/guildMemberRemove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { MessageEmbed, TextChannel, GuildMember } from 'discord.js';
import Event from '../types/Event';
import { ref } from '..';

const guildMemberRemove: Event = {
// const guildMemberRemove: Event = {
const guildMemberRemove: Event<[GuildMember]> = {
name: 'guildMemberRemove',
execute: async function(member: GuildMember) {
const guild = member.guild;
Expand Down Expand Up @@ -47,9 +48,9 @@ const guildMemberRemove: Event = {

if (kickLog.target!.id === member.id && kickLog.createdAt > member.joinedAt!) {

const { executor, target, reason } = kickLog;
const { executor, reason } = kickLog;
let reasonGiven = "No reason given.";
if (reason !== null || reason !== undefined) {
if (reason !== null && reason !== undefined) {
reasonGiven = reason!;
}

Expand Down
3 changes: 2 additions & 1 deletion src/events/interactionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { client } from '..';
import { Interaction } from 'discord.js';
import Event from '../types/Event';

const interactionCreate: Event = {
// const interactionCreate: Event = {
const interactionCreate: Event<[Interaction]> = {
name: 'interactionCreate',
execute: function (interaction: Interaction) {
if (!interaction.isCommand() || !interaction.inGuild()) return;
Expand Down
3 changes: 2 additions & 1 deletion src/events/messageCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { ref } from '..';
import muteUser from '../functions/muteUser';
import MemberServerPair from '../types/MemberServerPair';

const messageCreate: Event = {
// const messageCreate: Event = {
const messageCreate: Event<[Message]> = {
name: 'messageCreate',
execute: async function (message: Message) {

Expand Down
3 changes: 2 additions & 1 deletion src/events/ready.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Event from '../types/Event';
import OtterClient from '../types/OtterClient';

const ready: Event = {
//const ready: Event = {
const ready: Event<[OtterClient]> = {
name: 'ready',
once: true,
execute: function (client: OtterClient) {
Expand Down
5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ const database = getDatabase(app);
export const ref = database.ref("restricted_access/secret_document");

// As an admin, the app has access to read and write all data, regardless of Security Rules
ref.once("value", function(snapshot) {
// console.log(snapshot.val());
console.log("Database loaded");
ref.once("value", function() {
console.log("Connected to Firebase Database");
});


Expand Down
13 changes: 10 additions & 3 deletions src/types/Event.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
export default interface Event {
// export default interface Event {
// name: string;
// once?: boolean;
// execute: (...args: any[]) => any;
// }


export default interface Event<T extends unknown[]> {
name: string;
once?: boolean;
execute: (...args: any[]) => any;
}
execute: (...args: T) => void; // Adjust the return type if needed.
}

0 comments on commit 420b1e1

Please sign in to comment.