Removed googleapis package, added twitter to info, fixed bug with tags
This commit is contained in:
parent
38fa8c4629
commit
f1fb72294d
6 changed files with 44 additions and 230 deletions
|
@ -1,15 +1,15 @@
|
|||
const { google } = require("googleapis");
|
||||
const client = require("../utils/client.js");
|
||||
const paginator = require("../utils/pagination/pagination");
|
||||
const search = google.customsearch("v1");
|
||||
const paginator = require("../utils/pagination/pagination.js");
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
exports.run = async (message, args) => {
|
||||
if (!message.channel.guild.members.get(client.user.id).permission.has("addReactions") && !message.channel.permissionsOf(client.user.id).has("addReactions")) return `${message.author.mention}, I don't have the \`Add Reactions\` permission!`;
|
||||
if (!message.channel.guild.members.get(client.user.id).permission.has("embedLinks") && !message.channel.permissionsOf(client.user.id).has("embedLinks")) return `${message.author.mention}, I don't have the \`Embed Links\` permission!`;
|
||||
if (args.length === 0) return `${message.author.mention}, you need to provide something to search for!`;
|
||||
const embeds = [];
|
||||
const images = await search.cse.list({ searchType: "image", safe: "active", cx: process.env.CSE, q: args.join(" "), auth: process.env.GOOGLE });
|
||||
for (const [i, value] of images.data.items.entries()) {
|
||||
const request = await fetch(`https://www.googleapis.com/customsearch/v1?key=${process.env.GOOGLE}&cx=${process.env.CSE}&safe=active&searchType=image&q=${encodeURIComponent(args.join(" "))}`);
|
||||
const images = await request.json();
|
||||
for (const [i, value] of images.items.entries()) {
|
||||
embeds.push({
|
||||
"embed": {
|
||||
"title": "Search Results",
|
||||
|
|
|
@ -30,6 +30,10 @@ exports.run = async (message) => {
|
|||
{
|
||||
"name": "💻 Source Code:",
|
||||
"value": "[Click here!](https://github.com/TheEssem/esmBot-rewrite)"
|
||||
},
|
||||
{
|
||||
"name": "<:twitter:652550515372064768> Twitter:",
|
||||
"value": "[Click here!](https://twitter.com/esmBot_)"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ const paginator = require("../utils/pagination/pagination.js");
|
|||
const { random } = require("../utils/misc.js");
|
||||
|
||||
exports.run = async (message, args) => {
|
||||
if (args.length === 0) return `${message.author.mention}, you need to specify the name of the tag you want to view!`;
|
||||
const guild = (await database.guilds.find({ id: message.channel.guild.id }).exec())[0];
|
||||
const tags = guild.tags;
|
||||
const blacklist = ["add", "edit", "remove", "delete", "list", "random"];
|
||||
|
@ -60,7 +61,6 @@ exports.run = async (message, args) => {
|
|||
case "random":
|
||||
return tags[random(Object.keys(tags))].content;
|
||||
default:
|
||||
if (args.length === 0) return `${message.author.mention}, you need to specify the name of the tag you want to view!`;
|
||||
if (!tags.has(args[0].toLowerCase())) return `${message.author.mention}, this tag doesn't exist!`;
|
||||
return tags.get(args[0].toLowerCase()).content;
|
||||
}
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
const { google } = require("googleapis");
|
||||
const youtube = google.youtube({
|
||||
version: "v3",
|
||||
auth: process.env.GOOGLE,
|
||||
});
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
exports.run = async (message, args) => {
|
||||
if (args.length === 0) return `${message.author.mention}, you need to provide something to search for!`;
|
||||
message.channel.sendTyping();
|
||||
const result = await youtube.search.list({ q: args.join(" "), part: "snippet" });
|
||||
if (result.data.items[0].id.kind === "youtube#channel") {
|
||||
return `<:youtube:637020823005167626> **${result.data.items[0].snippet.title.replace("*", "\\*")}**\nhttps://youtube.com/channel/${result.data.items[0].id.channelId}`;
|
||||
} else if (result.data.items[0].id.kind === "youtube#playlist") {
|
||||
return `<:youtube:637020823005167626> **${result.data.items[0].snippet.title.replace("*", "\\*")}**\nCreated by **${result.data.items[0].snippet.channelTitle.replace("*", "\\*")}**\nhttps://youtube.com/playlist?list=${result.data.items[0].id.playlistId}`;
|
||||
const request = await fetch(`https://www.googleapis.com/youtube/v3/search?part=snippet&q=${encodeURIComponent(args.join(" "))}&key=${process.env.GOOGLE}`);
|
||||
const result = await request.json();
|
||||
if (result.items[0].id.kind === "youtube#channel") {
|
||||
return `<:youtube:637020823005167626> **${result.items[0].snippet.title.replace("*", "\\*")}**\nhttps://youtube.com/channel/${result.items[0].id.channelId}`;
|
||||
} else if (result.items[0].id.kind === "youtube#playlist") {
|
||||
return `<:youtube:637020823005167626> **${result.items[0].snippet.title.replace("*", "\\*")}**\nCreated by **${result.items[0].snippet.channelTitle.replace("*", "\\*")}**\nhttps://youtube.com/playlist?list=${result.items[0].id.playlistId}`;
|
||||
} else {
|
||||
return `<:youtube:637020823005167626> **${result.data.items[0].snippet.title.replace("*", "\\*")}**\nUploaded by **${result.data.items[0].snippet.channelTitle.replace("*", "\\*")}** on **${result.data.items[0].snippet.publishedAt.split("T")[0]}**\nhttps://youtube.com/watch?v=${result.data.items[0].id.videoId}`;
|
||||
return `<:youtube:637020823005167626> **${result.items[0].snippet.title.replace("*", "\\*")}**\nUploaded by **${result.items[0].snippet.channelTitle.replace("*", "\\*")}** on **${result.items[0].snippet.publishedAt.split("T")[0]}**\nhttps://youtube.com/watch?v=${result.items[0].id.videoId}`;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue