diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index b310cd8..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "dotenv.enableAutocloaking": true -} \ No newline at end of file diff --git a/commands/misc/roleMenu.ts b/commands/misc/roleMenu.ts index c6df3ad..fd83b2a 100644 --- a/commands/misc/roleMenu.ts +++ b/commands/misc/roleMenu.ts @@ -2,7 +2,7 @@ import { commandModule, CommandType } from '@sern/handler' import { publish } from "../../src/plugins/publish.js"; import { ownerOnly } from "../../src/plugins/ownerOnly.js" import { ActionRowBuilder, ApplicationCommandOptionType, ChannelType, Collection, EmbedBuilder, Role, SelectMenuBuilder, TextChannel } from "discord.js"; -import { Resolver } from "../../resolver.js"; +import { Resolver } from "../../util/resolver.js"; export default commandModule({ name: 'rolemenu', diff --git a/index.ts b/index.ts index f175b6e..b61ab7c 100644 --- a/index.ts +++ b/index.ts @@ -6,6 +6,7 @@ import 'dotenv/config' import mongoose from 'mongoose' import youtube from 'discord-bot-youtube-notifications' import express from 'express' +import youtubenotifications from "./util/youtubenotifications.js"; const app = express(); const client = new Client({ @@ -52,34 +53,6 @@ app.get("/", function (req, res) { app.listen(process.env.PORT || 7272, () => console.log("The webserver is listening")); -/*async function nowPlayingRadio() { - const getAPI = await axios.get("https://opml.radiotime.com/Describe.ashx?id=s67006", {validateStatus: function (status) {return status === 200|| status === 403}}).then((res) => res.data).catch((err) => {console.log("now playing radio errored out? diesofcringe")}) - var parser = new DOMParser() - var XMLDoc = parser.parseFromString(getAPI, "text/xml"); - let getsong, getartist; - try { - getsong = XMLDoc.getElementsByTagName("current_song").item(0)!.textContent - getartist = XMLDoc.getElementsByTagName("current_artist").item(0)!.textContent - } catch (err) { - getsong = "Anuncios o cambio de canción" - getartist = "catJAM" - } - const embed = new EmbedBuilder() - .setColor("Blurple") - .setTitle(`Ahora reproduciendo: ${getsong}`) - .setAuthor({name: 'Rock FM', iconURL: 'https://cdn-profiles.tunein.com/s67006/images/logoq.png'}) - .setDescription(`Artista: ${getartist}`) - .setFooter({text: `El nombre no cambia al instante, aparece 10 segundos después de terminar una canción.`}) - const guild = await client.guilds.fetch("928018226330337280"); - const channel = await guild.channels.fetch("1008730592835281009"); - const edit = (await channel.messages.fetch("1008778179252596736")) - await edit.edit({content: '', embeds: [embed]}) -} +client.login(process.env.TOKEN); -function nowPlayingInterval() { - setInterval(nowPlayingRadio, 4000) -} - -nowPlayingInterval()*/ - -client.login(process.env.TOKEN); \ No newline at end of file +setInterval(async () => await youtubenotifications(client), 180000) \ No newline at end of file diff --git a/notes.txt b/notes.txt deleted file mode 100644 index 73c0ebd..0000000 --- a/notes.txt +++ /dev/null @@ -1,43 +0,0 @@ - [ OneButton ] [ TwoButton ] -button customId = 'yes' button customId = 'no' - - - - -collector - options : { - max:1 - }, - filter : interaction.isButton() && interaction.customId === 'yes' || interaction.customId === 'no' - -collect interactions - if interaction.customId === 'yes' - this would be yes button - else - this would be the no button - - - - - - if (interaction.customId === 'langChooserSpanish') { - ctx.reply("spanish") - } - else { - ctx.reply("english") - } - - -const got = require('got') -const { MessageEmbed } = require('discord.js') - -module.exports = { -name: 'meme', -aliases: ['m', 'memes'], -description: 'Get a random meme from reddit', -execute(message, args) { - got(https://srizan.ml).then(res => { - - }); -} -} \ No newline at end of file diff --git a/schemas/youtube.js b/schemas/youtube.js new file mode 100644 index 0000000..aa8d5f5 --- /dev/null +++ b/schemas/youtube.js @@ -0,0 +1,7 @@ +import mongoose from 'mongoose' +const schema = new mongoose.Schema({ + id: {type: String, required: true}, + user: {type: String, required: true} +}); +const db = mongoose.model('youtube', schema, 'youtube'); +export default db \ No newline at end of file diff --git a/util/nowplayingradio.ts b/util/nowplayingradio.ts new file mode 100644 index 0000000..8097a02 --- /dev/null +++ b/util/nowplayingradio.ts @@ -0,0 +1,32 @@ +import axios from "axios"; +import { Client, EmbedBuilder, TextChannel } from "discord.js"; + +export async function nowPlayingRadio(client: Client) { + const getAPI = await axios.get("https://opml.radiotime.com/Describe.ashx?id=s67006", {validateStatus: function (status) {return status === 200|| status === 403}}).then((res) => res.data).catch((err) => {console.log("now playing radio errored out? diesofcringe")}) + var parser = new DOMParser() + var XMLDoc = parser.parseFromString(getAPI, "text/xml"); + let getsong, getartist; + try { + getsong = XMLDoc.getElementsByTagName("current_song").item(0)!.textContent + getartist = XMLDoc.getElementsByTagName("current_artist").item(0)!.textContent + } catch (err) { + getsong = "Anuncios o cambio de canción" + getartist = "catJAM" + } + const embed = new EmbedBuilder() + .setColor("Blurple") + .setTitle(`Ahora reproduciendo: ${getsong}`) + .setAuthor({name: 'Rock FM', iconURL: 'https://cdn-profiles.tunein.com/s67006/images/logoq.png'}) + .setDescription(`Artista: ${getartist}`) + .setFooter({text: `El nombre no cambia al instante, aparece 10 segundos después de terminar una canción.`}) + const guild = await client.guilds.fetch("928018226330337280"); + const channel = await guild.channels.fetch("1008730592835281009"); + const edit = await (channel as TextChannel).messages.fetch("1008778179252596736") + await edit.edit({content: '', embeds: [embed]}) +} + +function nowPlayingInterval() { +setInterval(nowPlayingRadio, 4000) +} + +nowPlayingInterval() \ No newline at end of file diff --git a/resolver.ts b/util/resolver.ts similarity index 100% rename from resolver.ts rename to util/resolver.ts diff --git a/stats.js b/util/web/stats.js similarity index 100% rename from stats.js rename to util/web/stats.js diff --git a/webserver.js b/util/web/webserver.js similarity index 100% rename from webserver.js rename to util/web/webserver.js diff --git a/util/youtubenotifications.ts b/util/youtubenotifications.ts new file mode 100644 index 0000000..9934215 --- /dev/null +++ b/util/youtubenotifications.ts @@ -0,0 +1,23 @@ +import { Client, EmbedBuilder, TextChannel } from "discord.js"; +import axios from 'axios' +import schema from '../schemas/youtube.js' + +export default async function youtubenotifications(client: Client) { + const db = await schema.findOne({name: 'elpady'}) + const request = await axios.get('https://decapi.me/youtube/latest_video?id=UC9G2yvrtrPeJFEzwlshg5HA&format={id}').then(res => res.data) + const noembed = await axios.get(`https://noembed.com/embed?url=https://youtube.com/watch?v=${request}`).then(res => res.data) + const fetchTextChannel = await (await client.guilds.fetch('928018226330337280')).channels.fetch('948690278498320404') as TextChannel + if (request === db!.id) return + else { + db!.id = request + await db?.save() + const embed = new EmbedBuilder() + .setAuthor({name: 'Mara Turing', iconURL: 'https://yt3.ggpht.com/ytc/AMLnZu8rf3ZxWKKv9Dr6UjmWiDuKkaK06J5lDZ8WwwCg=s88-c-k-c0x00ffffff-no-rj'}) + .setColor('Random') + .setTitle(`${noembed.title}`) + .setURL('https://youtu.be/' + request) + .setImage(`${noembed.thumbnail_url}`) + const message = await fetchTextChannel.send({content: 'Nuevo vídeo de Mara Turing, corre a verlo!', embeds: [embed]}) + message.react('<:Pog:1030169609178976346>') + } +} \ No newline at end of file