Skip to content

Commit

Permalink
Merge pull request #7 from CHProducts/dev
Browse files Browse the repository at this point in the history
change command name
  • Loading branch information
MotiCAT authored Jan 3, 2024
2 parents 92bd3fc + 31762e5 commit c1368cf
Show file tree
Hide file tree
Showing 46 changed files with 872 additions and 907 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Motcher

(多分)便利Bot

動作確認中
動作確認中
48 changes: 9 additions & 39 deletions src/Events/onInteractionCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ export async function onInteractionCreate(interaction: BaseInteraction): Promise
case 'about':
interactions.about(interaction);
break;
case 'addrole':
interactions.addrole(interaction);
break;
case 'avatar':
interactions.avatar(interaction);
break;
Expand All @@ -61,12 +58,6 @@ export async function onInteractionCreate(interaction: BaseInteraction): Promise
case 'clear':
interactions.clear(interaction);
break;
case 'deletejoin':
interactions.deletejoin(interaction);
break;
case 'deleteleave':
interactions.deleteleave(interaction);
break;
case 'help':
interactions.help(interaction);
break;
Expand All @@ -76,53 +67,32 @@ export async function onInteractionCreate(interaction: BaseInteraction): Promise
case 'invite':
interactions.invite(interaction);
break;
case 'joinmsg':
interactions.joinmsg(interaction);
case 'join':
interactions.join(interaction);
break;
case 'kick':
interactions.kick(interaction);
break;
case 'leavemsg':
interactions.leavemsg(interaction);
case 'leave':
interactions.leave(interaction);
break;
case 'log':
interactions.log(interaction);
break;
case 'mcskin':
interactions.mcskin(interaction);
break;
case 'mcstatus':
interactions.mcstatus(interaction);
break;
case 'memberlog':
interactions.memberlog(interaction);
break;
case 'memberlogstop':
interactions.memberlogstop(interaction);
break;
case 'msglog':
interactions.msglog(interaction);
break;
case 'msglogstop':
interactions.msglogstop(interaction);
break;
case 'ping':
interactions.ping(interaction);
break;
case 'remrole':
interactions.remrole(interaction);
break;
case 'resdelete':
interactions.resdelete(interaction);
break;
case 'resnow':
interactions.resnow(interaction);
break;
case 'response':
interactions.response(interaction);
break;
case 'rolelog':
interactions.rolelog(interaction);
break;
case 'rolelogstop':
interactions.rolelogstop(interaction);
case 'role':
interactions.role(interaction);
break;
case 'search':
interactions.search(interaction);
Expand Down
50 changes: 10 additions & 40 deletions src/Events/onMessageCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { readFileSync } from 'fs';

config();

const prefix = 'mc!';
const prefix = 'mt!';

