Kolayca Discord Botu Yazın: DiscordJS Helper Pack
Bu paketle Discord botu yazmayı kolaylaştırın. Bu npm paketi ile Discord botu yazmak çok kolay olacak.

İlk önce gerekli paketleri indirelim:
npm i discordjs-helper-pack discord.js
Yükledikten sonra, bot altyapısını ayarlayalım:
const { Client } = require('discord.js')
const { Configuration } = require('discordjs-helper-pack')
const client = new Client()
Configuration({
// incessary information
client: client,
dirname: __dirname,
commandsFileName: 'commands', // commands file
eventsFileName: 'events', // events file
chatInputCommand: true, // command interaction
//prefix configurations
prefix: 'm!',
prefixCommandsFileName: 'prefixCommands'
})
Sonra bota izinler verelim:
const { Tools } = require('discordjs-helper-pack')
const { ItentsAll } = new Tools()
const client = new Client({intents: ItentsAll()})
Gelin bir event oluşturalım, dizin altına events/ready.js:
const { Event } = require('discordjs-helper-pack')
new Event('ready').build(async(client, member)=>{
console.log(`${member.user.tag} adlı bot giriş yaptı!`)
})
Gelin bir tane slash komutu oluşturalım commands/example.js:
const { Command } = require('discordjs-helper-pack')
module.exports = new Command('example', 'example command')
.build(async (interaction)=>{
await interaction.reply('code is ran!')
})
Bir tane de prefix command oluşturalım, prefixCommands/example.js:
const { Affix } = require('discordjs-helper-pack')
module.exports = new Affix('example', description?, usage?)
.build('example', async (message, helper)=>{
message.reply("Code is ran!")
})
Gelin yardımcılara bakalım:
.client => client
.getUser() => message.author.id
.getArgs() => message.content.split(' ')
.bot() => message.author.bot
Embed ve Message yapısına bakalım:
import { MessageSender } from 'discordjs-helper-pack'
const sender = new MessageSender(client)
// eğer renk girilmezse, default gelir: 0x0099FF
sender.embed(title, color, footer)
// kanala mesaj atar
sender.send(embed, kanal_id, ...components)
/* Burada zorunlu olan embed ve kanal_id. */
sender.sendContent(text, kanal_id, ...components)
Embed’a random renk atamak istiyorsanız:
const { Crumbs } = require('discordjs-helper-pack')
const crumbs = new Crumbs()
crumbs.randomColor()
TextSelectBox sınıfına bakalım, bu özellikle beraber kolayca, seçim menüsü ekleyebiliyoruz:
const { TextSelectBox } = require('discordjs-helper-pack')
const { ActionRow } = require('discord-helper-pack')
# customId, title
const textbox = new TextSelectBox('terazi','Terazi')
default: label, value
textbox.add(label, value, description, boxDefault, emoji)
textbox.add('Kova', 'kova', 'Kova Burcu')
const box = textbox.build()
// yapı hazır:
ActionRow(box)
UserSelectBox sınıfına bakalım, bu yapıyla beraber kolayca User seçimi yapabiliyoruz:
const { UserSelectBox } = require('discordjs-helper-pack')
default: customId, description
const select = new UserSelectBox(customId, description).build()
const select = new UserSelectBox(customId, placeholder, max, min, disabled,setUsers,addUsers).build()
const select1 = new UserSelectBox("user1", "User Seçin.").build()
Button oluşturmak bu kadar kolay! Hadi bakalım:
const { Button } = require('discordjs-helper-pack')
const button = new Button()
default value: customId, label, buttonStyle
btn.add()
// example
btn.add("Burak", "instagram/burakbehlull", btn.style.Secondary)
// and others values
emoji, disabled
btn.add("Behlül", "github/burakbehlull", btn.style.Secondary, "emoji", true)
const btns = btn.build()
// use example
i.reply({components: [btns]})
Modal oluşturmak bu kadar kolay:
onst { Modal } = require('discordjs-helper-pack')
new Modal(customId, title)
default: customId, label
.add(customId, label)
// other
.add(customId, label, value, {paragraph, required, placeholder, max, min})
// example
const modal = new Modal('user', 'Kullanıcı bilgisi')
modal.add('adi', 'Adın')
modal.add('soyadi', 'Soyadın')
// ready
const built = modal.build()
interaction.showModal(built)
// other
interaction.showModal(modal.build())
Diğer ayrıntılar için npm paketimize bakabilirsiniz.
Bu paket, kolayca bot yazmanızı kolaylaştırdığı gibi, sizi kısıtlamaz. Farklı şeyler eklemenize engel olmaz. Kolay bir yapı sunar ve botu anlamanıza yardımcı olur.
Yorumlar
Yorum Gönder