first commit
This commit is contained in:
parent
26621c9866
commit
e895ff8fbd
@ -1,4 +1,4 @@
|
|||||||
# Discord-Linux Discord.JS v14 Base Template
|
# WTTR BOT
|
||||||
|
|
||||||
Only 3 dependencies required to run this bot!
|
Only 3 dependencies required to run this bot!
|
||||||
|
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
const { EmbedBuilder } = require('discord.js');
|
|
||||||
const { ActionRowBuilder, ModalBuilder, TextInputBuilder, TextInputStyle } = require('discord.js');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
name: "modal-example",
|
|
||||||
description: "Show a demo modal!",
|
|
||||||
|
|
||||||
run: async (client, interaction) => {
|
|
||||||
|
|
||||||
// Declare a random var for the main modal - Each Session
|
|
||||||
let rand = Math.floor(Math.random() * 99999999999999).toString();
|
|
||||||
|
|
||||||
// Check if this is a chatInput
|
|
||||||
if (!interaction.isChatInputCommand()) return;
|
|
||||||
|
|
||||||
// await interaction.deferReply();
|
|
||||||
const modal = new ModalBuilder()
|
|
||||||
.setCustomId(rand)
|
|
||||||
.setTitle('This is an example modal');
|
|
||||||
|
|
||||||
// TODO: Add components to modal...
|
|
||||||
const modalInputData = new TextInputBuilder()
|
|
||||||
.setCustomId('modalInput')
|
|
||||||
// The label is the prompt the user sees for this input
|
|
||||||
.setLabel("What text do you want to send?")
|
|
||||||
// Short means only a single line of text
|
|
||||||
.setStyle(TextInputStyle.Paragraph);
|
|
||||||
|
|
||||||
// An action row only holds one text input,
|
|
||||||
// so you need one action row per text input.
|
|
||||||
const modalInputRow = new ActionRowBuilder().addComponents([modalInputData]);
|
|
||||||
|
|
||||||
// Add inputs to the modal
|
|
||||||
modal.addComponents([modalInputRow]);
|
|
||||||
|
|
||||||
await interaction.showModal(modal);
|
|
||||||
|
|
||||||
client.on('interactionCreate', interaction => {
|
|
||||||
|
|
||||||
// Do not continue if its a modal
|
|
||||||
if (interaction.type == "modal") return
|
|
||||||
// Interaction type is 5 == Modal
|
|
||||||
if (interaction.type === 5) {
|
|
||||||
|
|
||||||
// Make sure we are working with our users modal only
|
|
||||||
if (interaction.customId === rand) {
|
|
||||||
|
|
||||||
// Get the data entered by the user
|
|
||||||
let modalInputDataString = interaction.fields.getTextInputValue('modalInput');
|
|
||||||
|
|
||||||
console.log(modalInputDataString)
|
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
|
||||||
// Set color to blue
|
|
||||||
.setColor("#FF0000")
|
|
||||||
.setTitle("Your input!")
|
|
||||||
.setDescription(`You said: ${modalInputDataString}`)
|
|
||||||
.setTimestamp()
|
|
||||||
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
|
|
||||||
interaction.reply({ embeds: [embed] });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +1,25 @@
|
|||||||
const { EmbedBuilder } = require('discord.js');
|
const { EmbedBuilder } = require('discord.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: "ping",
|
name: "weather",
|
||||||
private: true,
|
description: "Get the weather for a location",
|
||||||
description: "Returns websocket latency",
|
private: false,
|
||||||
|
options: [{
|
||||||
|
name: "location",
|
||||||
|
description: "The data you would like inside of the QR",
|
||||||
|
required: true,
|
||||||
|
type: 3 // 6 is type USER
|
||||||
|
}],
|
||||||
run: async (client, interaction) => {
|
run: async (client, interaction) => {
|
||||||
|
let encodedLocation = encodeURIComponent(interaction.options._hoistedOptions[0].value);
|
||||||
|
let location = interaction.options._hoistedOptions[0].value;
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor("#FF0000")
|
.setColor("#FF0000")
|
||||||
.setTitle("🏓 Pong!")
|
.setTitle(`The weather for: ${location}`)
|
||||||
.setDescription(`Latency : ${client.ws.ping}ms`)
|
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
|
.setImage(`https://wttr.in/${encodedLocation}.png`)
|
||||||
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
|
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
|
||||||
interaction.followUp({ embeds: [embed] });
|
await interaction.editReply({ embeds: [embed] });
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
const { EmbedBuilder } = require('discord.js');
|
|
||||||
const {ApplicationCommandType } = require('discord.js');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
name: "ping-test",
|
|
||||||
type: ApplicationCommandType.Message,
|
|
||||||
run: async (client, interaction) => {
|
|
||||||
const embed = new EmbedBuilder()
|
|
||||||
.setColor("#FF0000")
|
|
||||||
.setTitle("🏓 Pong!")
|
|
||||||
.setDescription(`Latency : ${client.ws.ping}ms`)
|
|
||||||
.setTimestamp()
|
|
||||||
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
|
|
||||||
interaction.followUp({ embeds: [embed] });
|
|
||||||
},
|
|
||||||
};
|
|
Loading…
Reference in New Issue
Block a user