add cv2 abstractions
This commit is contained in:
parent
f50d6ae45f
commit
281b5db156
1 changed files with 68 additions and 0 deletions
68
src/cv2.ts
Normal file
68
src/cv2.ts
Normal file
|
@ -0,0 +1,68 @@
|
|||
import {
|
||||
AnyMessageComponent,
|
||||
Component,
|
||||
ComponentTypes,
|
||||
FileComponent,
|
||||
MediaGalleryComponent,
|
||||
MessageActionRow,
|
||||
SectionComponent,
|
||||
SeparatorComponent,
|
||||
TextDisplayComponent
|
||||
} from "oceanic.js";
|
||||
import { client } from ".";
|
||||
|
||||
export const Divider: SeparatorComponent = {
|
||||
type: ComponentTypes.SEPARATOR,
|
||||
divider: true
|
||||
};
|
||||
export const Header = (
|
||||
title: string,
|
||||
level: 1 | 2 | 3
|
||||
): TextDisplayComponent => {
|
||||
return {
|
||||
type: ComponentTypes.TEXT_DISPLAY,
|
||||
content: `${"#".repeat(level)} ${title}`
|
||||
};
|
||||
};
|
||||
|
||||
export async function generateUserComponent(
|
||||
id: string
|
||||
): Promise<SectionComponent> {
|
||||
const user = await client.rest.users.get(id);
|
||||
return {
|
||||
type: ComponentTypes.SECTION,
|
||||
components: [
|
||||
Header("User", 3),
|
||||
{
|
||||
type: ComponentTypes.TEXT_DISPLAY,
|
||||
content: `${user.globalName || user.username}\n-# @${
|
||||
user.username
|
||||
}`
|
||||
}
|
||||
],
|
||||
accessory: {
|
||||
type: ComponentTypes.THUMBNAIL,
|
||||
media: {
|
||||
url: user.avatarURL("png", 128)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
export function generateList(
|
||||
elements: {
|
||||
[key: string]: string;
|
||||
},
|
||||
title?: string
|
||||
): TextDisplayComponent[] {
|
||||
let working: TextDisplayComponent[] = [];
|
||||
|
||||
if (title) working.push(Header(title, 3));
|
||||
for (const key of Object.keys(elements)) {
|
||||
working.push({
|
||||
type: ComponentTypes.TEXT_DISPLAY,
|
||||
content: `**${key}**\n-# ${elements[key].replaceAll("\n", "\n-# ")}`
|
||||
});
|
||||
}
|
||||
|
||||
return working;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue