discord.js uyumluluk katmanı
beeleon-discord.mjs, discord.js'in sık kullanılan sınıflarını Beeleon API'sine çeviren tek dosyalık bir katmandır. Çoğu bot için tek satır değişir:
js
// önce
import { Client, GatewayIntentBits, Events, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js';
// sonra
import { Client, GatewayIntentBits, Events, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } from './beeleon-discord.mjs';beeleon-discord.mjs ve beeleon.mjs dosyalarını botunun yanına koy (ikisi de Developer Portal › Bot şablonları sekmesinden ya da /dev/sdk/ adresinden indirilir). Node.js 22+ gerekir. Token olarak Beeleon bot tokenını ver: client.login('UYGULAMA_ID.GIZLI').
Örnek#
js
import { Client, GatewayIntentBits, Events, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, SlashCommandBuilder, Colors } from './beeleon-discord.mjs';
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages] });
client.once(Events.ClientReady, async c => {
await c.application.commands.set([new SlashCommandBuilder().setName('bilgi').setDescription('Bilgi kartı')]);
console.log('Hazır:', c.user.tag);
});
client.on(Events.InteractionCreate, async i => {
if (i.isChatInputCommand() && i.commandName === 'bilgi') {
const e = new EmbedBuilder().setTitle('Beeleon').setDescription('discord.js katmanıyla çalışıyor').setColor(Colors.Blurple).addFields({ name: 'Sen', value: `${i.user}` });
const row = new ActionRowBuilder().addComponents(new ButtonBuilder().setCustomId('tamam').setLabel('Tamam').setStyle(ButtonStyle.Success));
await i.reply({ embeds: [e], components: [row] });
}
if (i.isButton() && i.customId === 'tamam') await i.update({ content: '✅', embeds: [], components: [] });
});
client.login(process.env.TOKEN);Desteklenenler#
| discord.js | Beeleon karşılığı |
|---|---|
Client, login, on/once, user, guilds.cache, application.commands.set | Gateway + komut kaydı |
Events.ClientReady, InteractionCreate, MessageCreate, MessageUpdate, MessageDelete, GuildCreate, GuildMemberAdd, GuildMemberRemove | Aynı olaylar |
isChatInputCommand, isButton, isStringSelectMenu, isUserSelectMenu, isRoleSelectMenu, isChannelSelectMenu, isModalSubmit, isAutocomplete | Etkileşim türleri |
reply, update, deferReply + editReply, followUp, showModal, respond | Etkileşim yanıtları (ephemeral ya da flags: MessageFlags.Ephemeral) |
options.getString/Integer/Number/Boolean/User/Member/Channel/Role/Subcommand/SubcommandGroup/Focused | Seçenekler |
EmbedBuilder | Container: başlık → title, açıklama → text, alanlar → fields, görsel → banner, küçük resim → section, alt bilgi → footer, renk → accent. Birden çok embed tek container'da ayraçla birleşir |
ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, ChannelSelectMenuBuilder | Düğme ve menü satırları |
ModalBuilder, TextInputBuilder, TextInputStyle | Formlar |
SlashCommandBuilder (alt komut ve grup dahil), ContextMenuCommandBuilder | Komut tanımları |
message.reply, message.channel.send, message.react, message.edit, message.delete | Mesaj işlemleri |
client.user.setActivity, setStatus | Durum |
Bilinen farklar#
- Embed görselleri (
setImage,setThumbnail, yazar/alt bilgi simgesi) Beeleon'a yüklenmiş/cdn/...dosyası olmalıdır; dış adresler gösterilmez. Dosyayıclient.rest.upload(blob, ad)ile yükleyip dönenurl'yi kullan. - Ses (voice) bağlantıları, sticker gönderme ve thread yönetimi bu katmanda yoktur; gerekirse
client._bl.api(yöntem, yol, gövde)ile REST API'yi doğrudan çağır. deferReplysonrasıeditReplygerçek yanıtı gönderir (Beeleon'da her etkileşime 15 dakika içinde bir kez yanıt verilir).- İzin bitleri (
PermissionFlagsBits) Discord'unkiyle aynı değildir; bkz. İzinler.