-
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
7 changed files
with
159 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# slash-command-bot-v14 | ||
About Discord bot draft that does not contain ready-made commands, compatible with discord.js v14. Create your own discord bot with this slash command handler. | ||
|
||
<hr> | ||
Follow Me Social Media<br> | ||
Twitch Yayınları: https://twitch.com/umutxyp<br> | ||
Github: https://github.com/umutxyp<br> | ||
Instagram: https://instagram.com/umutxyp<br> | ||
Twitter: https://twitter.com/devbayraktar<br> | ||
Facebook: https://facebook.com/umutxyp<br> | ||
Pinterest: https://pinterest.com/umutxyp<br> | ||
TikTok: https://www.tiktok.com/@umutxyp |
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,10 @@ | ||
module.exports = { | ||
name: "ping", | ||
description: "View bot ping.", | ||
options: [], | ||
run: async (client, interaction) => { | ||
|
||
interaction.reply("pong") | ||
|
||
}, | ||
}; |
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,6 @@ | ||
module.exports = { | ||
////////////////////////// | ||
token: "", //WRITE YOUR BOT TOKEN | ||
botStatus: "Umut Bayraktar ♥", //WRITE YOUR BOT STATUS. | ||
////////////////////////// | ||
} |
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,23 @@ | ||
const { InteractionType } = require("discord.js"); | ||
const fs = require("fs"); | ||
module.exports = async(client, interaction) => { | ||
if(!interaction.guild) return; | ||
if(interaction.user.bot) return; | ||
|
||
if (interaction.type === InteractionType.ApplicationCommand) { | ||
fs.readdir("./commands", (err, files) => { | ||
if (err) throw err; | ||
files.forEach(async (f) => { | ||
let props = require(`../commands/${f}`); | ||
if (interaction.commandName.toLowerCase() === props.name.toLowerCase()) { | ||
try { | ||
return props.run(client, interaction); | ||
} catch (e) { | ||
return interaction.reply({ content: `ERROR\n\n\`\`\`${e.message}\`\`\``, ephemeral: true }).catch(e => { }) | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
} |
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,22 @@ | ||
const config = require("../config.js"); | ||
const { REST } = require("@discordjs/rest"); | ||
const { Routes } = require("discord-api-types/v10"); | ||
|
||
module.exports = async (client) => { | ||
console.log(`${client.user.tag} Bot Online!`) | ||
|
||
client.user.setActivity(config.botStatus) | ||
|
||
const rest = new REST({ version: "10" }).setToken(config.token); | ||
(async () => { | ||
try { | ||
await rest.put(Routes.applicationCommands(client.user.id), { | ||
body: await client.commands, | ||
}); | ||
console.log("Successfully loadded application [/] commands."); | ||
} catch(e) { | ||
console.log("Failed to load application [/] commands. " + e); | ||
} | ||
})(); | ||
|
||
} |
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,67 @@ | ||
const { Client, GatewayIntentBits, Partials } = require("discord.js"); | ||
const config = require("./config.js"); | ||
const fs = require("fs"); | ||
const client = new Client({ | ||
partials: [ | ||
Partials.Message, // for message | ||
Partials.Channel, // for text channel | ||
Partials.GuildMember, // for guild member | ||
Partials.Reaction, // for message reaction | ||
Partials.GuildScheduledEvent, // for guild events | ||
Partials.User, // for discord user | ||
Partials.ThreadMember, // for thread member | ||
], | ||
intents: [ | ||
GatewayIntentBits.Guilds, // for guild related things | ||
GatewayIntentBits.GuildMembers, // for guild members related things | ||
GatewayIntentBits.GuildBans, // for manage guild bans | ||
GatewayIntentBits.GuildEmojisAndStickers, // for manage emojis and stickers | ||
GatewayIntentBits.GuildIntegrations, // for discord Integrations | ||
GatewayIntentBits.GuildWebhooks, // for discord webhooks | ||
GatewayIntentBits.GuildInvites, // for guild invite managing | ||
GatewayIntentBits.GuildVoiceStates, // for voice related things | ||
GatewayIntentBits.GuildPresences, // for user presence things | ||
GatewayIntentBits.GuildMessages, // for guild messages things | ||
GatewayIntentBits.GuildMessageReactions, // for message reactions things | ||
GatewayIntentBits.GuildMessageTyping, // for message typing things | ||
GatewayIntentBits.DirectMessages, // for dm messages | ||
GatewayIntentBits.DirectMessageReactions, // for dm message reaction | ||
GatewayIntentBits.DirectMessageTyping, // for dm message typinh | ||
GatewayIntentBits.MessageContent, // enable if you need message content things | ||
], | ||
}); | ||
|
||
module.exports = client; | ||
|
||
fs.readdir("./events", (_err, files) => { | ||
files.forEach((file) => { | ||
if (!file.endsWith(".js")) return; | ||
const event = require(`./events/${file}`); | ||
let eventName = file.split(".")[0]; | ||
console.log(`👌 Loadded Event: ${eventName}`); | ||
client.on(eventName, event.bind(null, client)); | ||
delete require.cache[require.resolve(`./events/${file}`)]; | ||
}); | ||
}); | ||
|
||
client.commands = []; | ||
fs.readdir("./commands", (err, files) => { | ||
if (err) throw err; | ||
files.forEach(async (f) => { | ||
try { | ||
let props = require(`./commands/${f}`); | ||
client.commands.push({ | ||
name: props.name, | ||
description: props.description, | ||
options: props.options | ||
}); | ||
console.log(`Loaded command: ${props.name}`); | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
}); | ||
}); | ||
|
||
client.login(config.token || process.env.TOKEN).catch(e => { | ||
console.log("The Bot Token You Entered Into Your Project Is Incorrect Or Your Bot's INTENTS Are OFF!") | ||
}) |
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,19 @@ | ||
{ | ||
"name": "discordjs-slash-command-bot-v14", | ||
"version": "1.0.0", | ||
"description": "discordjs-slash-command-bot-v14", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node index.js" | ||
}, | ||
"keywords": [], | ||
"author": "Umut Bayraktar", | ||
"license": "MIT", | ||
"dependencies": { | ||
"discord.js": "^14.7.1", | ||
"fs": "^0.0.1-security" | ||
}, | ||
"engines": { | ||
"node": "17.x" | ||
} | ||
} |