list char images

master
Kit Kasune 3 years ago
parent eefbaf43fa
commit 79ea8689fc
  1. 19
      .idea/workspace.xml
  2. 64
      commands/anime/char.js
  3. 105
      commands/anime/charimage.js
  4. 2
      commands/misc/commands.js

@ -4,10 +4,9 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="826c705b-a7fa-4ece-b82a-e278fca7d494" name="Changes" comment="e"> <list default="true" id="826c705b-a7fa-4ece-b82a-e278fca7d494" name="Changes" comment="list characters in anime">
<change afterPath="$PROJECT_DIR$/slash/userinfo.js.dev" afterDir="false" />
<change afterPath="$PROJECT_DIR$/slashtemplate.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/commands/anime/char.js" beforeDir="false" afterPath="$PROJECT_DIR$/commands/anime/char.js" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -79,7 +78,7 @@
<workItem from="1640124257973" duration="3978000" /> <workItem from="1640124257973" duration="3978000" />
<workItem from="1640131913922" duration="1135000" /> <workItem from="1640131913922" duration="1135000" />
<workItem from="1640142319793" duration="749000" /> <workItem from="1640142319793" duration="749000" />
<workItem from="1640147904557" duration="2860000" /> <workItem from="1640147904557" duration="6966000" />
</task> </task>
<task id="LOCAL-00001" summary="not even gonna explain"> <task id="LOCAL-00001" summary="not even gonna explain">
<created>1640148826800</created> <created>1640148826800</created>
@ -102,7 +101,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1640206937172</updated> <updated>1640206937172</updated>
</task> </task>
<option name="localTasksCounter" value="4" /> <task id="LOCAL-00004" summary="list characters in anime">
<created>1640214318896</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1640214318896</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -125,6 +131,7 @@
<MESSAGE value="not even gonna explain" /> <MESSAGE value="not even gonna explain" />
<MESSAGE value="stoopid errors" /> <MESSAGE value="stoopid errors" />
<MESSAGE value="e" /> <MESSAGE value="e" />
<option name="LAST_COMMIT_MESSAGE" value="e" /> <MESSAGE value="list characters in anime" />
<option name="LAST_COMMIT_MESSAGE" value="list characters in anime" />
</component> </component>
</project> </project>

