Skip to content

Commit d676556

Browse files
committed
Huge V1.8 Update!
1 parent 9c10067 commit d676556

22 files changed

+480
-447
lines changed

index.js

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,16 @@ const events = new Discord.Collection();
1313
globalThis.Underline = {
1414
config,
1515
client,
16-
interactions: interactions,
17-
events: events,
16+
interactions,
17+
events,
1818
Interaction: require('./types/Interaction'),
1919
Event: require('./types/Event'),
2020
SlashCommand: require("./types/SlashCommand"),
21-
SlashSubCommand: require("./types/SlashSubCommand"),
2221
MessageAction: require("./types/MessageAction"),
2322
UserAction: require("./types/UserAction"),
2423
}
2524

26-
console.info("[BİLGİ] Basit Altyapı - by Kıraç Armağan Önal");
25+
console.info("[BİLGİ] Basit Altyapı v1.8 - by Kıraç Armağan Önal");
2726
(async () => {
2827
let interactionsPath = path.resolve("./interactions");
2928
await makeSureFolderExists(interactionsPath);
@@ -46,53 +45,46 @@ console.info("[BİLGİ] Basit Altyapı - by Kıraç Armağan Önal");
4645
let rltPath = path.relative(__dirname, interactionFile);
4746
console.info(`[BİLGİ] "${interactionFile}" konumundaki interaksiyon yükleniyor..`)
4847
/** @type {import("./types/Interaction")} */
49-
let interactionData = require(interactionFile);
48+
let uInter = require(interactionFile);
5049

51-
if (interactionData?._type != "interaction") {
50+
if (uInter?._type != "interaction") {
5251
console.warn(`[UYARI] "${rltPath}" interaksiyon dosyası boş. Atlanıyor..`);
5352
return;
5453
}
5554

56-
if (!interactionData.type) {
57-
console.warn(`[UYARI] "${rltPath}" interaksiyon dosyasın için bir type belirtilmemiş. Atlanıyor.`);
58-
return;
59-
}
60-
61-
if (!interactionData.id) {
55+
if (!uInter.id) {
6256
console.warn(`[UYARI] "${rltPath}" interaksiyon dosyasının bir idsi bulunmuyor. Atlanıyor..`);
6357
return;
6458
}
6559

66-
if (typeof interactionData.name != "string") {
67-
console.warn(`[UYARI] "${rltPath}" interaksiyon dosyasının bir ismi bulunmuyor. Atlanıyor..`);
60+
if (uInter.name.length > 3) {
61+
console.warn(`[UYARI] "${rltPath}" interaksiyon dosyasının isim listesi çok uzun. (>3) Atlanıyor..`);
6862
return;
6963
}
70-
if (interactionData.actionType == "CHAT_INPUT") interactionData.name = interactionData.name.replace(/ /g, "").toLowerCase();
7164

72-
if (typeof interactionData.type == "SUB_COMMAND" && !interactionData.subName) {
73-
console.warn(`[UYARI] "${rltPath}" interaksiyon dosyasının tipi "SUB_COMMAND" ancak bir subName bulundurmuyor. Atlanıyor..`);
65+
if (!uInter.name?.length) {
66+
console.warn(`[UYARI] "${rltPath}" interaksiyon dosyasının bir ismi bulunmuyor. Atlanıyor..`);
7467
return;
7568
}
7669

77-
78-
if (Underline.interactions.has(interactionData.id)) {
79-
console.warn(`[UYARI] "${interactionData.id}" idli bir interaksiyon daha önceden zaten yüklenmiş. Atlanıyor.`)
70+
if (Underline.interactions.has(uInter.id)) {
71+
console.warn(`[UYARI] "${uInter.id}" idli bir interaksiyon daha önceden zaten yüklenmiş. Atlanıyor.`)
8072
return;
8173
}
8274

83-
if (typeof interactionData.onInteraction != "function") {
75+
if (typeof uInter.onInteraction != "function") {
8476
console.error(`[HATA] "${rltPath}" interaksiyon dosyası geçerli bir onInteraction fonksiyonuna sahip değil! Atlanıyor.`);
8577
return;
8678
};
8779

88-
if (!interactionData.guildOnly && (interactionData.perms.bot.length != 0 || interactionData.perms.user.length != 0)) {
80+
if (!uInter.guildOnly && (uInter.perms.bot.length != 0 || uInter.perms.user.length != 0)) {
8981
console.warn(`[UYARI] "${rltPath}" interaksiyon dosyası sunuculara özel olmamasına rağmen özel perm kullanıyor.`);
9082
}
9183

9284

93-
Underline.interactions.set(interactionData.id, interactionData);
94-
interactionData.onLoad(client);
95-
console.info(`[BİLGİ] "/${interactionData.name}${interactionData.subName ? ` ${interactionData.subName}` : ""}" (${interactionData.id}) adlı interaksiyon yüklendi. (${Date.now() - start}ms sürdü.)`);
85+
Underline.interactions.set(uInter.id, uInter);
86+
uInter.onLoad(client);
87+
console.info(`[BİLGİ] "${uInter.actionType == "CHAT_INPUT" ? `/${uInter.name.join(" ")}` : `${uInter.name[0]}`}" (${uInter.id}) adlı interaksiyon yüklendi. (${Date.now() - start}ms sürdü.)`);
9688
});
9789

9890
if (Underline.interactions.size) {
@@ -148,11 +140,16 @@ console.info("[BİLGİ] Basit Altyapı - by Kıraç Armağan Önal");
148140
client.on("interactionCreate", async (interaction) => {
149141
if (!(interaction.isCommand() || interaction.isContextMenu())) return;
150142

151-
let command = Underline.interactions.find(cmd => {
152-
if (cmd.type == "SUB_COMMAND") {
153-
return cmd.name == interaction.commandName && cmd.subName == interaction.options.getSubcommand();
154-
} else if (cmd.type == "COMMAND") {
155-
return cmd.name == interaction.commandName;
143+
let subCommandName = "";
144+
try {subCommandName = interaction.options.getSubcommand();} catch { };
145+
let subCommandGroupName = "";
146+
try {subCommandGroupName = interaction.options.getSubcommandGroup();} catch { };
147+
148+
let command = Underline.interactions.find(uInter => {
149+
switch (uInter.name.length) {
150+
case 1: return uInter.name[0] == interaction.commandName;
151+
case 2: return uInter.name[0] == interaction.commandName && uInter.name[1] == subCommandName;
152+
case 3: return uInter.name[0] == interaction.commandName && uInter.name[1] == subCommandGroupName && uInter.name[2] == subCommandName;
156153
}
157154
});
158155

interactions/-ornekInteraksiyon.js renamed to interactions/-ornekKomut.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
module.exports = new Underline.Interaction({
2-
// interaksiyon tipi. COMMAND veya SUB_COMMAND. Gerekli
3-
// interaksiyon tipi SUB_COMMAND olması durumunda subName değeri vermek zoundasınız.
4-
// Subinteraksiyon örnekleri için moderasyon interaksiyonlarına bakabilirsiniz.
5-
type: "COMMAND",
6-
// interaksiyonun idsi. Opsiyonel, boş bırakıldığında {type}:{name}:{subName} formatı ile kayıt olur.
7-
// Boşluk içeremez.
8-
id: "ornekinteraksiyon",
9-
// interaksiyonun kullanıcıya gözüken ismi. Opsiyonel, boş bırakıldığında dosya ismini alır.
10-
// Boşluk içeremez. Bu interaksiyon kullanıcıya /onnekinteraksiyon şeklinde gözükecektir.
11-
// Boşluk, büyük harf, türkçe harf içeremez.
12-
name: "ornekinteraksiyon",
1+
module.exports = new Underline.SlashCommand({
2+
// Slah komutun kullanıcıya gözüken ismi. Bu isim bir arraydır (liste)
3+
// Bu liste en fazla 3 uzunlukta olabilir. Örneğin;
4+
// ["muüzik", "çal"] kullanıcıya /müzik çal olarak gözükecektir.
5+
// veya ["muüzik", "liste", "temizle"] kullanıcıya /müzik liste temizle
6+
// olarak gözükecektir.
7+
name: ["örnekiteraksiyon"],
138
// onInteraction fonksiyonu her interaksiyon kullanıldığında çağrılır.
149
onInteraction(interaction, other) {
1510
// Discord.js CommandInteraction objesi.

interactions/-ornekSağtık.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Sağtık menüsünün nerede çıkacağını
2+
// Class tipini değiştirerek değiştirebilirsiniz.
3+
// Örneğin; Underline.UserAction üyeye sağ tıklama ve
4+
// Underline.MessageAction mesaja sağ tıklama interaksiyonudur.
5+
module.exports = new Underline.UserAction({
6+
// Sağtık menüsünde kullanıcıya gözüken isimdir. Bu isim bir stringdir (yazı)
7+
name: "Örnek İsim",
8+
// Örnek komuttaki bütün değerleri buradada kullanabilirsiniz!
9+
})

interactions/matamatik.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const expressionMap = {
66
};
77

88
module.exports = new Underline.SlashCommand({
9-
name: "matamatik",
9+
name: ["matamatik"],
1010
onInteraction(interaction, other) {
1111
let numberOne = interaction.options.getNumber("number_one");
1212
let expressionName = interaction.options.getString("expression_type");

interactions/moderasyon/at.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
module.exports = new Underline.SlashSubCommand({
2-
name: "moderasyon",
3-
subName: "at",
1+
module.exports = new Underline.SlashCommand({
2+
name: ["moderasyon", "at"],
43
description: "Sunucudan üye atmanızı sağlar.",
54
options: [
65
{

interactions/moderasyon/rol.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
module.exports = new Underline.SlashSubCommand({
2-
name: "moderasyon",
3-
subName: "rol",
1+
module.exports = new Underline.SlashCommand({
2+
name: ["moderasyon", "rol"],
43
description: "Bir kullanıcıdan rol alamanızı sağlar.",
54
options: [
65
{

interactions/moderasyon/ses-sustur.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
module.exports = new Underline.SlashSubCommand({
2-
name: "moderasyon",
3-
subName: "ses-sustur",
1+
module.exports = new Underline.SlashCommand({
2+
name: ["moderasyon", "ses-sustur"],
43
description: "Bir kullanıcının ses susturmasını açıp kapamanızı sağlar.",
54
options: [
65
{

interactions/moderasyon/temizle.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const sleep = require('stuffs/lib/sleep');
22

3-
module.exports = new Underline.SlashSubCommand({
4-
name: "moderasyon",
5-
subName: "temizle",
3+
module.exports = new Underline.SlashCommand({
4+
name: ["moderasyon", "temizle"],
65
description: "Belli bir miktar mesaj silemenizi sağlar.",
76
options: [
87
{

interactions/moderasyon/yasakla.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
module.exports = new Underline.SlashSubCommand({
2-
name: "moderasyon",
3-
subName: "yasakla",
1+
module.exports = new Underline.SlashCommand({
2+
name: ["moderasyon", "yasakla"],
43
description: "Sunucudan üye yasaklamanızı sağlar.",
54
options: [
65
{

interactions/profil.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = new Underline.SlashCommand({
22
description: "Bir kullanıcı hakkına bilgilere bakmanızı sağlar.",
3-
name: "profil",
3+
name: ["profil"],
44
async onInteraction(interaction, other) {
55
/** @type {import("discord.js").GuildMember} */
66
const member = interaction.options.getMember("kullanici", true);

0 commit comments

Comments
 (0)