aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorThongrapee Panyapatiphan <[email protected]>2021-12-09 17:55:29 +0700
committerThongrapee Panyapatiphan <[email protected]>2021-12-09 17:55:29 +0700
commitd8086be5cf1ab7152a6dc27ada78b3d186d85220 (patch)
tree1d9fa4aa618cd0266e1266818a80e3b636d8a8e0 /src/utils
parent33b0ffa244eaa33a75f16790678390aad8f3d3ff (diff)
parent9afca25866830dacc668b1861bab5c12260de639 (diff)
downloadmuse-d8086be5cf1ab7152a6dc27ada78b3d186d85220.tar.xz
muse-d8086be5cf1ab7152a6dc27ada78b3d186d85220.zip
Merge branch 'master' into playlist-limit-config
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/channels.ts10
-rw-r--r--src/utils/db.ts4
2 files changed, 7 insertions, 7 deletions
diff --git a/src/utils/channels.ts b/src/utils/channels.ts
index 4c5b6b0..2d074b4 100644
--- a/src/utils/channels.ts
+++ b/src/utils/channels.ts
@@ -3,8 +3,8 @@ import {Guild, VoiceChannel, User, GuildMember} from 'discord.js';
export const isUserInVoice = (guild: Guild, user: User): boolean => {
let inVoice = false;
- guild.channels.cache.filter(channel => channel.type === 'voice').forEach(channel => {
- if (channel.members.array().find(member => member.id === user.id)) {
+ guild.channels.cache.filter(channel => channel.type === 'GUILD_VOICE').forEach(channel => {
+ if ((channel as VoiceChannel).members.find(member => member.id === user.id)) {
inVoice = true;
}
});
@@ -12,7 +12,7 @@ export const isUserInVoice = (guild: Guild, user: User): boolean => {
return inVoice;
};
-export const getSizeWithoutBots = (channel: VoiceChannel): number => channel.members.array().reduce((s, member) => {
+export const getSizeWithoutBots = (channel: VoiceChannel): number => channel.members.reduce((s, member) => {
if (!member.user.bot) {
s++;
}
@@ -22,7 +22,7 @@ export const getSizeWithoutBots = (channel: VoiceChannel): number => channel.mem
export const getMemberVoiceChannel = (member?: GuildMember): [VoiceChannel, number] | null => {
const channel = member?.voice?.channel;
- if (channel && channel.type === 'voice') {
+ if (channel && channel.type === 'GUILD_VOICE') {
return [
channel,
getSizeWithoutBots(channel),
@@ -41,7 +41,7 @@ export const getMostPopularVoiceChannel = (guild: Guild): [VoiceChannel, number]
const voiceChannels: PopularResult[] = [];
for (const [_, channel] of guild.channels.cache) {
- if (channel.type === 'voice') {
+ if (channel.type === 'GUILD_VOICE') {
const size = getSizeWithoutBots(channel as VoiceChannel);
voiceChannels.push({
diff --git a/src/utils/db.ts b/src/utils/db.ts
index be42013..15a2d79 100644
--- a/src/utils/db.ts
+++ b/src/utils/db.ts
@@ -1,12 +1,12 @@
import {Sequelize} from 'sequelize-typescript';
import path from 'path';
import {DATA_DIR} from '../services/config.js';
-import {Cache, Settings, Shortcut} from '../models/index.js';
+import {FileCache, KeyValueCache, Settings, Shortcut} from '../models/index.js';
export const sequelize = new Sequelize({
dialect: 'sqlite',
database: 'muse',
storage: path.join(DATA_DIR, 'db.sqlite'),
- models: [Cache, Settings, Shortcut],
+ models: [FileCache, KeyValueCache, Settings, Shortcut],
logging: false,
});