Skip to content

Commit

Permalink
Merge pull request #4 from dorasto/oauth
Browse files Browse the repository at this point in the history
Oauth
  • Loading branch information
trent-001 authored Feb 26, 2025
2 parents 0290710 + 00e6d69 commit 4283760
Show file tree
Hide file tree
Showing 7 changed files with 572 additions and 46 deletions.
63 changes: 63 additions & 0 deletions commands/authenticate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import {
ChatInputCommandInteraction,
PermissionsBitField,
SlashCommandBuilder,
EmbedBuilder,
ButtonBuilder,
ButtonStyle,
} from "discord.js";

export default {
data: new SlashCommandBuilder()
.setName("authenticate")
.setDescription("Connect your Doras account")
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator),
cooldown: 3,
async execute(inter: ChatInputCommandInteraction) {
try {
await inter.deferReply({
ephemeral: true,
});

if (!inter.guildId) {
await inter.editReply({
content: "This command can only be used in a server.",
});
return;
}

// Authentication Link
const authUrl = process.env.SERVER_URL + "/auth/login";

// Create Embed
const embed = new EmbedBuilder()
.setTitle("Authenticate")
.setDescription(
"Click the button below to authenticate your Doras account."
);

// Create Button
const authButton = new ButtonBuilder()
.setLabel("Connect Your Account")
.setURL(authUrl)
.setStyle(ButtonStyle.Link); // ButtonStyle.Link makes it a clickable link

// Send Embed and Button
await inter.editReply({
embeds: [embed],
// components: [
// {
// type: 1, // Action Row
// components: [authButton],
// },
// ],
});
return;
} catch (error) {
console.error("Error executing authenticate command:", error);
await inter.editReply({
content: "There was an error executing the command.",
});
}
},
};
8 changes: 8 additions & 0 deletions db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,11 @@ export const discordBotServer = pgTable("discord_bot_server", {
roles: jsonb("roles").default([]),
created_at: timestamp("created_at").defaultNow().notNull(),
});