@ -323,14 +323,7 @@ module.exports = {
asr.stop(); asr.stop();
} }
else {return message.reply("Looks like you didn't find the character you were looking for.");} else {return message.reply("Looks like you didn't find the character you were looking for.");}
} else { } else {fn = asr.id;}
await message.channel.send({embeds: [asr.embed]});
let conf = await ask(message, "Is this the character you meant?", 60000);
if (!['y', 'yes', 'ye', 'n', 'no'].includes(conf.trim().toLowerCase())) {clearDM(); return dmch.send("You must specify yes or no! Please try again.");}
conf = ['y', 'yes', 'ye'].includes(conf.trim().toLowerCase());
if (!conf) {return message.channel.send("Well, I've got nothing, then. If that doesn't match the character you're looking for then I would try again with a more narrow search.");}
fn = asr.id;
}
let tu = await UserData.findOne({uid: message.author.id}); let tu = await UserData.findOne({uid: message.author.id});
let queue = false; let queue = false;
if (!tu || !tu.staff) { if (!tu || !tu.staff) {
@ -427,6 +420,61 @@ module.exports = {
} }
} }
if (['nn', 'nicknane', 'altname', 'nick'].includes(args[0].toLowerCase())) {
args.shift();
if (!args[0]) {
let tempchar = await ask(message, "What character would you like to add to add a nickname to?", 60000, false, true);
if (!tempchar) {return;}
args = tempchar.split(/\s+/g);
}
let asr = await chs(message, client, args.join(" ").trim().toLowerCase(), -700);
let fn;
if (asr === 0) {
return message.channel.send("That search returned no results! Try again?");
} else if (asr instanceof Pagination) {
await asr.start({user: message.author.id, startPage: 1, endTime: 60000});
await asr.message.react('✅');
await message.channel.send("React with :white_check_mark: when you've found the character you want!");
let arc;
try {arc = await asr.message.awaitReactions({filter: (r) => ['✅', '⏹'].includes(r.emoji.name), max: 1, errors: ['time']});}
catch {return message.reply("Looks like you didn't find the character you were looking for.");}
collected = arc.first().emoji.name;
if (collected === '✅') {
fn = client.misc.cache.chars.get(asr.getCurrentPage().title.trim());
asr.stop();
}
else {return message.reply("Looks like you didn't find the character you were looking for.");}
} else {fn = asr.id;}
let tu = await UserData.findOne({uid: message.author.id});
let queue = false;
if (!tu || !tu.staff) {
message.channel.send("This nickname will be __submitted__ for reviewal.");
queue = true;
}
let ch = await Char.findOne({id: fn});
let nn = await ask(message, `What nickname would you like to add to ${ch.name}?`, 60000, false, true);
if (!nn) {return;}
if (!queue) {
ch.nicknames.push(nn);
ch.markModified('nicknames');
ch.save();
}
client.guilds.fetch('762707532417335296').then(g => g.channels.cache.get('817466729293938698').send({
embeds: [
new Discord.MessageEmbed()
.setAuthor(message.author.username, message.author.avatarURL())
.setTitle(`New Character Nickname ${queue ? "Submitted" : "Added"}`)
.setDescription(`For **${ch.name}** | \`${ch.id}\` from ${client.misc.cache.animeID.get(ch.anime)}`)
.addField("Name", nn)
.setThumbnail(ch.thumbnail)
.setColor('c375f0')
.setTimestamp()
.setFooter("Natsuki")
], content: queue ? '<@330547934951112705>' : undefined
}).catch(() => {})).catch(() => {});
return message.channel.send(`Character nickname ${queue ? "submitted" : "added"}.`);
}
return message.channel.send(`Invalid arg! Syntax: \`${prefix}char <add|view|search|random|love|loved>\``); return message.channel.send(`Invalid arg! Syntax: \`${prefix}char <add|view|search|random|love|loved>\``);
} }
}; };

