mirror of
https://github.com/BluemediaDev/muse.git
synced 2025-05-08 19:31:35 +02:00
Setup and migrate to Prisma (#456)
This commit is contained in:
parent
129d121364
commit
51d378e4cb
30 changed files with 605 additions and 273 deletions
|
@ -1,8 +1,8 @@
|
|||
import {TextChannel, Message, GuildChannel, ThreadChannel} from 'discord.js';
|
||||
import {injectable} from 'inversify';
|
||||
import {Settings} from '../models/index.js';
|
||||
import errorMsg from '../utils/error-msg.js';
|
||||
import Command from '.';
|
||||
import {prisma} from '../utils/db.js';
|
||||
|
||||
@injectable()
|
||||
export default class implements Command {
|
||||
|
@ -17,9 +17,13 @@ export default class implements Command {
|
|||
public async execute(msg: Message, args: string []): Promise<void> {
|
||||
if (args.length === 0) {
|
||||
// Show current settings
|
||||
const settings = await Settings.findByPk(msg.guild!.id);
|
||||
const settings = await prisma.setting.findUnique({
|
||||
where: {
|
||||
guildId: msg.guild!.id,
|
||||
},
|
||||
});
|
||||
|
||||
if (settings) {
|
||||
if (settings?.channel) {
|
||||
let response = `prefix: \`${settings.prefix}\`\n`;
|
||||
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
||||
response += `channel: ${msg.guild!.channels.cache.get(settings.channel)!.toString()}\n`;
|
||||
|
@ -47,7 +51,14 @@ export default class implements Command {
|
|||
case 'prefix': {
|
||||
const newPrefix = args[1];
|
||||
|
||||
await Settings.update({prefix: newPrefix}, {where: {guildId: msg.guild!.id}});
|
||||
await prisma.setting.update({
|
||||
where: {
|
||||
guildId: msg.guild!.id,
|
||||
},
|
||||
data: {
|
||||
prefix: newPrefix,
|
||||
},
|
||||
});
|
||||
|
||||
await msg.channel.send(`👍 prefix updated to \`${newPrefix}\``);
|
||||
break;
|
||||
|
@ -63,7 +74,14 @@ export default class implements Command {
|
|||
}
|
||||
|
||||
if (channel && channel.type === 'GUILD_TEXT') {
|
||||
await Settings.update({channel: channel.id}, {where: {guildId: msg.guild!.id}});
|
||||
await prisma.setting.update({
|
||||
where: {
|
||||
guildId: msg.guild!.id,
|
||||
},
|
||||
data: {
|
||||
channel: channel.id,
|
||||
},
|
||||
});
|
||||
|
||||
await Promise.all([
|
||||
(channel as TextChannel).send('hey apparently I\'m bound to this channel now'),
|
||||
|
@ -83,7 +101,15 @@ export default class implements Command {
|
|||
return;
|
||||
}
|
||||
|
||||
await Settings.update({playlistLimit}, {where: {guildId: msg.guild!.id}});
|
||||
await prisma.setting.update({
|
||||
where: {
|
||||
guildId: msg.guild!.id,
|
||||
},
|
||||
data: {
|
||||
playlistLimit,
|
||||
},
|
||||
});
|
||||
|
||||
await msg.channel.send(`👍 playlist-limit updated to ${playlistLimit}`);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue