Skip to content

Commit

Permalink
docs: update milestone
Browse files Browse the repository at this point in the history
  • Loading branch information
tinarskii committed Nov 6, 2022
1 parent c33cd5f commit 055a002
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 40 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ However, here are some of the features that will be implemented:
- [x] Fun commands
- [ ] Utility commands
- [ ] Music commands
- [ ] NSFW commands
- [ ] Leveling system
- [x] NSFW commands
- [ ] Economy system

With new addition that does not exist in the original project:

- [ ] Web dashboard
- [ ] Leveling system
- [ ] Chatting Bot
- [ ] Anti-spam system
- [ ] And more TODOs...
Expand Down
41 changes: 38 additions & 3 deletions src/commands/nsfw/danbooru.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
import { Discord, Slash } from "discordx";
import { Discord, Slash, SlashOption } from "discordx";
import { ApplicationCommandOptionType, Colors, CommandInteraction, EmbedBuilder, TextChannel } from "discord.js";
import { Category } from "@discordx/utilities";
import axios from "axios";

@Discord()
@Category("Age-Restricted")
export class DanbooruCommand {
public readonly rating = {
e: "explicit",
s: "safe",
q: "questionable",
u: "unknown",
};

@Slash({ description: "Get random danbooru image", name: "danbooru" })
async danbooru(
@
@SlashOption({
name: "tags",
description: "Tags to search (Seperated with commas)",
type: ApplicationCommandOptionType.String,
required: false,
})
tags: string = "",
interaction: CommandInteraction,
): Promise<void> {

if (!(<TextChannel>interaction.channel).nsfw) {
await interaction.reply("This channel is not Age-Restricted!");
return;
}

const { data } = await axios.get(`https://danbooru.donmai.us/posts.json?tags=${tags}&page=${Math.floor(Math.random() * 100) + 1}&limit=1`);
await interaction.reply({
embeds: [
new EmbedBuilder()
.setTitle(`Image from ${data[0].tag_string_artist}`)
.setImage(data[0].file_url)
.setColor(Colors.Green)
.setURL(`https://danbooru.donmai.us/posts/${data[0].id}`)
.setFooter({
text: `rating: ${this.rating[data[0].rating as keyof typeof this.rating]} | score: ${data[0].score}`,
}),
],
});
}
}
37 changes: 17 additions & 20 deletions src/commands/nsfw/gelbooru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@ import { Category } from "@discordx/utilities";
import axios from "axios";

@Discord()
@Category("NSFW")
export class DanbooruCommand {
public readonly rating = {
e: "explicit",
s: "safe",
q: "questionable",
u: "unknown",
};

@Slash({ description: "Get random danbooru image", name: "danbooru" })
async danbooru(
@Category("Age-Restricted")
export class GelbooruCommand {
@Slash({ description: "Get random gelbooru image", name: "gelbooru" })
async gelbooru(
@SlashOption({
name: "tags",
description: "Tags to search (Seperated with commas)",
Expand All @@ -25,21 +18,25 @@ export class DanbooruCommand {
interaction: CommandInteraction,
): Promise<void> {
if (!(<TextChannel>interaction.channel).nsfw) {
await interaction.reply("This channel is not NSFW!");
await interaction.reply("This channel is not Age-Restricted!");
return;
}

const { data } = await axios.get(`https://danbooru.donmai.us/posts.json?tags=${tags}&limit=1`);
const { data } = await axios.get(`https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&limit=1&pid=${Math.floor(Math.random() * 100) + 1}&tags=${tags.split(",").join("+")}`);

if (!data.post) {
await interaction.reply("No results found!");
return;
}

await interaction.reply({
embeds: [
new EmbedBuilder()
.setTitle(`Image from ${data[0].tag_string_artist}`)
.setImage(data[0].file_url)
.setColor(Colors.Green)
.setURL(`https://danbooru.donmai.us/posts/${data[0].id}`)
.setFooter({
text: `rating: ${this.rating[data[0].rating as keyof typeof this.rating]} | score: ${data[0].score}`,
}),
.setTitle(`Image from ${data.post[0].owner}`)
.setColor(Colors.Fuchsia)
.setImage(data.post[0].file_url)
.setFooter({ text: `rating: ${data.post[0].rating} | score: ${data.post[0].score}` })
.setURL(`https://gelbooru.com/index.php?page=post&s=view&id=${data.post[0].id}`),
],
});
}
Expand Down
26 changes: 11 additions & 15 deletions src/commands/nsfw/rule34.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { Category } from "@discordx/utilities";
import axios from "axios";

@Discord()
@Category("NSFW")
export class DanbooruCommand {
@Slash({ description: "Get random gelbooru image", name: "gelbooru" })
async gelbooru(
@Category("Age-Restricted")
export class Rule34Command {
@Slash({ description: "Get random image from rule34.xxx", name: "rule34" })
async rule34(
@SlashOption({
name: "tags",
description: "Tags to search (Seperated with commas)",
Expand All @@ -22,21 +22,17 @@ export class DanbooruCommand {
return;
}

const { data } = await axios.get(`https://gelbooru.com/index.php?page=dapi&s=post&q=index&json=1&limit=1&pid=${Math.floor(Math.random() * 100) + 1}&tags=${tags.split(",").join("+")}`);

if (!data.post) {
await interaction.reply("No results found!");
return;
}
const { data } = await axios.get(`https://rule34.xxx/index.php?page=dapi&s=post&q=index&tags=${tags}&json=1`);
const image = data[Math.floor(Math.random() * data.length)];

await interaction.reply({
embeds: [
new EmbedBuilder()
.setTitle(`Image from ${data.post[0].owner}`)
.setColor(Colors.Fuchsia)
.setImage(data.post[0].file_url)
.setFooter({ text: `rating: ${data.post[0].rating} | score: ${data.post[0].score}` })
.setURL(`https://gelbooru.com/index.php?page=post&s=view&id=${data.post[0].id}`),
.setTitle(`Image from ${image.owner}`)
.setColor("#ffb6c1")
.setImage(image.file_url)
.setFooter({ text: `rating: ${image.rating} | score: ${image.score}` })
.setURL(`https://rule34.xxx/index.php?page=post&s=view&id=${image.id}`),
],
});
}
Expand Down

0 comments on commit 055a002

Please sign in to comment.