Skip to content

Commit

Permalink
fix alot of bugs and add erlpack back
Browse files Browse the repository at this point in the history
  • Loading branch information
Artrix9095 committed Sep 4, 2021
1 parent 9de01bf commit a450694
Show file tree
Hide file tree
Showing 11 changed files with 301 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Secrets and logs
*.secret
*.log
# *.log

# Cache
.eslintcache
Expand Down
1 change: 0 additions & 1 deletion dist/lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ class Client extends Emitter_1.default {
ready();
});
this.event('MESSAGE_REACTION_ADD', (json) => {
console.log('json');
if (this.events.has('reaction')) {
this.events.get('reaction')(new Reaction_1.default(json, this.token, this.bot));
}
Expand Down
2 changes: 1 addition & 1 deletion dist/lib/discord/Message.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Message as IMessage } from '../_DiscordAPI';
declare class Message {
protected token: string;
protected bot: User;
author_id: string;
author: User;
guild_id: string;
channel_id: string;
embeds: Embed[];
Expand Down
7 changes: 5 additions & 2 deletions dist/lib/discord/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const Embed_1 = __importDefault(require("./Embed"));
const User_1 = __importDefault(require("./User"));
const _Debug_1 = __importDefault(require("../_Debug"));
const _http_1 = __importDefault(require("../_http"));
// class Message implements IMessage {
Expand All @@ -26,16 +27,18 @@ class Message {
var _a;
this.token = token;
this.bot = bot;
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)) }));
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)) }));
if (data.message_reference) {
_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)));
}
}
edit(content) {
return __awaiter(this, void 0, void 0, function* () {
const data = {};
if (this.author_id.toString() !== this.bot.id.toString())
if (this.author.id.toString() !== this.bot.id.toString()) {
new _Debug_1.default(true).error('message edit', "Cannot edit a message you didn't send");
return;
}
if (typeof content === 'string') {
// Just a normal message
data.content = content;
Expand Down
23 changes: 11 additions & 12 deletions examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,17 @@ client.use(function reactMiddleware(req, res, next) {
// A basic 'ping' command. Responds with 'pong' along with the latency (in
// milliseconds) within an embed.
client.command(['ping', 'latency'], function ping(req, res) {
const timestamp = Date.parse(new Date(req.message.timestamp));
res.send(
new Embed()
.setTitle('Pong')
.setAuthor(req.author.username, { icon: req.author.avatar })
.addField({
name: 'Latency',
value: `${Date.now() - timestamp}ms`,
})
.setDescription()
.setColor(Colors.rgb(13, 186, 120))
);
res.send('Loading...').then(msg => {
msg.edit(new Embed()
.setTitle('Pong')
.setAuthor(req.author.username, { icon: req.author.avatar })
.addField({
name: 'Latency',
value: `${Date.now() - msg.timestamp}ms`,
})
.setDescription()
.setColor(Colors.rgb(13, 186, 120)))
})
});
// More complex example command using the GitHub API
client.command(['github', 'gh'], async function github(req, res) {
Expand Down
179 changes: 178 additions & 1 deletion examples/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a450694

Please sign in to comment.