Skip to content

Commit 93b5b06

Browse files
committed
⚗️ chore: sorry but seriously i forgor what i was doing
1 parent 1b7bde4 commit 93b5b06

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1084
-845
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![banner](https://cdn.discordapp.com/attachments/783319033730564098/783399012547035176/HarmonyBanner.png)
1+
![banner](https://github.com/harmonyland/harmony/blob/main/assets/banner.png)
22

33
<p align="center"><i><b>An easy to use Discord API Library for Deno.</b></i></p>
44
<p align="center">

core/src/rest/http_client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,15 @@ export class HTTPClient implements HTTPClientOptions {
176176
}
177177
}
178178

179+
const query = new URLSearchParams(options?.query).toString();
180+
179181
const abortController = new AbortController();
180182
const timeoutID = setTimeout(() => {
181183
abortController.abort();
182184
}, this.timeout);
183185

184186
const res = await fetch(
185-
`${this.baseURL}/v${this.version}${endpoint}`,
187+
`${this.baseURL}/v${this.version}${endpoint}${query}`,
186188
{
187189
method,
188190
headers,

framework/src/cache/manager.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// deno-lint-ignore-file no-explicit-any
2+
import { Collection } from "./collection.ts";
3+
4+
export class CacheManager extends Collection<string, Collection<string, any>> {
5+
constructor() {
6+
super();
7+
}
8+
}

framework/src/managers/guildChannels.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class GuildChannelsManager
1717
constructor(client: Client, parent: ChannelsManager, guildID: string) {
1818
super(
1919
client,
20-
parent as unknown as BaseManager<GuildChannelPayload, GuildChannel>,
20+
parent as BaseManager<GuildChannelPayload, GuildChannel>,
2121
);
2222
this.guildID = guildID;
2323
}

framework/src/managers/guildMembers.ts

Whitespace-only changes.

framework/src/managers/messages.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import type {
2+
GetChannelMessagesParams,
3+
MessagePayload,
4+
} from "../../../types/mod.ts";
5+
import type { Client } from "../client/mod.ts";
6+
import { Message } from "../structures/messages/mod.ts";
7+
import { BaseManager } from "./base.ts";
8+
9+
export class MessagesManager extends BaseManager<MessagePayload, Message> {
10+
constructor(client: Client) {
11+
super(client);
12+
}
13+
14+
_fill(messages: MessagePayload[]) {
15+
for (const message of messages) {
16+
this.set(message.id!, message);
17+
}
18+
}
19+
20+
async _fetch(
21+
channelID: string,
22+
id: string,
23+
): Promise<MessagePayload | undefined> {
24+
try {
25+
const resp: MessagePayload | undefined = await this.client.rest.get(
26+
`/channels/${channelID}/messages/${id}`,
27+
);
28+
if (!resp) return;
29+
this.set(id, resp);
30+
return resp;
31+
} catch (_err) {
32+
return;
33+
}
34+
}
35+
async _fetchBulk(
36+
channelID: string,
37+
options: GetChannelMessagesParams,
38+
): Promise<MessagePayload[] | undefined> {
39+
try {
40+
const query: Record<string, string> = {
41+
...options,
42+
limit: "",
43+
};
44+
if (options.limit) {
45+
if (options.limit > 100 || options.limit < 1) {
46+
throw new Error("Limit must be in range 1-100");
47+
}
48+
query.limit = options.limit.toString();
49+
} else {
50+
delete query.limit;
51+
}
52+
const resp: MessagePayload[] | undefined = await this.client.rest.get(
53+
`/channels/${channelID}/messages`,
54+
{
55+
query,
56+
},
57+
);
58+
if (!resp) return;
59+
return resp.map((message) => {
60+
this.set(message.id!, message);
61+
return message;
62+
});
63+
} catch (_err) {
64+
return;
65+
}
66+
}
67+
68+
get(
69+
id: string,
70+
) {
71+
const cached = this._get(id);
72+
if (!cached) return;
73+
return new Message(this.client, cached);
74+
}
75+
async fetch(
76+
channelID: string,
77+
id: string,
78+
) {
79+
try {
80+
const payload = await this._fetch(channelID, id);
81+
if (!payload) return;
82+
return new Message(this.client, payload);
83+
} catch (_err) {
84+
return;
85+
}
86+
}
87+
}

framework/src/structures/channels/channel.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,4 @@ export class Channel {
1717
get type(): ChannelType {
1818
return this.payload.type;
1919
}
20-
21-
get flags(): number {
22-
return this.payload.flags;
23-
}
2420
}

framework/src/structures/channels/groupDMChannel.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export class GroupDMChannel extends DMBasedChannel {
1616
get icon(): string | null {
1717
return this.payload.icon;
1818
}
19+
get ownerID(): string {
20+
return this.payload.owner_id;
21+
}
1922
get owner(): User | undefined {
2023
return this.client.users.get(this.payload.owner_id);
2124
}

framework/src/structures/channels/guildChannel.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Channel } from "./channel.ts";
22
import type { GuildChannelPayload } from "../../../../types/mod.ts";
33
import type { Client } from "../../client/mod.ts";
4+
import { Guild } from "../guilds/guild.ts";
45

56
export class GuildChannel extends Channel {
67
payload: GuildChannelPayload;
@@ -12,6 +13,9 @@ export class GuildChannel extends Channel {
1213
get guildID(): string {
1314
return this.payload.guild_id;
1415
}
16+
get guild(): Guild | undefined {
17+
return this.client.guilds.get(this.payload.guild_id);
18+
}
1519
get name(): string {
1620
return this.payload.name;
1721
}
@@ -27,6 +31,9 @@ export class GuildChannel extends Channel {
2731
get parentID(): string | null {
2832
return this.payload.parent_id;
2933
}
34+
get parent(): GuildChannel | undefined {
35+
return this.client.channels.get(this.payload.parent_id!) as GuildChannel;
36+
}
3037
get topic(): string | null {
3138
return this.payload.topic;
3239
}

framework/src/structures/channels/guildForumChannel.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,7 @@ export class GuildForumChannel extends GuildForumChannelSuper {
7272
};
7373
});
7474
}
75+
get flags(): number {
76+
return this.payload.flags!;
77+
}
7578
}

0 commit comments

Comments
 (0)