const { Client, GatewayIntentBits, EmbedBuilder, AttachmentBuilder } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
let vouchCount = 1;
const kanalids = 'kanal id'; // kanalid
client.on('ready', () => {
console.log(`Bot giriş yaptı: ${client.user.tag}`);
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
if (interaction.channelId !== kanalids) {
return interaction.reply({ content: 'you cant use on this channel', ephemeral: true });
}
if (interaction.commandName === 'vouch') {
await interaction.deferReply();
const message = interaction.options.getString('message');
const stars = interaction.options.getInteger('stars');
const attachment = interaction.options.getAttachment('image');
if (!message || !stars || stars < 1 || stars > 5) {
return interaction.followUp({ content: 'Please enter a valid message and a star value between 1-5.', ephemeral: true });
}
let starDisplay = '⭐'.repeat(stars);
const vouchEmbed = new EmbedBuilder()
.setColor(0x0099ff)
.setTitle('New vouch created!')
.addFields(
{ name: 'Vouch Nº:', value: `${vouchCount}`, inline: true },
{ name: 'Vouched by:', value: `${interaction.user}`, inline: true },
{ name: 'Vouched at:', value: `<t:${Math.floor(Date.now() / 1000)}:F>`, inline: true }
)
.setDescription(`${starDisplay}\n\n**Vouch:**\n${message}`)
.setFooter({ text: 'Vouch System' })
.setAuthor({ name: interaction.user.tag, iconURL: interaction.user.displayAvatarURL() });
if (attachment) {
const file = new AttachmentBuilder(attachment.url);
vouchEmbed.setImage(`attachment://${attachment.name}`);
await interaction.followUp({ embeds: [vouchEmbed], files: [file] });
} else {
await interaction.followUp({ embeds: [vouchEmbed] });
}
vouchCount++;
}
});
client.on('ready', async () => {
const data = [
{
name: 'vouch',
description: 'Create a new Vouch for this discord server!',
options: [
{
name: 'message',
description: 'Vouch Message',
type: 3,
required: true,
},
{
name: 'stars',
description: 'Stars (1-5)',
type: 4,
required: true,
},
{
name: 'image',
description: 'Proof',
type: 11,
required: false,
},
],
},
];
const guildId = 'serverid'; // serverid
const guild = client.guilds.cache.get(guildId);
if (guild) {
await guild.commands.set(data);
console.log('Slash komutu ayarlandı');
}
});
client.login('bot token'); // Bot tokenini buraya koy