From 53ae00e5d531ef384d73aa0d11ed5d3998b42b44 Mon Sep 17 00:00:00 2001 From: PawitSahare <123424956+pawitpr@users.noreply.github.com> Date: Mon, 6 Feb 2023 13:43:21 -0800 Subject: [PATCH 1/4] Create console.js --- console.js | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 console.js diff --git a/console.js b/console.js new file mode 100644 index 0000000..5ca48d1 --- /dev/null +++ b/console.js @@ -0,0 +1,2 @@ +// this is a file +console.log('hello') From dabd34d6b1089f5a943844d1dfc425b3395d6907 Mon Sep 17 00:00:00 2001 From: PawitSahare <123424956+pawitpr@users.noreply.github.com> Date: Mon, 6 Feb 2023 13:44:50 -0800 Subject: [PATCH 2/4] Update console.js --- console.js | 1 + 1 file changed, 1 insertion(+) diff --git a/console.js b/console.js index 5ca48d1..77f6d27 100644 --- a/console.js +++ b/console.js @@ -1,2 +1,3 @@ // this is a file console.log('hello') +console.log('hello') // 2nd From c699d3d0d1e1b2e57633d6c998b82448e2e8d4c1 Mon Sep 17 00:00:00 2001 From: PawitSahare <123424956+pawitpr@users.noreply.github.com> Date: Mon, 6 Feb 2023 13:46:52 -0800 Subject: [PATCH 3/4] Update console.js --- console.js | 1 + 1 file changed, 1 insertion(+) diff --git a/console.js b/console.js index 77f6d27..d02c053 100644 --- a/console.js +++ b/console.js @@ -1,3 +1,4 @@ // this is a file console.log('hello') console.log('hello') // 2nd +console.log('hello') From 05b8943d133ce8fa4228d6cafecd77ef7913d2e5 Mon Sep 17 00:00:00 2001 From: PawitSahare <123424956+pawitpr@users.noreply.github.com> Date: Mon, 6 Feb 2023 13:50:41 -0800 Subject: [PATCH 4/4] Create sync.js --- sync.js | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 sync.js diff --git a/sync.js b/sync.js new file mode 100644 index 0000000..d86ccde --- /dev/null +++ b/sync.js @@ -0,0 +1,94 @@ +require('dotenv').config(); +const inlinereply = require('discord-reply') +const {REST} = require('@discordjs/rest'); +const { Console, clear } = require('console'); +const { Routes } = require('discord-api-types/v9'); +const { Client, Intents, Collection , MessageEmbed} = require('discord.js'); +const { config } = require('dotenv'); +const randomstring = require('randomstring') +const fs = require('fs'); +const path = require('path'); +const { send } = require('process'); + + + +const client = new Client({ + intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] +}); + +// List of all commands +const commands = []; +client.commands = new Collection(); + +const commandsPath = path.join(__dirname, "commands"); // E:\yt\discord bot\js\intro\commands +const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js')); +for(const file of commandFiles) +{ + const filePath = path.join(commandsPath, file); + const command = require(filePath); + + client.commands.set(command.data.name, command); + commands.push(command.data.toJSON()); +} + +client.on("ready",async () => { + console.log('i am online'); + client.user.setActivity('Kya dekh raha hai ', {type:"WATCHING"}) + // Get all ids of the servers + const guild_ids = client.guilds.cache.map(guild => guild.id); + + + + const rest = new REST({version: '9'}).setToken(process.env.TOKEN); + for (const guildId of guild_ids) + { + rest.put(Routes.applicationGuildCommands(process.env.CLIENT_ID, guildId), + {body: commands}) + .then(() => console.log('Connected client id is ' + guildId)) + .catch(console.error); + } +}); + +client.on("interactionCreate", async interaction => { + if(!interaction.isCommand()) return; + + const command = client.commands.get(interaction.commandName); + if(!command) return; + + try + { + await command.execute(interaction); + } + catch(error) + { + console.error(error); + await interaction.reply({content: "There was an error executing this command"}); + } +}); + +client.login(process.env.TOKEN); +client.on("message",async msg => { + let isNewUser = msg.type === "GUILD_MEMBER_JOIN" + if (isNewUser) { + msg.author.send(' Naye Player ko Salam 🫡 ' + msg.author.username ); + msg.reply('Are you new User?') + + } + + if (msg.mentions.has(client.user.id)) { + + + return msg.reply(`What i do ${msg.author.username} ?`); + + } + return msg.reply(`${randomstring.generate(80)}`) + + +}); + + + +const PORT = process.env.PORT + +console.log('Your default port is' + PORT); +// Webhook