feat: Add Container.channel
This commit is contained in:
parent
69972c1b02
commit
5b5616b7aa
3 changed files with 25 additions and 5 deletions
13
src/init.ts
13
src/init.ts
|
@ -1,4 +1,5 @@
|
||||||
import { Config } from './config'
|
import { Config } from './config'
|
||||||
|
import { ReleaseChannel } from './lib/releaseChannel'
|
||||||
import { container } from '@sapphire/pieces'
|
import { container } from '@sapphire/pieces'
|
||||||
import { connect, disconnect } from 'mongoose'
|
import { connect, disconnect } from 'mongoose'
|
||||||
|
|
||||||
|
@ -13,6 +14,7 @@ declare module '@sapphire/pieces' {
|
||||||
fail: number
|
fail: number
|
||||||
success: number
|
success: number
|
||||||
}
|
}
|
||||||
|
channel: ReleaseChannel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,11 +28,20 @@ declare module '@sapphire/framework' {
|
||||||
container.dbDisconnect = async () => await disconnect()
|
container.dbDisconnect = async () => await disconnect()
|
||||||
container.config = new Config()
|
container.config = new Config()
|
||||||
container.prefix = container.config.bot.prefix
|
container.prefix = container.config.bot.prefix
|
||||||
container.version = '5.0.0-yogurt.e250308a'
|
container.version = '5.0.0-yogurt_canary.250308b'
|
||||||
container.embedColors = {
|
container.embedColors = {
|
||||||
default: 0xaddb87,
|
default: 0xaddb87,
|
||||||
fail: 0xff0000,
|
fail: 0xff0000,
|
||||||
success: 0x00ff00,
|
success: 0x00ff00,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (container.version.includes(ReleaseChannel.Release))
|
||||||
|
container.channel = ReleaseChannel.Release
|
||||||
|
else if (container.version.includes(ReleaseChannel.Preview))
|
||||||
|
container.channel = ReleaseChannel.Preview
|
||||||
|
else if (container.version.includes(ReleaseChannel.Dev))
|
||||||
|
container.channel = ReleaseChannel.Dev
|
||||||
|
else if (container.version.includes(ReleaseChannel.Canary))
|
||||||
|
container.channel = ReleaseChannel.Canary
|
||||||
|
|
||||||
await connect(container.config.databaseUrl)
|
await connect(container.config.databaseUrl)
|
||||||
|
|
6
src/lib/releaseChannel.ts
Normal file
6
src/lib/releaseChannel.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
export enum ReleaseChannel {
|
||||||
|
Release = 'release',
|
||||||
|
Preview = 'preview',
|
||||||
|
Dev = 'dev',
|
||||||
|
Canary = 'canary',
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
import { Learn, Text, type IText } from '../lib/databases'
|
import { Learn, Text, type IText } from '../lib/databases'
|
||||||
|
import { ReleaseChannel } from '../lib/releaseChannel'
|
||||||
import { Listener } from '@sapphire/framework'
|
import { Listener } from '@sapphire/framework'
|
||||||
import type { Message, TextChannel } from 'discord.js'
|
import type { Message, TextChannel } from 'discord.js'
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ export class MessageCreateListener extends Listener {
|
||||||
const content = msg.content.slice(this.container.prefix.length)
|
const content = msg.content.slice(this.container.prefix.length)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
this.container.channel === ReleaseChannel.Release &&
|
||||||
this.container.config.train.userId &&
|
this.container.config.train.userId &&
|
||||||
msg.author.id === this.container.config.train.userId
|
msg.author.id === this.container.config.train.userId
|
||||||
)
|
)
|
||||||
|
@ -32,10 +34,11 @@ export class MessageCreateListener extends Listener {
|
||||||
if ((msg.channel as TextChannel).nsfw) {
|
if ((msg.channel as TextChannel).nsfw) {
|
||||||
;(await Text.find()).forEach(data => datas.push(data))
|
;(await Text.find()).forEach(data => datas.push(data))
|
||||||
|
|
||||||
await new Text({
|
if (this.container.channel === ReleaseChannel.Release)
|
||||||
text: content,
|
await new Text({
|
||||||
persona: `user:${msg.author.username.slice(0, 45).toLowerCase()}`,
|
text: content,
|
||||||
}).save()
|
persona: `user:${msg.author.username.slice(0, 45).toLowerCase()}`,
|
||||||
|
}).save()
|
||||||
} else {
|
} else {
|
||||||
;(await Text.find({ persona: 'muffin' })).forEach(data =>
|
;(await Text.find({ persona: 'muffin' })).forEach(data =>
|
||||||
datas.push(data),
|
datas.push(data),
|
||||||
|
|
Reference in a new issue