Skip to content

Commit

Permalink
Merge pull request #17 from NITKC22s/develop
Browse files Browse the repository at this point in the history
Develop => main v3.1.0
  • Loading branch information
starkoka authored Dec 27, 2022
2 parents 85a0a5a + bf26972 commit af0f1eb
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 286 deletions.
32 changes: 13 additions & 19 deletions botmain.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const config = require('./environmentConfig')
let ccconfig=require("./CCConfig.json");
const timetableBuilder = require('./timetable/timetableUtils');
const Classes = require('./timetable/timetables.json');
const studyroom = require('./functions/studyRoom.js')
const TxtEasterEgg = require('./functions/TxtEasterEgg.js');
const dotenv = require('dotenv');
const path = require('path');
Expand Down Expand Up @@ -311,14 +310,6 @@ client.on(Events.InteractionCreate, async interaction =>
}
});

/*自習室BOT(VCに参加したら通知)*/
client.on('voiceStateUpdate', (oldState, newState) => {
studyroom.func(oldState, newState)
})

cron.schedule('0 0 * * *',() => {
studyroom.update();
})
/*TxtEasterEgg*/
client.on('messageCreate', message => {
TxtEasterEgg.func(message);
Expand Down Expand Up @@ -493,16 +484,19 @@ cron.schedule('0 5 * * *', () => {

cron.schedule('0 20 * * 0,1,2,3,4', async () => {
let dayOfWeek = new Date().getDay()+1;
(await (client.channels.cache.get(config.M) ?? await client.channels.fetch(config.M))
.send({ embeds: [timetableBuilder(Classes.M, dayOfWeek)] }));
(await (client.channels.cache.get(config.E) ?? await client.channels.fetch(config.E))
.send({ embeds: [timetableBuilder(Classes.E, dayOfWeek)] }));
(await (client.channels.cache.get(config.D) ?? await client.channels.fetch(config.D))
.send({ embeds: [timetableBuilder(Classes.D, dayOfWeek)] }));
(await (client.channels.cache.get(config.J) ?? await client.channels.fetch(config.J))
.send({ embeds: [timetableBuilder(Classes.J, dayOfWeek)] }));
(await (client.channels.cache.get(config.C) ?? await client.channels.fetch(config.C))
.send({ embeds: [timetableBuilder(Classes.C, dayOfWeek)] }));
//timetable == trueのとき
if(config.timetable === true) {
(await (client.channels.cache.get(config.M) ?? await client.channels.fetch(config.M))
.send({ embeds: [timetableBuilder(Classes.M, dayOfWeek)] }));
(await (client.channels.cache.get(config.E) ?? await client.channels.fetch(config.E))
.send({ embeds: [timetableBuilder(Classes.E, dayOfWeek)] }));
(await (client.channels.cache.get(config.D) ?? await client.channels.fetch(config.D))
.send({ embeds: [timetableBuilder(Classes.D, dayOfWeek)] }));
(await (client.channels.cache.get(config.J) ?? await client.channels.fetch(config.J))
.send({ embeds: [timetableBuilder(Classes.J, dayOfWeek)] }));
(await (client.channels.cache.get(config.C) ?? await client.channels.fetch(config.C))
.send({ embeds: [timetableBuilder(Classes.C, dayOfWeek)] }));
}
});


Expand Down
148 changes: 0 additions & 148 deletions commands/studyCommands.js

This file was deleted.

22 changes: 21 additions & 1 deletion commands/timeTable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js')
const timetableBuilder = require('../timetable/timetableUtils')
const Classes = require('../timetable/timetables.json')

const fs = require('fs');
const {configPath}=require("../environmentConfig")
module.exports = [
{
data: new SlashCommandBuilder()
Expand Down Expand Up @@ -64,6 +65,25 @@ module.exports = [
await interaction.reply({ embeds: [embed] });
},
},
{
data: new SlashCommandBuilder()
.setName('ttswitcher')
.setDescription('時間割定期送信のON/OFFを切り替えます')
.setDefaultMemberPermissions(1<<3)
.addBooleanOption(option =>
option
.setName('options')
.setDescription('定期実行の可否を指定します')
.setRequired(true)
),

async execute(interaction) {
const date = JSON.parse(fs.readFileSync(configPath, 'utf8')) //ここで読み取り
date.timetable = interaction.options.data[0].value
fs.writeFileSync(configPath, JSON.stringify(date,null ,"\t")) //ここで書き出し
await interaction.reply({ content: "時間割定期通知機能を" + interaction.options.data[0].value + "に設定しました", ephemeral: true });
},
},


]
10 changes: 8 additions & 2 deletions environmentConfig.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
const config = process.env.NODE_ENV == "production" ? require('./config.json') : require('./config.dev.json')
module.exports=config
const Path = require("path");
const configPath = Path.resolve(
__dirname,
process.env.NODE_ENV == "production" ? "./config.json" : "./config.dev.json"
);
const config = require(configPath);
module.exports = config;
module.exports.configPath = configPath;
115 changes: 0 additions & 115 deletions functions/studyRoom.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"name": "nitkc-main",
"description": "",
"version": "3.0.1",
"version": "3.1.0",
"main": "botmain.js",
"scripts": {
"dev": "cross-env NODE_ENV=development node .",
Expand Down

0 comments on commit af0f1eb

Please sign in to comment.