Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
EmirhanSarac authored Nov 11, 2022
0 parents commit 51392c3
Show file tree
Hide file tree
Showing 8 changed files with 736 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
discord.js v14 slash altyapı
18 changes: 18 additions & 0 deletions commands/ping.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { Client, EmbedBuilder } = require("discord.js");

module.exports = {
name: "ping",
description: "Bot'un ping değerlerini öğrenirsiniz",
type: 1,
options: [],

run: async(client, interaction) => {

const { user, guildId, channel } = interaction;


interaction.reply({ embeds: [ new EmbedBuilder().setDescription(`Pong! ***${client.ws.ping}ms***`) ], ephemeral: true })

}

};
3 changes: 3 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"TOKEN":"Njg1Nzc2NzQ1NzE0MTU1NTgw.GiqVuL.a-CtGZ5mMJJcgV_HN-0I1fyCoyj-WJ76yQjIw8"
}
28 changes: 28 additions & 0 deletions events/interactionCreate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { Collection, EmbedBuilder } = require("discord.js");
const { readdirSync } = require("fs");

module.exports = async(client, interaction) => {

if(interaction.isChatInputCommand()) {

if (!interaction.guildId) return;

readdirSync('./commands').forEach(f => {

const cmd = require(`../commands/${f}`);

if(interaction.commandName.toLowerCase() === cmd.name.toLowerCase()) {

return cmd.run(client, interaction);


}


});



}

};
17 changes: 17 additions & 0 deletions events/ready.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { REST } = require("@discordjs/rest");
const { Routes } = require("discord-api-types/v10");
const { TOKEN } = require("../config.json");

module.exports = async (client) => {

const rest = new REST({ version: "10" }).setToken(TOKEN);
try {
await rest.put(Routes.applicationCommands(client.user.id), {
body: client.commands,
});
} catch (error) {
console.error(error);
}

console.log(`${client.user.tag} Aktif!`);
};
63 changes: 63 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const { Client, GatewayIntentBits, Partials, Collection } = require("discord.js");
const INTENTS = Object.values(GatewayIntentBits);
const PARTIALS = Object.values(Partials);
const client = new Client({
intents: INTENTS,
allowedMentions: {
parse: ["users"]
},
partials: PARTIALS,
retryLimit: 3
});

global.client = client;
client.commands = (global.commands = []);

const { readdirSync } = require("fs")
const { TOKEN } = require("./config.json");

/* Slash Komutları Yüklüyoruz */

readdirSync('./commands').forEach(f => {
if(!f.endsWith(".js")) return;

const props = require(`./commands/${f}`);

client.commands.push({
name: props.name.toLowerCase(),
description: props.description,
options: props.options,
dm_permission: props.dm_permission,
type: 1
});

console.log(`[COMMAND] ${props.name} komutu yüklendi.`)

});


/* Slash Komutları Yüklüyoruz */

/* Eventleri Yüklüyoruz */

readdirSync('./events').forEach(e => {

const eve = require(`./events/${e}`);
const name = e.split(".")[0];

client.on(name, (...args) => {
eve(client, ...args)
});

console.log(`[EVENT] ${name} eventi yüklendi.`)

});


/* Eventleri Yüklüyoruz */

client.login(TOKEN).then(app => {
console.log(`[BOT] Token girişi başarılı.`)
}).catch(app => {
console.log(`[BOT] Token girşi başarısız.`)
})
Loading

0 comments on commit 51392c3

Please sign in to comment.