Alexcitten
Alexcitten
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by Alexcitten on 11/26/2023 in #djs-questions
File Attachment
How do I attach my attachment in the embed after rank.build(), given that this embed is needed for my my-karma.js command? I mean when my command is called, it calls an embed from another file where everything is very connected. my-karma.js:
const { SlashCommandBuilder } = require("discord.js");
const { getMemberTotalKarma } = require("../../modules/member");

module.exports = {
data: new SlashCommandBuilder().setName("my-karma").setDescription("meow"),
async execute(interaction) {
await interaction.deferReply({
fetchReply: true,
deferReply: true,
})

const embed = await getMemberTotalKarma(interaction.member);

await interaction.editReply({
embeds: [embed]
})
}
}
const { SlashCommandBuilder } = require("discord.js");
const { getMemberTotalKarma } = require("../../modules/member");

module.exports = {
data: new SlashCommandBuilder().setName("my-karma").setDescription("meow"),
async execute(interaction) {
await interaction.deferReply({
fetchReply: true,
deferReply: true,
})

const embed = await getMemberTotalKarma(interaction.member);

await interaction.editReply({
embeds: [embed]
})
}
}
src/modules/member/controller.js:
...
const getMemberTotalKarma = async (memberDiscordId, interaction) => {
try {
...
if (gradationValue && gradationRole) {
await interaction.deferReply({
fetchReply: true,
deferReply: true,
})
...
const rank = new canvacord.Rank()
.setAvatar(img)
.setCurrentXP(karma)
.setRequiredXP(karmaNeededForNextRole)
.setProgressBar("#e523ff")
.setUsername(memberDiscordId.user.username)
.renderEmojis(true)
.setRank(karma, "kR", true)

rank.build()
.then(async buffer => {
const attachment = new AttachmentBuilder(buffer, { name: 'rank.png' })
return new EmbedBuilder()
.setColor(colors.primary)
.setDescription(`meow`)
.setImage(`attachment://${attachment.name}`);
});
}
return new EmbedBuilder().setColor(colors.primary).setDescription(`meow2`);
} catch (error) {
console.log(error);
return new EmbedBuilder().setColor(colors.danger).setDescription(`error`);
}
}
...
...
const getMemberTotalKarma = async (memberDiscordId, interaction) => {
try {
...
if (gradationValue && gradationRole) {
await interaction.deferReply({
fetchReply: true,
deferReply: true,
})
...
const rank = new canvacord.Rank()
.setAvatar(img)
.setCurrentXP(karma)
.setRequiredXP(karmaNeededForNextRole)
.setProgressBar("#e523ff")
.setUsername(memberDiscordId.user.username)
.renderEmojis(true)
.setRank(karma, "kR", true)

rank.build()
.then(async buffer => {
const attachment = new AttachmentBuilder(buffer, { name: 'rank.png' })
return new EmbedBuilder()
.setColor(colors.primary)
.setDescription(`meow`)
.setImage(`attachment://${attachment.name}`);
});
}
return new EmbedBuilder().setColor(colors.primary).setDescription(`meow2`);
} catch (error) {
console.log(error);
return new EmbedBuilder().setColor(colors.danger).setDescription(`error`);
}
}
...
3 replies
DIAdiscord.js - Imagine an app
Created by Alexcitten on 1/16/2023 in #djs-questions
Checking bot permissions in a channel
Do it with permissions.has()?
6 replies
DIAdiscord.js - Imagine an app
Created by Alexcitten on 1/14/2023 in #djs-questions
The button collector is not working, I'm doing something wrong
Code:
if (usdPricePerByteFormatted === 0) {
const confirmEmbedZero = new EmbedBuilder()
. . .

const yesZero = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel('Yes')
.setCustomId('yeschannel')
.setStyle(ButtonStyle.Success)
)
const noZero = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel('No')
.setCustomId('nochannel')
.setStyle(ButtonStyle.Danger)
)
return interaction.editReply({
embeds: [confirmEmbedZero],
ephemeral: true,
components: [yesZero, noZero]
})
}

const filter = i => i.customId === 'yeschannel' && i.user.id === interaction.user.id;
const collector = interaction.channel.createMessageComponentCollector({ filter })

collector.on("collect", async i => {
console.log('yea!!')
})
collector.on('end', collected => {
console.log(`Collected ${collected.size} items`);
});
if (usdPricePerByteFormatted === 0) {
const confirmEmbedZero = new EmbedBuilder()
. . .

const yesZero = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel('Yes')
.setCustomId('yeschannel')
.setStyle(ButtonStyle.Success)
)
const noZero = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel('No')
.setCustomId('nochannel')
.setStyle(ButtonStyle.Danger)
)
return interaction.editReply({
embeds: [confirmEmbedZero],
ephemeral: true,
components: [yesZero, noZero]
})
}

