Skip to content

Commit

Permalink
Submission
Browse files Browse the repository at this point in the history
  • Loading branch information
Seefaaa committed Oct 26, 2024
1 parent 94bd79f commit ec10760
Show file tree
Hide file tree
Showing 27 changed files with 810 additions and 214 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,5 @@ dist
.DS_Store

config.toml

test.ts
1 change: 1 addition & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
preload = ["./src/preload.ts"]
5 changes: 5 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ guild_id = ""
path = "bot.json.log"
colorize = true
verify_channel = ""
submissions_channel = ""

[api]
url = "https://api.turkb.us/v2"
token = ""

[submission]
questions = []
role = ""
10 changes: 4 additions & 6 deletions src/commands/api/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ export class CheckCommand implements Command {
if (statusCode === 200) {
const server = servers[0];

const connect = new ButtonBuilder()
.setLabel('Bağlan')
.setStyle(ButtonStyle.Link)
.setURL(CONNECT_URL);

const row = new ActionRowBuilder<MessageActionRow>().addComponents(
connect
new ButtonBuilder()
.setLabel('Bağlan')
.setStyle(ButtonStyle.Link)
.setURL(CONNECT_URL)
);

if (server.server_status === 1) {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/api/playtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async function handlePlaytimePlayerReply(
interaction: ChatInputCommandInteraction
) {
if (player.length === 0) {
interaction.reply('Oyuncu daha önce hiçbir meslek oynamamış.');
await interaction.reply('Oyuncu daha önce hiçbir meslek oynamamış.');
return;
}

Expand Down Expand Up @@ -230,7 +230,7 @@ async function handlePlaytimePlayerReply(
next.setDisabled(true);
previous.setDisabled(true);

interaction.editReply({
await interaction.editReply({
content,
components: [row],
});
Expand Down
26 changes: 8 additions & 18 deletions src/commands/api/verify.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
import {
type ChatInputCommandInteraction,
type Client,
PermissionFlagsBits,
SlashCommandBuilder,
type TextChannel,
} from 'discord.js';

import config from '@/config';
import { verifyRegex } from '@/constants';
import logger from '@/logger';
import type { Command } from '@/types';
import { post } from '@/utils';

const logVerify = async (client: Client, message: string) => {
const verifyLogChannel = (await client.channels.fetch(
config.log.verifyChannel
)) as TextChannel;

verifyLogChannel.send({
content: message,
allowedMentions: { parse: [] },
});
};

export class VerifyCommand implements Command {
public builder = new SlashCommandBuilder()
.setName('verify')
Expand Down Expand Up @@ -52,7 +38,8 @@ export class VerifyCommand implements Command {
ephemeral: true,
});

logVerify(
logger.channel(
'verify',
interaction.client,
`${user} hesabını \`${ckey}\` adlı BYOND hesabına bağladı.`
);
Expand Down Expand Up @@ -135,7 +122,8 @@ export class UnverifyCommand implements Command {
`<@${user.id}> adlı Discord hesabı ile \`${ckey}\` adlı BYOND hesabının bağlantısı kaldırıldı.`
);

logVerify(
logger.channel(
'verify',
interaction.client,
`${user} adlı Discord hesabı ile \`${ckey}\` adlı BYOND hesabının bağlantısı ${interaction.user} tarafından kaldırıldı.`
);
Expand Down Expand Up @@ -164,7 +152,8 @@ export class UnverifyCommand implements Command {
`\`${ckey}\` adlı BYOND hesabı ile <${discordId}> adlı Discord hesabının bağlantısı kaldırıldı.`
);

logVerify(
logger.channel(
'verify',
interaction.client,
`${user} adlı Discord hesabı ile \`${ckey}\` adlı BYOND hesabının bağlantısı ${interaction.user} tarafından kaldırıldı.`
);
Expand Down Expand Up @@ -216,7 +205,8 @@ export class ForceVerifyCommand implements Command {
`<@${user.id}> adlı Discord hesabı \`${ckey}\` adlı BYOND hesabına bağlandı.`
);

logVerify(
logger.channel(
'verify',
interaction.client,
`${user} adlı Discord hesabı ile \`${ckey}\` adlı BYOND hesabı ${interaction.user} tarafından bağlandı.`
);
Expand Down
1 change: 1 addition & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export * from './api/player';
export * from './api/playtime';
export * from './api/verify';
export * from './api/who';
export * from './utility/button';
export * from './utility/ping';
84 changes: 84 additions & 0 deletions src/commands/utility/button.ts
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,
});
}
}
65 changes: 0 additions & 65 deletions src/config.ts

This file was deleted.

Loading

0 comments on commit ec10760

Please sign in to comment.