-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
810 additions
and
214 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 |
---|---|---|
|
@@ -176,3 +176,5 @@ dist | |
.DS_Store | ||
|
||
config.toml | ||
|
||
test.ts |
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 @@ | ||
preload = ["./src/preload.ts"] |
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
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
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
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
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
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,84 @@ | ||
import { | ||
ActionRowBuilder, | ||
ButtonBuilder, | ||
type ChatInputCommandInteraction, | ||
type MessageActionRowComponentBuilder as MessageActionRow, | ||
PermissionFlagsBits, | ||
SlashCommandBuilder, | ||
} from 'discord.js'; | ||
|
||
import type { Command } from '@/types'; | ||
|
||
export class ButtonCommand implements Command { | ||
public builder = new SlashCommandBuilder() | ||
.setName('button') | ||
.setDescription('Buton ekli bir mesaj oluşturur.') | ||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageChannels) | ||
.addStringOption((option) => | ||
option | ||
.setName('message') | ||
.setDescription('Butonun ekleneceği mesajın içeriği.') | ||
.setRequired(true) | ||
) | ||
.addStringOption((option) => | ||
option | ||
.setName('button') | ||
.setDescription('Buton oluşturmak için gereken özel söz dizimi.') | ||
.setRequired(true) | ||
); | ||
public async execute(interaction: ChatInputCommandInteraction) { | ||
const message = interaction.options.getString('message', true); | ||
const token = interaction.options.getString('button', true); | ||
|
||
if (!interaction.channel?.isSendable()) { | ||
await interaction.reply({ | ||
content: 'Bu kanala mesaj gönderemiyorum.', | ||
ephemeral: true, | ||
}); | ||
return; | ||
} | ||
|
||
const buttons = token.split(';'); | ||
|
||
if (buttons.length === 0) { | ||
await interaction.reply({ | ||
content: 'Buton oluşturmak için en az bir buton gereklidir.', | ||
ephemeral: true, | ||
}); | ||
return; | ||
} | ||
|
||
const row = new ActionRowBuilder<MessageActionRow>(); | ||
|
||
for (const button of buttons) { | ||
const [label, style, customId] = button.split(':'); | ||
|
||
const styleNumber = Number(style); | ||
|
||
if (isNaN(styleNumber) || styleNumber < 1 || styleNumber > 5) { | ||
await interaction.reply({ | ||
content: 'Geçersiz buton stili.', | ||
ephemeral: true, | ||
}); | ||
return; | ||
} | ||
|
||
row.addComponents( | ||
new ButtonBuilder() | ||
.setCustomId(customId) | ||
.setLabel(label) | ||
.setStyle(styleNumber) | ||
); | ||
} | ||
|
||
await interaction.channel.send({ | ||
content: message, | ||
components: [row], | ||
}); | ||
|
||
await interaction.reply({ | ||
content: 'Mesaj oluşturuldu.', | ||
ephemeral: true, | ||
}); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.