Skip to content

Commit

Permalink
byod
Browse files Browse the repository at this point in the history
  • Loading branch information
skysthelimitt committed Mar 28, 2024
1 parent e00850c commit 5a8ce0b
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 27 deletions.
1 change: 1 addition & 0 deletions commands/fun/dice.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { EmbedBuilder } = require("discord.js");
const { SlashCommandBuilder } = require("discord.js");
const { runAI } = require("../../utils")

module.exports = {
data: new SlashCommandBuilder()
Expand Down
17 changes: 17 additions & 0 deletions commands/selenite/createBYOD.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder, SlashCommandBuilder, PermissionsBitField } = require("discord.js");

module.exports = {
data: new SlashCommandBuilder().setName("createbyodembed").setDescription("dev command"),
async execute(interaction) {
if (interaction.isChatInputCommand() && interaction.channel.permissionsFor(interaction.user).has(PermissionsBitField.Flags.ManageGuild)) {
let byodEmbed = new EmbedBuilder().setTitle("Bring Your Own Domain").setDescription("Do you wish you could just create your own domain without the hassle of hosting it yourself?\n\nBring Your Own Domain allows you to simply create a domain using any service, point it to us, and we'll host it for you!");
const link = new ButtonBuilder().setCustomId('byodA').setLabel('Click here to start!').setStyle(ButtonStyle.Primary);
const button = new ActionRowBuilder().addComponents(link);
await interaction.channel.send(
{ embeds: [byodEmbed],
components: [button],
}
);
}
},
};
49 changes: 24 additions & 25 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { Client, Collection, GatewayIntentBits, Events, EmbedBuilder } = require(
const { token, widgets, logs_channel, links, dispenser_logs } = require("./config.json");
const client = new Client({ intents: ["Guilds", "GuildMessages", "GuildMembers", "MessageContent"], allowedMentions: { everyone: [false], roles: [false] } });
const Sequelize = require("sequelize");
const { byod } = require("./utils");
const level = new Sequelize("database", "user", "password", {
host: "localhost",
dialect: "sqlite",
Expand Down Expand Up @@ -104,39 +105,32 @@ client.login(token);
client.on("messageDelete", (message) => {
const logsChannel = client.channels.cache.get(logs_channel.toString());

const delEmbed = new EmbedBuilder()
delEmbed.setColor("#db3c30")
delEmbed.setTitle("🗑️ message deleted")
delEmbed.setDescription(
`> **author:** <@${message.author.id}> \n> **channel:** <#${message.channel.id}> \n> **timestamp:** <t:${Math.floor(Date.now() / 1000)}:R> `
);
const delEmbed = new EmbedBuilder();
delEmbed.setColor("#db3c30");
delEmbed.setTitle("🗑️ message deleted");
delEmbed.setDescription(`> **author:** <@${message.author.id}> \n> **channel:** <#${message.channel.id}> \n> **timestamp:** <t:${Math.floor(Date.now() / 1000)}:R> `);

if (message.content) {
delEmbed.addFields({name: 'message:', value: message.content});
}
if (message.content) {
delEmbed.addFields({ name: "message:", value: message.content });
}

// extra thing here to check if message has attachments
if (message.attachments.size > 0) {
const attachments = message.attachments.map((attachment) => attachment.url);
delEmbed.addFields({name: "attached:", value: attachments.join("\n")});
}
// extra thing here to check if message has attachments
if (message.attachments.size > 0) {
const attachments = message.attachments.map((attachment) => attachment.url);
delEmbed.addFields({ name: "attached:", value: attachments.join("\n") });
}

logsChannel.send({ embeds: [delEmbed] });
logsChannel.send({ embeds: [delEmbed] });
});
client.on("messageUpdate", (oldm, newm) => {
const logsChannel = client.channels.cache.get(logs_channel.toString());
if (oldm !== newm) {
const ediEmbed = new EmbedBuilder()
ediEmbed.setColor("#e2e833")
ediEmbed.setTitle("✍️ message edited")
ediEmbed.setDescription(
`> **author:** <@${oldm.author.id}> \n> **channel:** <#${oldm.channel.id}> \n> **timestamp:** <t:${Math.floor(Date.now() / 1000)}:R> `
);
const ediEmbed = new EmbedBuilder();
ediEmbed.setColor("#e2e833");
ediEmbed.setTitle("✍️ message edited");
ediEmbed.setDescription(`> **author:** <@${oldm.author.id}> \n> **channel:** <#${oldm.channel.id}> \n> **timestamp:** <t:${Math.floor(Date.now() / 1000)}:R> `);

ediEmbed.addFields(
{name: 'before:', value: `${oldm}`, inline: true},
{name: 'after:', value: `${newm}`, inline: true},
);
ediEmbed.addFields({ name: "before:", value: `${oldm}`, inline: true }, { name: "after:", value: `${newm}`, inline: true });

logsChannel.send({ embeds: [ediEmbed] });
}
Expand Down Expand Up @@ -172,5 +166,10 @@ client.on("interactionCreate", async (interaction) => {
return;
}
}
if(interaction.customId.includes("byod")) {
byod(interaction);
}
} else if (interaction.isModalSubmit()) {
byod(interaction);
}
});
91 changes: 91 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dependencies": {
"@2toad/profanity": "^2.2.0",
"@google/generative-ai": "^0.3.0",
"axios": "^1.6.8",
"bad-words-next": "^2.2.1",
"discord.js": "^14.12.1",
"sequelize": "^6.34.0",
Expand Down
50 changes: 48 additions & 2 deletions utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { EmbedBuilder } = require("discord.js");
const { EmbedBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
const { ai_key, logs_channel } = require("./config.json");
const { GoogleGenerativeAI } = require("@google/generative-ai");
const axios = require("axios");

async function runAI(interaction, freaky) {
try {
Expand Down Expand Up @@ -35,4 +36,49 @@ async function runAI(interaction, freaky) {

}

module.exports = { runAI }

async function byod(interaction) {
if(interaction.isModalSubmit()) {
if(interaction.fields.getTextInputValue("byodB_Input")) {
await interaction.reply({ content: 'Thank you! We are currently checking to see if it is valid.', ephemeral: true });
const url = 'http://localhost:5674/add';
const data = { domain: interaction.fields.getTextInputValue("byodB_Input") };
try {
const response = await axios.post(url, data, {
headers: {
'Content-Type': 'application/json'
}
});
reason = "**Congrats!**\nYou have successfully created your own link.\nYou may post it to community links if you'd like, or just continue.";
} catch (error) {
if (error.response) {
reason = error.response.data;
} else if (error.request) {
reason = 'No response received\nmajor fuck up, should never happen. dm @skysthelimit.dev';
} else {
reason = 'no response\nis the api down? dm @skysthelimit.dev'
}
}
await interaction.followUp({content: reason, ephemeral: true});
}
}
if (interaction.customId === "byodA") {
let byodEmbed = new EmbedBuilder().setTitle("Bring Your Own Domain").setDescription("Before we begin, let's make sure you have a domain set up!\nThis may vary across whatever you're using.\n\n").addFields({ name: "FreeDNS", value: "This assumes that you've already found a link that you like.\nOnce you are on the link creating page, make sure the type is A, and that you set the destination to \"5.161.118.69\". After you're done, click Continue.", inline: true }, { name: "Cloudflare", value: 'This assumes you already have already bought a domain.\nGo into the DNS settings, and add a new record. If you want it on the top level (for example, selenite.cc), then set Name to @, but if you want it to be on a subdomain (for example, selenite.skys.day), then set Name to the subdomain you want (if my domain is skys.day and I wanted to have Selenite on selenite.skys.day, set name to selenite). Set the IPv4 address to "5.161.118.69", and make sure Proxy status is set to DNS Only, and **NOT** Proxied. Click Save.', inline: true }, { name: "\n", value: "**Once you're done, then wait a few minutes to make sure everything is saved and working, and click Continue.**\n**To submit a domain, please type it without any slashes or anything other than the domain. If you created a link such as \"https://selenite.cc/projects.html\", please only type \"selenite.cc\".**" });
const link = new ButtonBuilder().setCustomId("byodB").setLabel("Continue").setStyle(ButtonStyle.Primary);
const button = new ActionRowBuilder().addComponents(link);
await interaction.reply({ embeds: [byodEmbed], components: [button], ephemeral: true });
} else if (interaction.customId === "byodB") {
const modal = new ModalBuilder().setCustomId("byodModal").setTitle("Bring Your Own Domain");

const byodInput = new TextInputBuilder()
.setCustomId("byodB_Input")
.setMaxLength(70)
.setMinLength(5)
.setLabel("Insert your link below")
.setStyle(TextInputStyle.Short);
const firstActionRow = new ActionRowBuilder().addComponents(byodInput);
modal.addComponents(firstActionRow);
await interaction.showModal(modal);
}
}
module.exports = { runAI, byod }

0 comments on commit 5a8ce0b

Please sign in to comment.