const filter = i => i.customId === 'yeschannel' && i.user.id === interaction.user.id;
const collector = interaction.channel.createMessageComponentCollector({ filter })

collector.on("collect", async i => {
console.log('yea!!')
})
collector.on('end', collected => {
console.log(`Collected ${collected.size} items`);
});
I do it in command file, not in interactionCreate
4 replies
DIAdiscord.js - Imagine an app
Created by Alexcitten on 1/9/2023 in #djs-questions
Get all messages in channel
6 replies
DIAdiscord.js - Imagine an app
Created by Alexcitten on 12/17/2022 in #djs-questions
Many slash commands with the same beginning
I want to make commands that start with the same name but have different sub-commands. Is this only possible via SlashCommandBuilder()? For my code structure is now
module.exports = {
name: "commandname",
category: "test",
options: [
{
name: 'namesubcommand',
description: 'description',
type: 1,
options: [
{
name: 'optionname',
description: 'second description',
type: 3,
required: true
}
]
}
],
. . .
module.exports = {
name: "commandname",
category: "test",
options: [
{
name: 'namesubcommand',
description: 'description',
type: 1,
options: [
{
name: 'optionname',
description: 'second description',
type: 3,
required: true
}
]
}
],
. . .
And with the same command names, obviously, it gives me Application command names must be unique, because I'm trying to specify the same name for several slash commands
3 replies
DIAdiscord.js - Imagine an app
Created by Alexcitten on 12/16/2022 in #djs-questions
Types of options
Please tell me what each type is responsible for, give documentation on the types of options 3.options[0].options[0][UNION_TYPE_CHOICES]: Value of field "type" must be one of (9, 8, 7, 6, 5, 10, 3, 4, 11).
6 replies
DIAdiscord.js - Imagine an app
Created by Alexcitten on 11/30/2022 in #djs-questions
when checking for the number of characters in the argument, I ran into a problem that the bot sends
when checking for the number of characters in the argument, I ran into a problem that the bot sends the error "not such a number of characters in the argument" anyway, even if everything is correct
const { ApplicationCommandOptionType, EmbedBuilder } = require('discord.js');

module.exports = {
name: "test",
usage: "/test",
options: [
{
name: 'option',
description: '43-symbol',
type: ApplicationCommandOptionType.String,
required: true
}
],
category: "test",
description: "test",
ownerOnly: false,
run: async (client, interaction, args) => {

await interaction.deferReply({ephemeral: true});

if(!interaction.options.getString("option").lenght !== 43) {
interaction.editReply({
content: `not 43`
})
} else {

const embed = new EmbedBuilder()
.setThumbnail(client.user.displayAvatarURL())
.addFields([
{name: `yay`, value: `${interaction.options.getString("option")}`}
])
.setColor('#FF8747')
.setFooter({
text: `test`,
iconURL: `${client.user.displayAvatarURL()}`
});

return interaction.reply({
embeds: [embed],
ephemeral: true
});
}
}
}
const { ApplicationCommandOptionType, EmbedBuilder } = require('discord.js');

module.exports = {
name: "test",
usage: "/test",
options: [
{
name: 'option',
description: '43-symbol',
type: ApplicationCommandOptionType.String,
required: true
}
],
category: "test",
description: "test",
ownerOnly: false,
run: async (client, interaction, args) => {

await interaction.deferReply({ephemeral: true});

if(!interaction.options.getString("option").lenght !== 43) {
interaction.editReply({
content: `not 43`
})
} else {

const embed = new EmbedBuilder()
.setThumbnail(client.user.displayAvatarURL())
.addFields([
{name: `yay`, value: `${interaction.options.getString("option")}`}
])
.setColor('#FF8747')
.setFooter({
text: `test`,
iconURL: `${client.user.displayAvatarURL()}`
});

return interaction.reply({
embeds: [embed],
ephemeral: true
});
}
}
}
5 replies
DIAdiscord.js - Imagine an app
Created by Alexcitten on 8/4/2022 in #djs-questions
How send message to specific channel by channel id?
i will try interaction.channels.fetch("ID") but fetch is not defined
7 replies
DIAdiscord.js - Imagine an app
Created by Alexcitten on 8/2/2022 in #djs-questions
Get all tags and ID's users in voice channel by channel ID
How to get list all peoples, which are connected to a specific channel? User tags and ID's
3 replies
DIAdiscord.js - Imagine an app
Created by Alexcitten on 6/29/2022 in #djs-questions
Is it possible now to interact with the automod mode on servers
4 replies