-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
andrewstech
committed
Oct 22, 2023
1 parent
4578adc
commit ede779d
Showing
6 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const { SlashCommandBuilder } = require("discord.js"); | ||
const regiserDomain = require("../events/buttons/registerDomain"); | ||
|
||
module.exports = { | ||
data: new SlashCommandBuilder() | ||
.setName("register") | ||
.setDescription("Register a domain."), | ||
async execute(interaction) { | ||
await regiserDomain(interaction); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const Loading = require('../../components/loading'); | ||
const { EmbedBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder } = require('discord.js'); | ||
module.exports = async function (interaction) { | ||
const register = new ModalBuilder().setTitle('Register a Domain').setCustomId('regiserDomain') | ||
|
||
const domainCheck = new TextInputBuilder() | ||
.setCustomId('DomainCheck') | ||
.setPlaceholder('Enter a subdomain') | ||
.setMinLength(3) | ||
.setMaxLength(100) | ||
.setRequired(true) | ||
.setLabel('Enter the subdomain you want to register') | ||
.setStyle("Short"); | ||
|
||
|
||
const row = new ActionRowBuilder().addComponents(domainCheck); | ||
register.addComponents(row); | ||
await interaction.showModal(register); | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const RegisterDomain = require('./modals/RegisterDomain'); | ||
module.exports = async function (interaction) { | ||
if (interaction.customId === "regiserDomain") { | ||
await RegisterDomain(interaction); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const Loading = require('../../components/loading'); | ||
const { EmbedBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); | ||
module.exports = async function (interaction) { | ||
await Loading(interaction, true); | ||
const subdomain = interaction.fields.getTextInputValue("DomainCheck"); | ||
const response = await fetch( | ||
`https://api.github.com/repos/is-a-dev/register/contents/domains/${subdomain}.json`, | ||
{ | ||
headers: { | ||
"User-Agent": "is-a-dev-bot", | ||
}, | ||
cache: "no-cache", | ||
}, | ||
); | ||
|
||
if (response.status === 404) { | ||
const embed = new EmbedBuilder() | ||
// domain is available | ||
.setDescription(`Congratulations, ${subdomain}.is-a.dev is available!`) | ||
.setColor("#0096ff"); | ||
const button = new ButtonBuilder() | ||
.setCustomId(`register-${subdomain}`) | ||
.setLabel("Register IT") | ||
.setStyle(ButtonStyle.Primary); | ||
|
||
const row = new ActionRowBuilder().addComponents(button); | ||
await interaction.editReply({ | ||
components: [row], | ||
ephemeral: true, | ||
embeds: [embed] | ||
}); | ||
} else { | ||
const sadEmbed = new EmbedBuilder() | ||
// domain is taken | ||
.setDescription(`Sorry, ${subdomain}.is-a.dev is taken!`) | ||
.setColor("#0096ff"); | ||
|
||
const tryagin = new ButtonBuilder() | ||
.setCustomId(`tryagain`) | ||
.setLabel("Try Again") | ||
.setStyle(ButtonStyle.Primary); | ||
|
||
const sadrow = new ActionRowBuilder().addComponents(tryagin); | ||
await interaction.editReply({ | ||
components: [sadrow], | ||
ephemeral: true, | ||
embeds: [sadEmbed] | ||
}); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters