mirror of
https://github.com/ION606/custom_discordjs.git
synced 2026-05-14 22:26:54 +00:00
added message reactions
This commit is contained in:
@@ -15,7 +15,7 @@ export class message extends DataManager {
|
||||
|
||||
/** @type {Object[]} */
|
||||
mentions;
|
||||
|
||||
|
||||
/** @type {Object[]} */
|
||||
mention_roles;
|
||||
|
||||
@@ -83,10 +83,10 @@ export class message extends DataManager {
|
||||
guild_id: this.guild_id,
|
||||
fail_if_not_exists: false //when sending, whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message, default true
|
||||
}
|
||||
|
||||
const toSend = (typeof inp == 'string') ? {content: inp} : structuredClone(inp);
|
||||
|
||||
const toSend = (typeof inp == 'string') ? { content: inp } : structuredClone(inp);
|
||||
toSend['message_reference'] = refObj;
|
||||
|
||||
|
||||
if (inp.components) {
|
||||
toSend["components"] = [];
|
||||
for (const k of inp.components) {
|
||||
@@ -95,24 +95,28 @@ export class message extends DataManager {
|
||||
}
|
||||
|
||||
resolve(await this.channel.send(toSend));
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
delete() {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const response = await this.client.axiosCustom.delete(`/channels/${this.channel.id}/messages/${this.id}`);
|
||||
|
||||
resolve(response.data);
|
||||
} catch(err) {
|
||||
reject(err);
|
||||
}
|
||||
|
||||
})
|
||||
async delete() {
|
||||
try {
|
||||
const response = await this.client.axiosCustom.delete(`/channels/${this.channel.id}/messages/${this.id}`);
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} reaction
|
||||
*/
|
||||
async react(reaction) {
|
||||
this.axiosCustom.put(`/channels/${this.channel.id}/messages/${this.id}/reactions/${reaction}/@me`);
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +125,7 @@ export class message extends DataManager {
|
||||
*/
|
||||
async edit(inp) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const newMsg = (typeof inp == "string") ? {content: inp} : inp;
|
||||
const newMsg = (typeof inp == "string") ? { content: inp } : inp;
|
||||
|
||||
if (this.components) {
|
||||
newMsg.components = [];
|
||||
@@ -129,7 +133,7 @@ export class message extends DataManager {
|
||||
newMsg.components.push(k.toObj());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.client.axiosCustom.patch(`/channels/${this.channel.id}/messages/${this.id}`, newMsg).then((response) => {
|
||||
resolve(response.data);
|
||||
}).catch((err) => {
|
||||
@@ -156,7 +160,7 @@ export class message extends DataManager {
|
||||
}
|
||||
else {
|
||||
if (k == 'channel_id') {
|
||||
this.channel = new Channel({id: msgRaw[k]}, this.guild, client);
|
||||
this.channel = new Channel({ id: msgRaw[k] }, this.guild, client);
|
||||
}
|
||||
|
||||
this[k] = msgRaw[k];
|
||||
@@ -168,4 +172,4 @@ export class message extends DataManager {
|
||||
}
|
||||
|
||||
|
||||
export {messageChannelTypes} from './messageChannelTypes.js';
|
||||
export { messageChannelTypes } from './messageChannelTypes.js';
|
||||
Reference in New Issue
Block a user