diff --git a/package.json b/package.json index 2f4ec2165..10b69d5c1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gcommands", - "version": "1.0.26", + "version": "1.0.27", "description": "Open-source slah command handler", "main": "src/index.js", "dependencies": { diff --git a/src/main/GCommands.js b/src/main/GCommands.js index 11d477181..24795e0c9 100644 --- a/src/main/GCommands.js +++ b/src/main/GCommands.js @@ -276,8 +276,8 @@ class Message extends Structures.get("Message") { options.buttons = []; } - if(!options.allowed_mentions) { - options.allowed_mentions = { parse: ["users", "roles", "everyone"] }; + if(!options.allowedMentions) { + options.allowedMentions = { parse: ["users", "roles", "everyone"] }; } if (!Array.isArray(options.buttons)) { @@ -375,7 +375,7 @@ class Message extends Structures.get("Message") { "Content-Type": 'applications/json' }, data: { - allowed_mentions: options.allowed_mentions, + allowed_mentions: options.allowedMentions, content: content, components: [ { @@ -389,124 +389,6 @@ class Message extends Structures.get("Message") { }); } - async buttonsWithReply(content, options) { - if (!options.buttons) { - options.buttons = []; - } - - if(!options.allowed_mentions) { - options.allowed_mentions = { parse: ["users", "roles", "everyone"] }; - } - - if (!Array.isArray(options.buttons)) { - return console.log(new Color("&d[GCommands] &cThe buttons must be array.",{json:false}).getText()); - } - - let buttons = []; - let styles = ['blupurple', 'grey', 'green', 'red', 'url']; - - options.buttons.forEach((x, i) => { - if (!x.style) x.style = 'blupurple'; - - if (!styles.includes(x.style)) { - return console.log(new Color(`&d[GCommands] &c#${i} button has invalid style, recived ${x.style}`,{json:false}).getText()); - } - - if (!x.label) { - return console.log(new Color(`&d[GCommands] &c#${i} don't has label!`,{json:false}).getText()); - } - - if (typeof (x.label) !== 'string') x.label = String(x.label); - - if (x.style === 'url') { - if (!x.url) { - return console.log(new Color(`&d[GCommands] &cIf the button style is "url", you must provide url`,{json:false}).getText()); - } - } else { - if (!x.id) { - return console.log(new Color(`&d[GCommands] &cIf the button style is not "url", you must provide custom id`,{json:false}).getText()); - } - } - - var style; - - if (x.style === 'blupurple') { - style = 1; - } else if (x.style === 'grey') { - style = 2; - } else if (x.style === 'green') { - style = 3; - } else if (x.style === 'red') { - style = 4; - } else if (x.style === 'url') { - style = 5; - } - - let data = { - type: 2, - style: style, - label: x.label, - custom_id: x.id || null, - url: x.url || null - } - - buttons.push(data); - }) - - options.buttons === null; - - this.client.ws.on('INTERACTION_CREATE', async (data) => { - let typeStyles = { - 1: 'blupurple', - 2: 'grey', - 3: 'green', - 4: 'red', - 5: 'url' - }; - - await this.client.channels.cache.get(data.channel_id).messages.fetch(); - - var message; - try { - message = await this.client.channels.cache.get(data.channel_id).messages.cache.get(data.message.id); - } catch(e) { - message = await this.client.channels.cache.get(data.channel_id) - } - - var clicker = await this.client.guilds.cache.get(data.guild_id).members.cache.get(data.member.user.id); - - this.client.emit('clickButton', { - version: data.version, - type: data.type, - style: typeStyles[data.type], - token: data.token, - id: data.data.custom_id, - discordId: data.id, - applicationId: data.application_id, - clicker: clicker, - message - }) - }); - - this.client.api.channels[this.channel.id].messages.post({ - headers: { - "Content-Type": 'applications/json' - }, - data: { - allowed_mentions: options.allowed_mentions, - content: content, - components: [ - { - type: 1, - components: buttons - } - ], - options, - embed: options.embed || null - } - }).then(d => this.client.actions.MessageCreate.handle(d).message); - } - async inlineReply(content, options) { const mentionRepliedUser = typeof ((options || content || {}).allowedMentions || {}).repliedUser === "undefined" ? true : ((options || content).allowedMentions).repliedUser; delete ((options || content || {}).allowedMentions || {}).repliedUser;