-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from CHProducts/dev
change command name
- Loading branch information
Showing
46 changed files
with
872 additions
and
907 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Motcher | ||
|
||
(多分)便利Bot | ||
|
||
動作確認中 | ||
動作確認中 |
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,53 @@ | ||
import { ServerJoinData } from '../Utils/ServerData'; | ||
import { embeds } from '../embeds'; | ||
import { Message, Guild, TextBasedChannel } from 'discord.js'; | ||
import { writeFile, readFileSync } from 'fs'; | ||
|
||
export async function joinCommand(message: Message) { | ||
const args = message.content.split(' '); | ||
const subcommand = args[1] as string | undefined; | ||
switch (subcommand) { | ||
case 'message': | ||
{ | ||
const detail = args[2]; | ||
const channel = message.channel as TextBasedChannel; | ||
const guild = message.guild as Guild; | ||
const serverId = guild.id; | ||
if (!detail) return message.reply(embeds.joinmsgHelp); | ||
const rawData = readFileSync('./database/join_messages.json', 'utf-8'); | ||
const data: Record<string, ServerJoinData> = JSON.parse(rawData); | ||
data[serverId] = { | ||
joinMessage: detail, | ||
channelId: channel.id | ||
}; | ||
writeFile('./database/join_messages.json', JSON.stringify(data, null, 2), (err) => { | ||
if (err) { | ||
message.reply(embeds.defaultError); | ||
} else { | ||
message.reply(embeds.saveSuccess); | ||
} | ||
}); | ||
} | ||
break; | ||
case 'remove': | ||
{ | ||
const guild = message.guild as Guild; | ||
const serverId = guild.id; | ||
const rawData = readFileSync('./database/join_messages.json', 'utf-8'); | ||
const data: Record<string, ServerJoinData> = JSON.parse(rawData); | ||
delete data[serverId]; | ||
writeFile('./database/join_messages.json', JSON.stringify(data, null, 2), (err) => { | ||
if (err) { | ||
message.reply(embeds.defaultError); | ||
console.error(err); | ||
} else { | ||
message.reply(embeds.deleteSuccess); | ||
} | ||
}); | ||
} | ||
break; | ||
default: | ||
message.reply(embeds.joinHelp); | ||
break; | ||
} | ||
} |
Oops, something went wrong.