export async function onMessageCreate(message: Message): Promise<Awaitable<void>> {
if (bannedUsers.includes(message.author.id)) return;
Expand Down Expand Up @@ -62,9 +62,6 @@ export async function onMessageCreate(message: Message): Promise<Awaitable<void>
case 'about':
commands.about(message);
break;
case 'addrole':
commands.addrole(message);
break;
case 'avatar':
commands.avatar(message);
break;
Expand All @@ -80,12 +77,6 @@ export async function onMessageCreate(message: Message): Promise<Awaitable<void>
case 'clear':
commands.clear(message);
break;
case 'deletejoin':
commands.deletejoin(message);
break;
case 'deleteleave':
commands.deleteleave(message);
break;
case 'help':
commands.help(message);
break;
Expand All @@ -95,36 +86,27 @@ export async function onMessageCreate(message: Message): Promise<Awaitable<void>
case 'invite':
commands.invite(message);
break;
case 'joinmsg':
commands.joinmsg(message);
case 'join':
commands.join(message);
break;
case 'kick':
commands.kick(message);
break;
case 'leavemsg':
commands.leavemsg(message);
case 'leave':
commands.leave(message);
break;
case 'log':
commands.log(message);
break;
case 'mcskin':
commands.mcskin(message);
break;
case 'mcstatus':
commands.mcstatus(message);
break;
case 'memberlog':
commands.memberlog(message);
break;
case 'memberlogstop':
commands.memberlogstop(message);
break;
case 'minvite':
commands.botinvite(message);
break;
case 'msglog':
commands.msglog(message);
break;
case 'msglogstop':
commands.msglogstop(message);
break;
case 'ping':
commands.ping(message);
break;
Expand All @@ -134,23 +116,11 @@ export async function onMessageCreate(message: Message): Promise<Awaitable<void>
case 'restart':
commands.restart(message);
break;
case 'remrole':
commands.remrole(message);
break;
case 'resdelete':
commands.resdelete(message);
break;
case 'resnow':
commands.resnow(message);
break;
case 'response':
commands.response(message);
break;
case 'rolelog':
commands.rolelog(message);
break;
case 'rolelogstop':
commands.rolelogstop(message);
case 'role':
commands.role(message);
break;
case 'run':
commands.run(message);
Expand Down
21 changes: 0 additions & 21 deletions src/commands/addrole.ts

This file was deleted.

22 changes: 0 additions & 22 deletions src/commands/deletejoin.ts

This file was deleted.

20 changes: 0 additions & 20 deletions src/commands/deleteleave.ts

This file was deleted.

36 changes: 8 additions & 28 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
import { aboutCommand } from './about';
import { addroleCommand } from './addrole';
import { avatarCommand } from './avatar';
import { banCommand } from './ban';
import { banlistCommand } from './banlist';
import { bannerCommand } from './banner';
import { botinviteCommand } from './botinvite';
import { clearCommand } from './clear';
import { deletejoinCommand } from './deletejoin';
import { deleteleaveCommand } from './deleteleave';
import { helpCommand } from './help';
import { inlistCommand } from './inlist';
import { inviteCommand } from './invite';
import { joinmsgCommand } from './joinmsg';
import { joinCommand } from './join';
import { kickCommand } from './kick';
import { leavemsgCommand } from './leavemsg';
import { leaveCommand } from './leave';
import { logCommand } from './log';
import { mcskinCommand } from './mcskin';
import { mcstatusCommand } from './mcstatus';
import { memberlogCommand } from './memberlog';
import { memberlogstopCommand } from './memberlogstop';
import { msglogCommand } from './msglog';
import { msglogstopCommand } from './msglogstop';
import { pingCommand } from './ping';
import { pollCommand } from './poll';
import { remroleCommand } from './remrole';
import { resdeleteCommand } from './resdelete';
import { resnowCommand } from './resnow';
import { responseCommand } from './response';
import { restartCommand } from './restart';
import { rolelogCommand } from './rolelog';
import { rolelogstopCommand } from './rolelogstop';
import { roleCommand } from './role';
import { runCommand } from './run';
import { scriptCommand } from './script';
import { searchCommand } from './search';
Expand All @@ -41,35 +31,25 @@ import { userCommand } from './user';
export const commands = {
help: helpCommand,
about: aboutCommand,
addrole: addroleCommand,
avatar: avatarCommand,
ban: banCommand,
banlist: banlistCommand,
banner: bannerCommand,
botinvite: botinviteCommand,
clear: clearCommand,
deletejoin: deletejoinCommand,
deleteleave: deleteleaveCommand,
inlist: inlistCommand,
invite: inviteCommand,
joinmsg: joinmsgCommand,
join: joinCommand,
kick: kickCommand,
leavemsg: leavemsgCommand,
leave: leaveCommand,
log: logCommand,
mcskin: mcskinCommand,
mcstatus: mcstatusCommand,
memberlog: memberlogCommand,
memberlogstop: memberlogstopCommand,
msglog: msglogCommand,
msglogstop: msglogstopCommand,
ping: pingCommand,
poll: pollCommand,
remrole: remroleCommand,
resdelete: resdeleteCommand,
resnow: resnowCommand,
response: responseCommand,
restart: restartCommand,
rolelog: rolelogCommand,
rolelogstop: rolelogstopCommand,
role: roleCommand,
run: runCommand,
script: scriptCommand,
search: searchCommand,
Expand Down
53 changes: 53 additions & 0 deletions src/commands/join.ts
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;
}
}
Loading

0 comments on commit c1368cf

Please sign in to comment.