export const userServerAccess = pgTable("user_server_access", {
id: uuid("id").primaryKey().notNull(), // Unique identifier for each user record
discord_user_id: text("discord_user_id").notNull().unique(), // The user's Discord ID
discord_username: text("discord_username").notNull(), // The user's Discord username
servers: jsonb("servers").default([]), // An array of servers the user is part of (JSONB type)
created_at: timestamp("created_at").defaultNow().notNull(), // Timestamp of when the user record was created
});
27 changes: 20 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import { readdirSync } from "fs";
import { join } from "path";
import { db } from "./db";
import * as schema from "./db/schema";
import { ITwitch, IYoutubeLatest, IYoutubeLive } from "./types";
import {
ITwitch,
IYoutubeLatest,
IYoutubeLatestShort,
IYoutubeLive,
} from "./types";
import { eq } from "drizzle-orm";
import cron from "node-cron";
export const AddButtonDataTwitch = new Map();
Expand Down Expand Up @@ -200,7 +205,9 @@ const twitchLiveEmbeds = async (item: ITwitch, index: number) => {
new ButtonBuilder()
.setLabel("Social Links")
.setStyle(ButtonStyle.Link)
.setURL(item.social_link_url || "")) ||
.setURL(
"https://doras.to/" + item.social_link_url || ""
)) ||
"";
if (item.social_links && item.social_link_url)
buttonLinks && row.addComponents(buttonLinks);
Expand Down Expand Up @@ -530,7 +537,9 @@ const youtubeLiveEmbeds = async (item: IYoutubeLive, index: number) => {
new ButtonBuilder()
.setLabel("Social Links")
.setStyle(ButtonStyle.Link)
.setURL(item.social_link_url || "")) ||
.setURL(
"https://doras.to/" + item.social_link_url || ""
)) ||
"";
if (item.social_links && item.social_link_url)
buttonLinks && row.addComponents(buttonLinks);
Expand Down Expand Up @@ -692,7 +701,7 @@ const youtubeLatestEmbeds = async (item: IYoutubeLatest, index: number) => {
fields: [
{
name: "Views",
value: dataLatest?.views,
value: dataLatest?.views || "0",
inline: true,
},
{
Expand Down Expand Up @@ -728,7 +737,9 @@ const youtubeLatestEmbeds = async (item: IYoutubeLatest, index: number) => {
new ButtonBuilder()
.setLabel("Social Links")
.setStyle(ButtonStyle.Link)
.setURL(item.social_link_url || "")) ||
.setURL(
"https://doras.to/" + item.social_link_url || ""
)) ||
"";
if (item.social_links && item.social_link_url)
buttonLinks && row.addComponents(buttonLinks);
Expand All @@ -754,7 +765,7 @@ const youtubeLatestEmbeds = async (item: IYoutubeLatest, index: number) => {
}
};
const youtubeLatestShortEmbeds = async (
item: IYoutubeLatest,
item: IYoutubeLatestShort,
index: number
) => {
item.username = item.username.replace("@", "");
Expand Down Expand Up @@ -830,7 +841,9 @@ const youtubeLatestShortEmbeds = async (
new ButtonBuilder()
.setLabel("Social Links")
.setStyle(ButtonStyle.Link)
.setURL(item.social_link_url || "")) ||
.setURL(
"https://doras.to/" + item.social_link_url || ""
)) ||
"";
if (item.social_links && item.social_link_url)
buttonLinks && row.addComponents(buttonLinks);
Expand Down
135 changes: 135 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<!DOCTYPE html>
<html lang="en" class="dark">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description"
content="Welcome to the Doras.to Discord Bot - Integrate Twitch Live, YouTube Live, YouTube Latest, and YouTube Shorts Latest directly into your Discord server with embeds." />
<meta name="keywords"
content="discord bot, Doras.to Discord Bot, Twitch Live, YouTube Live, YouTube Latest, YouTube Shorts, Discord embeds, link shortening, analytics" />
<meta name="author" content="doras.to" />
<meta name="robots" content="index, follow" />

<!-- Open Graph meta tags for social media -->
<meta property="og:title" content="Welcome to the Doras.to Discord Bot" />
<meta property="og:description"
content="Integrate Twitch Live, YouTube Live, YouTube Latest, and YouTube Shorts Latest directly into your Discord server with Doras.to's embeds." />
<meta property="og:image" content="/favicon.ico" />
<meta property="og:url" content="https://discord.doras.to" />
<meta property="og:type" content="website" />

<!-- Twitter meta tags for Twitter Cards -->
<meta name="twitter:title" content="Welcome to the Doras.to Discord Bot" />
<meta name="twitter:description"
content="Integrate Twitch Live, YouTube Live, YouTube Latest, and YouTube Shorts Latest directly into your Discord server with Doras.to's embeds." />
<meta name="twitter:image" content="/favicon.ico" />
<meta name="twitter:card" content="summary_large_image" />

<title>Welcome to the Doras.to Discord Bot</title>
<style>
:root {
--background: 0 0% 6.27%;
--foreground: 0 0% 98.04%;
--card: 0 0% 8%;
--card-foreground: 0 0% 98.04%;
--popover: 0 0% 12.16%;
--popover-foreground: 0 0% 98.04%;
--muted: 0 0% 14.9%;
--muted-foreground: 0 0% 65.1%;
--accent: 0 0% 18.82%;
--accent-foreground: 0 0% 98.04%;
--success: 120 56.52% 54.9%;
--destructive: 2.77 56.52% 54.9%;
--border: 0 0% 14.51%;
--input: 2.77 56.52% 54.9%;
--primary: 2.77 56.52% 54.9%;
--primary-foreground: 0 0% 98.04%;
}

body {
background-color: hsl(var(--background));
color: hsl(var(--foreground));
font-family: "Montserrat Variable", sans-serif;
text-align: center;
padding: 50px;
}

.logo {
width: 150px;
margin-bottom: 30px;
}

h1 {
font-size: 50px;
color: hsl(var(--primary));
margin-bottom: 20px;
}

p {
font-size: 18px;
color: hsl(var(--muted-foreground));
}

.container {
max-width: 500px;
margin: 0 auto;
background-color: hsl(var(--card));
padding: 40px;
border-radius: 10px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

a {
color: hsl(var(--primary));
text-decoration: none;
}

a:hover {
text-decoration: underline;
}

.features {
margin-top: 30px;
font-size: 18px;
text-align: left;
}

.feature-item {
margin: 10px 0;
}
</style>
</head>

<body>
<div class="container">
<img src="favicon.ico" alt="Doras.to Bot Logo" class="logo" />
<h1>Welcome to the Doras.to Discord Bot!</h1>

<ul class="features">
<li>🚨 <strong>Twitch Live Streams</strong>: Get live Twitch notifications directly in your Discord server.
</li>
<li>📺 <strong>YouTube Live Streams</strong>: Stay updated with YouTube Live streams, right in Discord.</li>
<li>🎬 <strong>Latest YouTube Videos</strong>: View the latest videos from YouTube, embedded in your server.
</li>
<li>📱 <strong>YouTube Shorts Latest</strong>: See the latest YouTube Shorts in your Discord server.</li>
</ul>

<p>
For live stream announcements, you can choose whether the announcement should disappear when the stream
ends,
or if it should change its URL to the VOD (Video on Demand) once the stream is over.
</p>

<p>
You also have full control over where the announcements are posted and the ability to customize the alert
messages!
</p>

<p>To add the bot to your server, click the link below:</p>
<p><a href="https://discord.com/oauth2/authorize?client_id=1178674222873198612" target="_blank">Add Doras.to Bot
to your server</a></p>
</div>
</body>

</html>
Loading

0 comments on commit 4283760

Please sign in to comment.