@ -0,0 +1,105 @@
const Discord = require('discord.js');
const UserData = require('../../models/user');
const Char = require('../../models/char');
const ask = require('../../util/ask');
const chs = require('../../util/anime/charsearch');
const {Pagination} = require('../../util/pagination');
module.exports = {
name: "charimage",
aliases: ['ci', 'characterimage', 'charimg'],
meta: {
category: 'Anime',
description: "Add an image to a character",
syntax: '`charimage <character> <imageURL|attachedImage>` or `charimage <list> <character>`',
extra: null,
},
help: new Discord.MessageEmbed()
.setTitle("Help -> Character Images")
.setDescription("Add an image to a character, or list the characters' images.")
.addField("Notice", "If you're not a member of Natsuki staff, this image will be submitted for reviewal.")
.addField("Syntax", "`charimage <character> <imageURL|attachedImage>` or `charimage <list> <character>`"),
async execute(message, msg, args, cmd, prefix, mention, client) {
let list = false;
if (args[0] && ['l', 'list'].includes(args[0].toLowerCase())) {
list = true;
args.shift();
}
if (!args[0]) {
let tempchar = await ask(message, "What character would you like to add to add an image to?", 60000, false, true);
if (!tempchar) {return;}
args = tempchar.split(/\s+/g);
}
let asr = await chs(message, client, args.join(" ").trim().toLowerCase(), -700);
let fn;
if (asr === 0) {
return message.channel.send("That search returned no results! Try again?");
} else if (asr instanceof Pagination) {
await asr.start({user: message.author.id, startPage: 1, endTime: 60000});
await asr.message.react('✅');
await message.channel.send("React with :white_check_mark: when you've found the character you want!");
let arc;
try {arc = await asr.message.awaitReactions({filter: (r) => ['✅', '⏹'].includes(r.emoji.name), max: 1, errors: ['time']});}
catch {return message.reply("Looks like you didn't find the character you were looking for.");}
collected = arc.first().emoji.name;
if (collected === '✅') {
fn = client.misc.cache.chars.get(asr.getCurrentPage().title.trim());
asr.stop();
}
else {return message.reply("Looks like you didn't find the character you were looking for.");}
} else {fn = asr.id;}
let tu = await UserData.findOne({uid: message.author.id});
let queue = false;
if (!tu || !tu.staff) {
message.channel.send("This image will be __submitted__ for reviewal.");
queue = true;
}
let ch = await Char.findOne({id: fn});
if (list) {
let pages = ch.images.map(im => new Discord.MessageEmbed()
.setTitle(ch.name)
.setDescription(`**Name:** ${ch.name}`)
.addField('Other', `**Anime**: ${client.misc.cache.animeID.get(ch.anime)}\n\n**Gender**: ${ch.gender}\n`)
.setColor("c375f0")
.setImage(im)
);
if (pages.length > 1) {
let pag = new Pagination(message.channel, pages, message, client, true);
return await pag.start({user: message.author.id, time: 60000});
} else {return message.channel.send(pages[0].setTimestamp());}
} else {
args.shift();
if (!args[0]) {
let tempchar = message.attachments.size
? message.attachments.first().url
: await ask(message, "Please paste the image or a link to the image you'd like to add.", 60000, false, true);
if (!tempchar) {return;}
args = tempchar.split(/\s+/g);
}
let img = args.join(" ");
if (!img.match(/^https:\/\/(?:[\w\-].?)+[\/\w\-%()_]+\.(?:png|jpg|jpeg|gif|webp)$/gm)) {return message.channel.send("I don't think that's an image. Try again?");}
if (!queue) {
ch.images.push(img);
ch.markModified('images');
ch.save();
}
client.guilds.fetch('762707532417335296').then(g => g.channels.cache.get('817466729293938698').send({
embeds: [
new Discord.MessageEmbed()
.setAuthor(message.author.username, message.author.avatarURL())
.setTitle(`New Image ${queue ? "Submitted" : "Added"}`)
.setDescription(`For **${ch.name}** | \`${ch.id}\` from ${client.misc.cache.animeID.get(ch.anime)}`)
.setThumbnail(ch.thumbnail)
.setImage(img)
.setColor('c375f0')
.setTimestamp()
.setFooter("Natsuki")
], content: queue ? '<@330547934951112705>' : undefined
}).catch(() => {})).catch(() => {});
return message.channel.send(`Character image ${queue ? "submitted" : "added"}.`);
}
}
};

@ -12,7 +12,7 @@ module.exports = {
help: "Shows a list of all my commands", help: "Shows a list of all my commands",
async execute(message, msg, args, cmd, prefix, mention, client) { async execute(message, msg, args, cmd, prefix, mention, client) {
let categories = []; let categories = [];
Array.from(client.commands.values()).forEach(c => {console.log(c); if (!categories.includes(c.meta ? c.meta.category : 'Uncategorized')) {categories.push(c.meta ? c.meta.category : 'Uncategorized');}}); Array.from(client.commands.values()).forEach(c => {if (!categories.includes(c.meta ? c.meta.category : 'Uncategorized')) {categories.push(c.meta ? c.meta.category : 'Uncategorized');}});
let ce = new Discord.MessageEmbed() let ce = new Discord.MessageEmbed()
.setTitle("Commands") .setTitle("Commands")
.setDescription(`You can use \`${prefix}help\` on any command to get more help on it.`) .setDescription(`You can use \`${prefix}help\` on any command to get more help on it.`)

Loading…
Cancel
Save