mirror of
https://github.com/kirameki-cafe/Yumi.git
synced 2026-09-13 18:59:19 +00:00
Add user data caching
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ import { sendHybridInteractionMessageResponse, makeInfoEmbed } from '../utils/Di
|
||||
|
||||
const EMBEDS = {
|
||||
INFO: async (data: Message | Interaction) => {
|
||||
let GuildCache = await Cache.getGuild(data.guildId!);
|
||||
let GuildCache = await Cache.getCachedGuild(data.guildId!);
|
||||
|
||||
// TODO: Better error handling
|
||||
if (typeof GuildCache === 'undefined') throw new Error('Guild not found');
|
||||
|
||||
@@ -60,7 +60,7 @@ const EMBEDS = {
|
||||
});
|
||||
},
|
||||
NO_SERVICE_ANNOUNCEMENT_STATUS_PROVIDED: async (data: Message | Interaction) => {
|
||||
let GuildCache = await Cache.getGuild(data.guild!.id);
|
||||
let GuildCache = await Cache.getCachedGuild(data.guild!.id);
|
||||
|
||||
// TODO: Better error handling
|
||||
if (typeof GuildCache === 'undefined') throw new Error('Guild not found');
|
||||
@@ -288,7 +288,7 @@ export default class Settings extends DiscordModule {
|
||||
});
|
||||
|
||||
await Cache.updateGuildCache(data.getGuild()!.id);
|
||||
let GuildCache = await Cache.getGuild(data.getGuild()!.id);
|
||||
let GuildCache = await Cache.getCachedGuild(data.getGuild()!.id);
|
||||
|
||||
const newStatusBool = ['true', 'yes', 'y', 'enable'].includes(
|
||||
newStatus.toLowerCase()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { User as PrismaUser } from '@prisma/client';
|
||||
import {
|
||||
Message,
|
||||
Interaction,
|
||||
@@ -16,6 +17,7 @@ import {
|
||||
|
||||
import DiscordMusicPlayer from '../../providers/DiscordMusicPlayer';
|
||||
import Users from '../../services/Users';
|
||||
import Cache from '../../providers/Cache';
|
||||
|
||||
const EMBEDS = {
|
||||
DEBUG_INFO: (data: Message | Interaction) => {
|
||||
@@ -25,7 +27,7 @@ const EMBEDS = {
|
||||
fields: [
|
||||
{
|
||||
name: 'Available arguments',
|
||||
value: '``invalidInteraction`` ``crashMusicPlayer`` ``crash`` ``activemusicplayer``'
|
||||
value: '``invalidInteraction`` ``crashMusicPlayer`` ``crash`` ``activemusicplayer`` ``mydata``'
|
||||
}
|
||||
],
|
||||
user: data instanceof Interaction ? data.user : data.author
|
||||
@@ -53,6 +55,14 @@ const EMBEDS = {
|
||||
user: data instanceof Interaction ? data.user : data.author
|
||||
});
|
||||
},
|
||||
YOUR_USER_DATA: (data: Message | Interaction, userData?: PrismaUser) => {
|
||||
return makeInfoEmbed({
|
||||
icon: '📃',
|
||||
title: `Your user data`,
|
||||
description: JSON.stringify(userData),
|
||||
user: data instanceof Interaction ? data.user : data.author
|
||||
});
|
||||
},
|
||||
NOT_DEVELOPER: (data: Message | Interaction) => {
|
||||
return makeErrorEmbed({
|
||||
title: 'Developer only',
|
||||
@@ -127,6 +137,14 @@ export default class Debug extends DiscordModule {
|
||||
]
|
||||
});
|
||||
},
|
||||
myData: async (data: HybridInteractionMessage) => {
|
||||
const userData = await Cache.getCachedUser(user.id);
|
||||
await sendHybridInteractionMessageResponse(data, {
|
||||
embeds: [
|
||||
EMBEDS.YOUR_USER_DATA(data.getRaw(), userData)
|
||||
]
|
||||
});
|
||||
},
|
||||
invalidInteraction: async (data: HybridInteractionMessage) => {
|
||||
const row = new MessageActionRow().addComponents(
|
||||
new MessageButton()
|
||||
@@ -170,6 +188,8 @@ export default class Debug extends DiscordModule {
|
||||
return await funct.crashMusicPlayer(data);
|
||||
case 'activemusicplayer':
|
||||
return await funct.activeMusicPlayer(data);
|
||||
case 'mydata':
|
||||
return await funct.myData(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user