generated from nhcarrigan/template
feat: migrate from github
This commit is contained in:
30
src/interfaces/Action.ts
Normal file
30
src/interfaces/Action.ts
Normal file
@ -0,0 +1,30 @@
|
||||
type PastAction =
|
||||
| "warned"
|
||||
| "kicked"
|
||||
| "banned"
|
||||
| "muted"
|
||||
| "unmuted"
|
||||
| "unbanned"
|
||||
| "noted"
|
||||
| "softbanned";
|
||||
|
||||
export type Action =
|
||||
| "warn"
|
||||
| "kick"
|
||||
| "ban"
|
||||
| "mute"
|
||||
| "unmute"
|
||||
| "unban"
|
||||
| "note"
|
||||
| "softban";
|
||||
|
||||
export const ActionToPastTense: { [key in Action]: PastAction } = {
|
||||
warn: "warned",
|
||||
kick: "kicked",
|
||||
ban: "banned",
|
||||
mute: "muted",
|
||||
unmute: "unmuted",
|
||||
unban: "unbanned",
|
||||
note: "noted",
|
||||
softban: "softbanned"
|
||||
};
|
11
src/interfaces/ActionPayload.ts
Normal file
11
src/interfaces/ActionPayload.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { Action } from "./Action";
|
||||
|
||||
export interface ActionPayload {
|
||||
userId: string;
|
||||
serverId: string;
|
||||
action: Action;
|
||||
reason: string;
|
||||
moderator: string;
|
||||
duration?: number;
|
||||
pruneDays?: number | undefined;
|
||||
}
|
19
src/interfaces/Command.ts
Normal file
19
src/interfaces/Command.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import {
|
||||
SlashCommandBuilder,
|
||||
SlashCommandOptionsOnlyBuilder,
|
||||
SlashCommandSubcommandsOnlyBuilder
|
||||
} from "discord.js";
|
||||
|
||||
import { ExtendedClient } from "./ExtendedClient";
|
||||
import { GuildCommandInteraction } from "./Interactions";
|
||||
|
||||
export interface Command {
|
||||
data:
|
||||
| SlashCommandOptionsOnlyBuilder
|
||||
| Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup">
|
||||
| SlashCommandSubcommandsOnlyBuilder;
|
||||
run: (
|
||||
bot: ExtendedClient,
|
||||
interaction: GuildCommandInteraction
|
||||
) => Promise<void>;
|
||||
}
|
8
src/interfaces/CommandHandler.ts
Normal file
8
src/interfaces/CommandHandler.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { ExtendedClient } from "./ExtendedClient";
|
||||
import { GuildCommandInteraction } from "./Interactions";
|
||||
|
||||
export type CommandHandler = (
|
||||
bot: ExtendedClient,
|
||||
interaction: GuildCommandInteraction,
|
||||
config: ExtendedClient["configs"][""]
|
||||
) => Promise<void>;
|
13
src/interfaces/Context.ts
Normal file
13
src/interfaces/Context.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { ExtendedClient } from "./ExtendedClient";
|
||||
import { GuildContextInteraction } from "./Interactions";
|
||||
|
||||
export interface Context {
|
||||
data: {
|
||||
name: string;
|
||||
type: 2 | 3;
|
||||
};
|
||||
run: (
|
||||
bot: ExtendedClient,
|
||||
interaction: GuildContextInteraction
|
||||
) => Promise<void>;
|
||||
}
|
18
src/interfaces/ExtendedClient.ts
Normal file
18
src/interfaces/ExtendedClient.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { PrismaClient, configs } from "@prisma/client";
|
||||
import { Client, WebhookClient } from "discord.js";
|
||||
|
||||
import { Command } from "./Command";
|
||||
import { Context } from "./Context";
|
||||
|
||||
export interface ExtendedClient extends Client {
|
||||
env: {
|
||||
token: string;
|
||||
debugHook: WebhookClient;
|
||||
mongoUri: string;
|
||||
devMode: boolean;
|
||||
};
|
||||
db: PrismaClient;
|
||||
commands: Command[];
|
||||
contexts: Context[];
|
||||
configs: { [serverId: string]: Omit<configs, "id"> };
|
||||
}
|
190
src/interfaces/GitHubPayloads.ts
Normal file
190
src/interfaces/GitHubPayloads.ts
Normal file
@ -0,0 +1,190 @@
|
||||
/**
|
||||
* The structure of the NESTED issue data from the GitHub Webhook.
|
||||
*/
|
||||
interface GithubIssuePayload {
|
||||
id: number;
|
||||
node_id: string;
|
||||
url: string;
|
||||
repository_url: string;
|
||||
html_url: string;
|
||||
number: number;
|
||||
state: string;
|
||||
state_reason: string | null;
|
||||
title: string;
|
||||
body: string;
|
||||
user: GithubUserPayload;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
closed_by: GithubUserPayload;
|
||||
}
|
||||
|
||||
interface GithubPullRequestPayload {
|
||||
html_url: string;
|
||||
body: string;
|
||||
number: number;
|
||||
merged: boolean;
|
||||
title: string;
|
||||
user: GithubUserPayload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Structure of the repo data, sent on pretty much
|
||||
* every GitHub Webhook payload.
|
||||
*/
|
||||
interface GithubRepoPayload {
|
||||
id: number;
|
||||
node_id: string;
|
||||
name: string;
|
||||
full_name: string;
|
||||
owner: GithubUserPayload;
|
||||
private: boolean;
|
||||
html_url: string;
|
||||
description: string;
|
||||
fork: boolean;
|
||||
url: string;
|
||||
archive_url: string;
|
||||
assignees_url: string;
|
||||
blobs_url: string;
|
||||
branches_url: string;
|
||||
collaborators_url: string;
|
||||
comments_url: string;
|
||||
commits_url: string;
|
||||
compare_url: string;
|
||||
contents_url: string;
|
||||
contributors_url: string;
|
||||
deployments_url: string;
|
||||
downloads_url: string;
|
||||
events_url: string;
|
||||
forks_url: string;
|
||||
git_commits_url: string;
|
||||
git_refs_url: string;
|
||||
git_tags_url: string;
|
||||
git_url: string;
|
||||
issue_comment_url: string;
|
||||
issue_events_url: string;
|
||||
issues_url: string;
|
||||
keys_url: string;
|
||||
labels_url: string;
|
||||
languages_url: string;
|
||||
merges_url: string;
|
||||
milestones_url: string;
|
||||
notifications_url: string;
|
||||
pulls_url: string;
|
||||
releases_url: string;
|
||||
ssh_url: string;
|
||||
stargazers_url: string;
|
||||
statuses_url: string;
|
||||
subscribers_url: string;
|
||||
subscription_url: string;
|
||||
tags_url: string;
|
||||
teams_url: string;
|
||||
trees_url: string;
|
||||
clone_url: string;
|
||||
mirror_url: string;
|
||||
hooks_url: string;
|
||||
svn_url: string;
|
||||
homepage: string;
|
||||
language: string | null;
|
||||
forks: number;
|
||||
forks_count: number;
|
||||
stargazers_count: number;
|
||||
watchers_count: number;
|
||||
watchers: number;
|
||||
size: number;
|
||||
default_branch: string;
|
||||
open_issues_count: number;
|
||||
open_issues: number;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
interface GithubUserPayload {
|
||||
login: string;
|
||||
id: number;
|
||||
node_id: string;
|
||||
avatar_url: string;
|
||||
gravatar_id: string;
|
||||
url: string;
|
||||
html_url: string;
|
||||
followers_url: string;
|
||||
following_url: string;
|
||||
gists_url: string;
|
||||
starred_url: string;
|
||||
subscriptions_url: string;
|
||||
organizations_url: string;
|
||||
repos_url: string;
|
||||
events_url: string;
|
||||
received_events_url: string;
|
||||
type: string;
|
||||
site_admin: boolean;
|
||||
name: string;
|
||||
company: string;
|
||||
blog: string;
|
||||
location: string;
|
||||
email: string;
|
||||
hireable: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The structure of the comment data from the Github Webhook.
|
||||
*/
|
||||
export interface GithubCommentPayload {
|
||||
action: string;
|
||||
issue: GithubIssuePayload;
|
||||
comment: {
|
||||
html_url: string;
|
||||
body: string;
|
||||
user: GithubUserPayload;
|
||||
};
|
||||
repository: GithubRepoPayload;
|
||||
sender: GithubUserPayload;
|
||||
}
|
||||
|
||||
export interface GithubForkPayload {
|
||||
forkee: GithubRepoPayload;
|
||||
repository: GithubRepoPayload;
|
||||
sender: GithubUserPayload;
|
||||
}
|
||||
|
||||
/**
|
||||
* The structure of the top level issue data from the GitHub webhook.
|
||||
*/
|
||||
export interface GithubIssuesPayload {
|
||||
action: string;
|
||||
issue: GithubIssuePayload;
|
||||
repository: GithubRepoPayload;
|
||||
sender: GithubUserPayload;
|
||||
}
|
||||
|
||||
/**
|
||||
* The structure of the ping payload when a new GitHub webhook
|
||||
* is initialised.
|
||||
*/
|
||||
export interface GithubPingPayload {
|
||||
zen: string;
|
||||
hook_id: string;
|
||||
hook: Record<string, unknown>;
|
||||
repository: GithubRepoPayload;
|
||||
organization: Record<string, unknown>;
|
||||
sender: GithubUserPayload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Structure of the pull request data from the GitHub Webhook.
|
||||
*/
|
||||
export interface GithubPullPayload {
|
||||
action: string;
|
||||
number: number;
|
||||
pull_request: GithubPullRequestPayload;
|
||||
repository: GithubRepoPayload;
|
||||
sender: GithubUserPayload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Structure of the star data sent from the GitHub Webhook.
|
||||
*/
|
||||
export interface GithubStarPayload {
|
||||
action: "created" | "deleted";
|
||||
starred_at: string;
|
||||
repository: GithubRepoPayload;
|
||||
sender: GithubUserPayload;
|
||||
}
|
15
src/interfaces/Interactions.ts
Normal file
15
src/interfaces/Interactions.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import {
|
||||
ChatInputCommandInteraction,
|
||||
ContextMenuCommandInteraction,
|
||||
Guild,
|
||||
GuildMember
|
||||
} from "discord.js";
|
||||
|
||||
export interface GuildCommandInteraction extends ChatInputCommandInteraction {
|
||||
guild: Guild;
|
||||
member: GuildMember;
|
||||
}
|
||||
|
||||
export interface GuildContextInteraction extends ContextMenuCommandInteraction {
|
||||
guild: Guild;
|
||||
}
|
Reference in New Issue
Block a user