Skip to content

Commit a450694

Browse files
committed
fix alot of bugs and add erlpack back
1 parent 9de01bf commit a450694

File tree

11 files changed

+301
-38
lines changed

11 files changed

+301
-38
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Secrets and logs
22
*.secret
3-
*.log
3+
# *.log
44

55
# Cache
66
.eslintcache

dist/lib/Client.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ class Client extends Emitter_1.default {
251251
ready();
252252
});
253253
this.event('MESSAGE_REACTION_ADD', (json) => {
254-
console.log('json');
255254
if (this.events.has('reaction')) {
256255
this.events.get('reaction')(new Reaction_1.default(json, this.token, this.bot));
257256
}

dist/lib/discord/Message.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Message as IMessage } from '../_DiscordAPI';
99
declare class Message {
1010
protected token: string;
1111
protected bot: User;
12-
author_id: string;
12+
author: User;
1313
guild_id: string;
1414
channel_id: string;
1515
embeds: Embed[];

dist/lib/discord/Message.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1818
};
1919
Object.defineProperty(exports, "__esModule", { value: true });
2020
const Embed_1 = __importDefault(require("./Embed"));
21+
const User_1 = __importDefault(require("./User"));
2122
const _Debug_1 = __importDefault(require("../_Debug"));
2223
const _http_1 = __importDefault(require("../_http"));
2324
// class Message implements IMessage {
@@ -26,16 +27,18 @@ class Message {
2627
var _a;
2728
this.token = token;
2829
this.bot = bot;
29-
Object.assign(this, Object.assign(Object.assign({}, data), { timestamp: new Date(data === null || data === void 0 ? void 0 : data.timestamp), embeds: (_a = data === null || data === void 0 ? void 0 : data.embeds) === null || _a === void 0 ? void 0 : _a.map((v) => new Embed_1.default(v)) }));
30+
Object.assign(this, Object.assign(Object.assign({}, data), { author: new User_1.default(data.author, this.token), timestamp: new Date(data === null || data === void 0 ? void 0 : data.timestamp), embeds: (_a = data === null || data === void 0 ? void 0 : data.embeds) === null || _a === void 0 ? void 0 : _a.map((v) => new Embed_1.default(v)) }));
3031
if (data.message_reference) {
3132
_http_1.default.GET(`/channels/${data.message_reference.channel_id}/messages/${data.message_reference.message_id}`).then((msg) => (this.message_reference = new Message(msg, token, bot)));
3233
}
3334
}
3435
edit(content) {
3536
return __awaiter(this, void 0, void 0, function* () {
3637
const data = {};
37-
if (this.author_id.toString() !== this.bot.id.toString())
38+
if (this.author.id.toString() !== this.bot.id.toString()) {
3839
new _Debug_1.default(true).error('message edit', "Cannot edit a message you didn't send");
40+
return;
41+
}
3942
if (typeof content === 'string') {
4043
// Just a normal message
4144
data.content = content;

examples/index.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,17 @@ client.use(function reactMiddleware(req, res, next) {
4141
// A basic 'ping' command. Responds with 'pong' along with the latency (in
4242
// milliseconds) within an embed.
4343
client.command(['ping', 'latency'], function ping(req, res) {
44-
const timestamp = Date.parse(new Date(req.message.timestamp));
45-
res.send(
46-
new Embed()
47-
.setTitle('Pong')
48-
.setAuthor(req.author.username, { icon: req.author.avatar })
49-
.addField({
50-
name: 'Latency',
51-
value: `${Date.now() - timestamp}ms`,
52-
})
53-
.setDescription()
54-
.setColor(Colors.rgb(13, 186, 120))
55-
);
44+
res.send('Loading...').then(msg => {
45+
msg.edit(new Embed()
46+
.setTitle('Pong')
47+
.setAuthor(req.author.username, { icon: req.author.avatar })
48+
.addField({
49+
name: 'Latency',
50+
value: `${Date.now() - msg.timestamp}ms`,
51+
})
52+
.setDescription()
53+
.setColor(Colors.rgb(13, 186, 120)))
54+
})
5655
});
5756
// More complex example command using the GitHub API
5857
client.command(['github', 'gh'], async function github(req, res) {

examples/package-lock.json

Lines changed: 178 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)