Skip to content

Commit

Permalink
chore: Prohibits the use of certain users
Browse files Browse the repository at this point in the history
  • Loading branch information
MotiCAT committed Oct 29, 2023
1 parent de0fd6d commit b41213f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
.env
package-lock.json
src/jsons/
src/jsons/
backup
12 changes: 12 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const client = new Discord.Client({
client.commands = new Discord.Collection(); //commandsフォルダのChatInputCommandを格納するためのプロパティ
client.contexts = new Discord.Collection(); //commandsフォルダのContextMenuCommandを格納するためのプロパティ

const bannedServers = ["1136234915663466496"];
const bannedUsers = ["1109315933274640417"];

const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js') && !file.startsWith('context_'));
for (const file of commandFiles) {
try {
Expand Down Expand Up @@ -41,6 +44,7 @@ client.on('ready', async () => {
});

client.on('interactionCreate', async (interaction) => {
if (bannedUsers.includes(interaction.user?.id) || bannedServers.includes(interaction.guild?.id)) return;
if (!interaction.guild) return interaction.reply('DMでは使用できません。');
if (interaction.isChatInputCommand()) {
const command = client.commands.get(interaction.commandName);
Expand Down Expand Up @@ -219,6 +223,7 @@ client.on('interactionCreate', async (interaction) => {
});

client.on('messageCreate', async (message) => {
if (bannedUsers.includes(message.author?.id) || bannedServers.includes(message.guild?.id)) return;
if (message.content.startsWith('ch!eval')) {
if (message.author.id !== '895050958441160734') return;
const code = message.content
Expand Down Expand Up @@ -325,6 +330,7 @@ client.on('messageCreate', async (message) => {
});

client.on('messageUpdate', async (oldMessage, message) => {
if (bannedUsers.includes(message.author?.id) || bannedServers.includes(message.guild?.id)) return;
const tokendata = require('./jsons/token.json');
const serverId = message.guild.id;
const tokenData = tokendata[serverId];
Expand Down Expand Up @@ -364,6 +370,12 @@ client.on('messageUpdate', async (oldMessage, message) => {
};
});

client.on('guildCreate', async guild => {
if (guild.id === '1136234915663466496' || guild.name === 'サウロンのサーバー') {
await guild.leave();
};
});

client.on('error', stderr);

client.login(process.env.TOKEN)
Expand Down

0 comments on commit b41213f

Please sign in to comment.