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 { ReleaseChannel } from './lib/releaseChannel'
|
||||
import { container } from '@sapphire/pieces'
|
||||
import { connect, disconnect } from 'mongoose'
|
||||
|
||||
|
@ -13,6 +14,7 @@ declare module '@sapphire/pieces' {
|
|||
fail: number
|
||||
success: number
|
||||
}
|
||||
channel: ReleaseChannel
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,11 +28,20 @@ declare module '@sapphire/framework' {
|
|||
container.dbDisconnect = async () => await disconnect()
|
||||
container.config = new Config()
|
||||
container.prefix = container.config.bot.prefix
|
||||
container.version = '5.0.0-yogurt.e250308a'
|
||||
container.version = '5.0.0-yogurt_canary.250308b'
|
||||
container.embedColors = {
|
||||
default: 0xaddb87,
|
||||
fail: 0xff0000,
|
||||
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)
|
||||
|
|
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 { ReleaseChannel } from '../lib/releaseChannel'
|
||||
import { Listener } from '@sapphire/framework'
|
||||
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)
|
||||
|
||||
if (
|
||||
this.container.channel === ReleaseChannel.Release &&
|
||||
this.container.config.train.userId &&
|
||||
msg.author.id === this.container.config.train.userId
|
||||
)
|
||||
|
@ -32,6 +34,7 @@ export class MessageCreateListener extends Listener {
|
|||
if ((msg.channel as TextChannel).nsfw) {
|
||||
;(await Text.find()).forEach(data => datas.push(data))
|
||||
|
||||
if (this.container.channel === ReleaseChannel.Release)
|
||||
await new Text({
|
||||
text: content,
|
||||
persona: `user:${msg.author.username.slice(0, 45).toLowerCase()}`,
|
||||
|
|
Reference in a new issue