Skip to content

Commit

Permalink
DDD-DDD regex (#1)
Browse files Browse the repository at this point in the history
2fa auth gibi numeric regex

---------

Co-authored-by: Sefa <sefa@outlook.ie>
  • Loading branch information
exdal and Seefaaa authored Sep 15, 2024
1 parent af04d2b commit 8608343
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/commands/api/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ export class VerifyCommand implements Command {
.setDescription('Discord hesabın ile BYOND hesabını bağlar.')
.addStringOption((option) =>
option
.setName('token')
.setDescription('Oyun içerisinden alınan tek kullanımlık token.')
.setName('code')
.setDescription('Oyun içerisinden alınan tek kullanımlık kod.')
.setRequired(true)
);
public async execute(interaction: ChatInputCommandInteraction) {
const user = interaction.user;
const token = interaction.options.getString('token', true);
const code = interaction.options.getString('code', true);

const { statusCode, body: ckey } = await post<string>('verify', {
discord_id: user.id,
one_time_token: token,
one_time_token: code,
});

if (statusCode === 200) {
Expand All @@ -36,13 +36,13 @@ export class VerifyCommand implements Command {
ephemeral: true,
});
} else if (statusCode === 404) {
interaction.reply({ content: 'Token geçersiz.', ephemeral: true });
interaction.reply({ content: 'Kod geçersiz.', ephemeral: true });
} else if (statusCode === 409) {
const conflict = ckey as any as string;

if (conflict.startsWith('@')) {
interaction.reply({
content: `Bu token <${conflict}> adlı Discord hesabına bağlı.`,
content: `Bu kod <${conflict}> adlı Discord hesabına bağlı.`,
ephemeral: true,
});
} else {
Expand Down
10 changes: 4 additions & 6 deletions src/events/messageCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ export class MessageCreateEvent implements Event {
public async execute(message: Message) {
if (message.guildId === GUILD_ID) {
const [command, token] = message.content.split(' ');
if (command === '/verify' && /^([A-z']+-){5}[A-z']+$/.test(token)) {
if (command === '/verify' && /^\d{3}-\d{3}$/.test(token)) {
try {
await message.reply({
content:
'Hesabını doğrulamak için /verify yazdıkdan sonra çıkan komutu kullanman gerek, ayrıca doğrulama tokenini bir başkası ile paylaşmamalısın.',
options: { ephemeral: true },
});
await message.reply(
'Hesabını doğrulamak için /verify yazdıkdan sonra çıkan komutu kullanman gerek, ayrıca doğrulama kodunu bir başkası ile paylaşmamalısın.'
);
message.delete();
} catch {}
}
Expand Down

0 comments on commit 8608343

Please sign in to comment.