-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from jmhayes3/feature/command-embeddings
use embeddings in command replies
- Loading branch information
Showing
10 changed files
with
330 additions
and
36 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,22 @@ | ||
import Keyv from 'keyv'; | ||
import KeyvRedis from '@keyv/redis'; | ||
|
||
const keyvRedis = new KeyvRedis('redis://127.0.0.1:6379'); | ||
console.log(keyvRedis); | ||
|
||
const cache = new Keyv({ store: keyvRedis, namespace: 'cache' }); | ||
console.log(cache); | ||
|
||
const users = new Keyv(new KeyvRedis('redis://localhost:6379'), { namespace: 'users' }); | ||
console.log(users); | ||
|
||
await users.set("foo", "bar"); | ||
console.log(await users.get('foo')); | ||
|
||
await cache.set('testing', false); | ||
await cache.set('foo', 'foobar'); | ||
await cache.set('bar', 'barfoo'); | ||
console.log(await cache.get('testing')); | ||
console.log(await cache.get('foo')); | ||
console.log(await cache.get('bar')); | ||
await cache.clear(); |
This file was deleted.
Oops, something went wrong.
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,38 @@ | ||
import { SlashCommandBuilder, EmbedBuilder } from 'discord.js'; | ||
|
||
export const data = new SlashCommandBuilder().setName('role').setDescription('Display role info').addRoleOption(option => option.setName('role').setDescription("The role you want to get the info of").setRequired(true)); | ||
|
||
export async function execute(interaction) { | ||
const { options } = interaction; | ||
|
||
const role = options.getRole('role'); | ||
|
||
if (!role || !role.id) return interaction.reply({ content: `That role **doesn't** seem to exist in ${interaction.guild.name}`, ephemeral: true }); | ||
if (role.name === "@everyone") return interaction.reply({ content: `You **cannot** get the info of the \`\`@everyone\`\``, ephemeral: true }); | ||
if (role.name === "@here") return interaction.reply({ content: `You **cannot** get the info of the \`\`@here\`\``, ephemeral: true }); | ||
|
||
const created = parseInt(role.createdTimestamp / 1000); | ||
const isMentionable = role.isMentionable ? "true" : "false"; | ||
const isManaged = role.isManaged ? "true" : "false"; | ||
const isHigher = role.isHigher ? "true" : "false"; | ||
const position = role.position; | ||
const isBotRole = role.isBotRole ? "true" : "false"; | ||
|
||
const roleEmbed = new EmbedBuilder() | ||
.setColor(role.color) | ||
.setTitle("Role info") | ||
.addFields( | ||
{ name: "Name", value: `> ${role.name}` }, | ||
{ name: "Color", value: `> ${role.hexColor}` }, | ||
{ name: "Mention", value: `> @${role.name}` }, | ||
{ name: "Hoisted", value: `> ${isHigher}` }, | ||
{ name: "Position", value: `> ${position}` }, | ||
{ name: "Mentionable", value: `> ${isMentionable}` }, | ||
{ name: "Managed", value: `> ${isManaged}` }, | ||
{ name: "Bot", value: `> ${isBotRole}` }, | ||
{ name: "Created", value: `> <t:${created}:R>` }) | ||
.setFooter({ text: `Role ID: ${role.id}` }) | ||
.setThumbnail(role.iconURL()); | ||
|
||
await interaction.reply({ embeds: [roleEmbed], ephemeral: true }) | ||
} |
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,27 @@ | ||
import { SlashCommandBuilder, EmbedBuilder } from 'discord.js'; | ||
|
||
export const data = new SlashCommandBuilder().setName('server').setDescription('Display server info'); | ||
|
||
export async function execute(interaction) { | ||
if (!interaction.isChatInputCommand()) return; | ||
|
||
await interaction.deferReply({ ephemeral: true }); | ||
|
||
const server = interaction.guild; | ||
const members = interaction.guild.memberCount; | ||
const created = parseInt(interaction.guild.createdTimestamp / 1000); | ||
|
||
const serverEmbed = new EmbedBuilder() | ||
.setColor('#777777') | ||
.setTitle("Server info") | ||
.addFields( | ||
{ name: "Name", value: `> ${server.name}` }, | ||
{ name: "Members", value: `> ${members}` }, | ||
{ name: "Owner ID", value: `> ${server.ownerId}` }, | ||
{ name: "Created", value: `> <t:${created}:R>` }) | ||
.setFooter({ text: `Server ID: ${server.id}` }) | ||
.setThumbnail(server.iconURL()) | ||
|
||
const reply = { embeds: [serverEmbed], ephemeral: true }; | ||
await interaction.followUp(reply); | ||
}; |
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,26 @@ | ||
import { SlashCommandBuilder, EmbedBuilder } from 'discord.js'; | ||
|
||
export const data = new SlashCommandBuilder().setName('user').setDescription('Display user info'); | ||
|
||
export async function execute(interaction) { | ||
if (!interaction.isChatInputCommand()) return; | ||
|
||
await interaction.deferReply({ ephemeral: true }); | ||
|
||
const user = interaction.user; | ||
const created = parseInt(interaction.user.createdTimestamp / 1000); | ||
|
||
const userEmbed = new EmbedBuilder() | ||
.setColor('#195ece') | ||
.setTitle("User info") | ||
.addFields( | ||
{ name: "Username", value: `> ${user.username}` }, | ||
{ name: "Joined", value: `> <t:${created}:R>` }) | ||
.setFooter({ text: `User ID: ${user.id}` }) | ||
.setThumbnail(user.displayAvatarURL()); | ||
|
||
const reply = { embeds: [userEmbed], ephemeral: true }; | ||
console.log(reply); | ||
|
||
await interaction.followUp(reply); | ||
}; |
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,26 @@ | ||
import { ContextMenuCommandBuilder, ApplicationCommandType, EmbedBuilder } from 'discord.js'; | ||
|
||
export const data = new ContextMenuCommandBuilder().setName('User Info').setType(ApplicationCommandType.User); | ||
|
||
export async function execute(interaction) { | ||
if (!interaction.isUserContextMenuCommand()) return; | ||
|
||
await interaction.deferReply({ ephemeral: true }); | ||
|
||
const user = interaction.user; | ||
const created = parseInt(interaction.user.createdTimestamp / 1000); | ||
|
||
const userContextMenuEmbed = new EmbedBuilder() | ||
.setColor('#195ece') | ||
.setTitle("User info") | ||
.addFields( | ||
{ name: "Username", value: `> ${user.username}` }, | ||
{ name: "Joined", value: `> <t:${created}:R>` }) | ||
.setFooter({ text: `User ID: ${user.id}` }) | ||
.setThumbnail(user.displayAvatarURL()); | ||
|
||
const reply = { embeds: [userContextMenuEmbed], ephemeral: true }; | ||
console.log(reply); | ||
|
||
await interaction.followUp(reply); | ||
}; |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.