-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.ts
More file actions
47 lines (42 loc) · 1.3 KB
/
mod.ts
File metadata and controls
47 lines (42 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { CommandHandler, updateMessage } from "$xor";
const kv = (key: string, value: string) =>
`<b>${key} :</b> <code>${value}</code>\n`;
export default {
name: "github",
handlers: [
new CommandHandler(
"github",
async ({ client, event, args }) => {
const user = args[0];
if (!user) {
await updateMessage(event, "Username wasn't provided");
return;
}
event.message.delete({ revoke: true });
const res = await fetch(`https://api.github.com/users/${user}`);
if (res.status === 404 || !res.ok) {
await updateMessage(event, "No user found with username - " + user);
}
const data = await res.json();
await client.sendFile(event.chatId!, {
file: data.avatar_url,
caption: kv("Username", data.login) +
kv("Name", data.name) +
kv("Bio", data.bio) +
kv("Location", data.location) +
kv("Public Repos", data.public_repos) +
kv("Followers", data.followers) +
kv("Following", data.following),
forceDocument: true,
thumb: data.avatar_url,
parseMode: "html",
});
},
),
],
help: `
**Introduction**
Fetch GitHub user information
**Commands**
- github <username>`,
};