forked from Supositware/Haha-Yes
Compare commits
No commits in common. "f8c958af91d7f7f5d0f1facf442b7622649922ba" and "5b2fa020d18bc560a7cdd9d7d78c4e4a6be68eeb" have entirely different histories.
f8c958af91
...
5b2fa020d1
2 changed files with 153 additions and 21 deletions
|
@ -30,7 +30,6 @@ export default {
|
||||||
userPermissions: [PermissionFlagsBits.ManageChannels],
|
userPermissions: [PermissionFlagsBits.ManageChannels],
|
||||||
async execute(interaction, args, client) {
|
async execute(interaction, args, client) {
|
||||||
await interaction.deferReply();
|
await interaction.deferReply();
|
||||||
|
|
||||||
if (args.list) {
|
if (args.list) {
|
||||||
let tagList = await db.Tag.findAll({ attributes: ['trigger', 'response', 'ownerID'], where: { serverID: interaction.guild.id } });
|
let tagList = await db.Tag.findAll({ attributes: ['trigger', 'response', 'ownerID'], where: { serverID: interaction.guild.id } });
|
||||||
|
|
||||||
|
@ -51,7 +50,7 @@ export default {
|
||||||
|
|
||||||
if (args.remove) {
|
if (args.remove) {
|
||||||
if (tag) {
|
if (tag) {
|
||||||
if (tag.get('ownerID') == interaction.user.id || interaction.member.permissionsIn(interaction.channel).has('ADMINISTRATOR') || interaction.user.id == ownerId) {
|
if (tag.get('ownerID') == interaction.user.id || interaction.member.hasPermission('ADMINISTRATOR') || interaction.user.id == ownerId) {
|
||||||
db.Tag.destroy({ where: { trigger: args.trigger, serverID: interaction.guild.id } });
|
db.Tag.destroy({ where: { trigger: args.trigger, serverID: interaction.guild.id } });
|
||||||
return interaction.editReply('successfully deleted the following tag: ' + args.trigger);
|
return interaction.editReply('successfully deleted the following tag: ' + args.trigger);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +71,7 @@ export default {
|
||||||
await db.Tag.create(body);
|
await db.Tag.create(body);
|
||||||
return interaction.editReply(`tag have been set to ${args.trigger} : ${args.response}`);
|
return interaction.editReply(`tag have been set to ${args.trigger} : ${args.response}`);
|
||||||
}
|
}
|
||||||
else if (tag.get('ownerID') == interaction.user.id || interaction.member.permissionsIn(interaction.channel).has('ADMINISTRATOR') || interaction.user.id == ownerId) {
|
else if (tag.get('ownerID') == interaction.user.id || interaction.member.hasPermission('ADMINISTRATOR') || interaction.user.id == ownerId) {
|
||||||
|
|
||||||
const row = new ActionRowBuilder()
|
const row = new ActionRowBuilder()
|
||||||
.addComponents(
|
.addComponents(
|
||||||
|
@ -113,6 +112,26 @@ export default {
|
||||||
return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true });
|
return interaction.editReply({ content: 'Nothing has been changed.', ephemeral: true });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
const filter = m => m.content && m.author.id == interaction.user.id;
|
||||||
|
message.channel.awaitMessages(filter, { time: 5000, max: 1, errors: ['time'] })
|
||||||
|
.then(async messages => {
|
||||||
|
let messageContent = messages.map(messages => messages.content.toLowerCase());
|
||||||
|
if (messageContent[0] === 'y' || messageContent[0] === 'yes') {
|
||||||
|
const body = { trigger: args.trigger, response: args.response, ownerID: interaction.user.id, serverID: message.guild.id };
|
||||||
|
await Tag.update(body, { where: { trigger: args.trigger, serverID: message.guild.id } });
|
||||||
|
return interaction.editReply(`tag have been set to ${args.trigger} : ${args.response}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return interaction.editReply('Not updating.');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
return interaction.editReply('Took too long to answer. didin\'t update anything.');
|
||||||
|
});
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return interaction.editReply(`You are not the owner of this tag, if you think it is problematic ask an admin to remove it by doing ${this.client.commandHandler.prefix[0]}tag ${args.trigger} --remove`);
|
return interaction.editReply(`You are not the owner of this tag, if you think it is problematic ask an admin to remove it by doing ${this.client.commandHandler.prefix[0]}tag ${args.trigger} --remove`);
|
||||||
|
@ -130,3 +149,121 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
const { Command } = require('discord-akairo');
|
||||||
|
const Tag = require('../../models').Tag;
|
||||||
|
|
||||||
|
class TagCommand extends Command {
|
||||||
|
constructor() {
|
||||||
|
super('tag', {
|
||||||
|
aliases: ['tag'],
|
||||||
|
category: 'admin',
|
||||||
|
userPermissions: ['MANAGE_MESSAGES'],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
id: 'trigger',
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'remove',
|
||||||
|
match: 'flag',
|
||||||
|
flag: '--remove'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'reset',
|
||||||
|
match: 'flag',
|
||||||
|
flag: '--reset'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'response',
|
||||||
|
type: 'string',
|
||||||
|
match: 'rest',
|
||||||
|
}
|
||||||
|
],
|
||||||
|
channel: 'guild',
|
||||||
|
description: {
|
||||||
|
content: 'Create custom autoresponse (--remove to delete a tag, --reset to delete EVERY tag on the server) [Click here to see the complete list of "tag"](https://cdn.discordapp.com/attachments/502198809355354133/561043193949585418/unknown.png) (Need "" if the trigger contains spaces)',
|
||||||
|
usage: '[trigger] [response]',
|
||||||
|
examples: ['"do you know da wea" Fuck off dead meme', 'hello Hello [author], how are you today?', 'hello --remove']
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async exec(message, args) {
|
||||||
|
const tag = await Tag.findOne({where: {trigger: args.trigger, serverID: message.guild.id}});
|
||||||
|
const ownerID = this.client.ownerID;
|
||||||
|
|
||||||
|
if (args.reset) {
|
||||||
|
if (message.member.hasPermission('ADMINISTRATOR')) {
|
||||||
|
interaction.editReply('Are you sure you want to delete EVERY tag? There is no way to recover them. y/n');
|
||||||
|
|
||||||
|
const filter = m => m.content && m.author.id == interaction.user.id;
|
||||||
|
return message.channel.awaitMessages(filter, {time: 5000, max: 1, errors: ['time'] })
|
||||||
|
.then(async messages => {
|
||||||
|
let messageContent = messages.map(messages => messages.content.toLowerCase());
|
||||||
|
if (messageContent[0] === 'y' || messageContent[0] === 'yes') {
|
||||||
|
Tag.destroy({where: {serverID: message.guild.id}});
|
||||||
|
return interaction.editReply('Tags have been reset.');
|
||||||
|
} else {
|
||||||
|
return interaction.editReply('Not reseting.');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
return interaction.editReply('Took too long to answer. didin\'t update anything.');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return interaction.editReply('Only person with the `ADMINISTRATOR` rank can reset tags.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.remove) {
|
||||||
|
if (tag) {
|
||||||
|
if (tag.get('ownerID') == interaction.user.id || message.member.hasPermission('ADMINISTRATOR') || interaction.user.id == ownerID) {
|
||||||
|
Tag.destroy({where: {trigger: args.trigger, serverID: message.guild.id}});
|
||||||
|
return interaction.editReply('successfully deleted the following tag: ' + args.trigger);
|
||||||
|
} else {
|
||||||
|
return interaction.editReply(`You are not the owner of this tag, if you think it is problematic ask an admin to remove it by doing ${this.client.commandHandler.prefix[0]}tag ${args.trigger} --remove`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return interaction.editReply('Did not find the specified tag, are you sure it exist?');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!args.trigger) return interaction.editReply('Please provide a trigger in order to create a tag.');
|
||||||
|
|
||||||
|
if (!args.response) return interaction.editReply('Please provide the response for that tag');
|
||||||
|
|
||||||
|
if (!tag) {
|
||||||
|
const body = {trigger: args.trigger, response: args.response, ownerID: interaction.user.id, serverID: message.guild.id};
|
||||||
|
await Tag.create(body);
|
||||||
|
return interaction.editReply(`tag have been set to ${args.trigger} : ${args.response}`);
|
||||||
|
} else if (tag.get('ownerID') == interaction.user.id || message.member.hasPermission('ADMINISTRATOR') || interaction.user.id == ownerID) {
|
||||||
|
interaction.editReply('This tag already exist, do you want to update it? y/n');
|
||||||
|
const filter = m => m.content && m.author.id == interaction.user.id;
|
||||||
|
message.channel.awaitMessages(filter, {time: 5000, max: 1, errors: ['time'] })
|
||||||
|
.then(async messages => {
|
||||||
|
let messageContent = messages.map(messages => messages.content.toLowerCase());
|
||||||
|
if (messageContent[0] === 'y' || messageContent[0] === 'yes') {
|
||||||
|
const body = {trigger: args.trigger, response: args.response, ownerID: interaction.user.id, serverID: message.guild.id};
|
||||||
|
await Tag.update(body, {where: {trigger: args.trigger, serverID: message.guild.id}});
|
||||||
|
return interaction.editReply(`tag have been set to ${args.trigger} : ${args.response}`);
|
||||||
|
} else {
|
||||||
|
return interaction.editReply('Not updating.');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
return interaction.editReply('Took too long to answer. didin\'t update anything.');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return interaction.editReply(`You are not the owner of this tag, if you think it is problematic ask an admin to remove it by doing ${this.client.commandHandler.prefix[0]}tag ${args.trigger} --remove`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = TagCommand;
|
||||||
|
*/
|
15
index.js
15
index.js
|
@ -41,13 +41,11 @@ async function loadCommandFromDir(dir) {
|
||||||
|
|
||||||
for (const file of commandFiles) {
|
for (const file of commandFiles) {
|
||||||
const filePath = path.join(commandsPath, file);
|
const filePath = path.join(commandsPath, file);
|
||||||
import(filePath)
|
let command = await import(filePath);
|
||||||
.then(importedCommand => {
|
command = command.default;
|
||||||
const command = importedCommand.default;
|
|
||||||
client.commands.set(command.data.name, command);
|
client.commands.set(command.data.name, command);
|
||||||
console.log(`Successfully loaded command \x1b[32m${command.category}/${command.data.name}\x1b[0m`);
|
console.log(`Successfully loaded command \x1b[32m${command.category}/${command.data.name}\x1b[0m`);
|
||||||
})
|
|
||||||
.catch(error => console.error(`Failed to load command for path: ${filePath}`, error));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,16 +55,13 @@ async function loadEventFromDir(dir, listener) {
|
||||||
|
|
||||||
for (const file of eventFiles) {
|
for (const file of eventFiles) {
|
||||||
const filePath = path.join(eventsPath, file);
|
const filePath = path.join(eventsPath, file);
|
||||||
import(filePath)
|
let event = await import(filePath);
|
||||||
.then(importedEvent => {
|
event = event.default;
|
||||||
const event = importedEvent.default;
|
|
||||||
if (event.once) {
|
if (event.once) {
|
||||||
listener.once(event.name, (...args) => event.execute(...args, client));
|
listener.once(event.name, (...args) => event.execute(...args, client));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
listener.on(event.name, (...args) => event.execute(...args, client));
|
listener.on(event.name, (...args) => event.execute(...args, client));
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.catch(error => console.error(`Failed to load event for path: ${filePath}`, error));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue