Skip to content

Commit 74fadd8

Browse files
committed
feat: rename commandChannel -> logChannel
1 parent 30bf9a2 commit 74fadd8

File tree

10 files changed

+41
-26
lines changed

10 files changed

+41
-26
lines changed

api-schema.graphql

+2-2
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ type BotRole {
220220

221221
type BotServer {
222222
adminRole: String
223+
botChannel: String
223224
botId: String!
224-
commandChannel: String
225225
createdAt: DateTime
226226
dryRun: Boolean
227227
enableSync: Boolean
@@ -835,7 +835,7 @@ input UserUpdateBotInput {
835835

836836
input UserUpdateBotServerInput {
837837
adminRole: String
838-
commandChannel: String
838+
botChannel: String
839839
dryRun: Boolean
840840
enableSync: Boolean
841841
mentionRoles: Boolean

libs/api/bot/data-access/src/lib/api-bot-manager.service.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,13 @@ export class ApiBotManagerService implements OnModuleInit {
189189
throw new Error(`Server ${serverId} not found for bot ${botId}`)
190190
}
191191

192-
const { dryRun, commandChannel, mentionRoles, mentionUsers, verbose } = botServer
192+
const { dryRun, botChannel, mentionRoles, mentionUsers, verbose } = botServer
193193

194194
async function sendCommandChannel(message: string) {
195-
if (!commandChannel) {
195+
if (!botChannel) {
196196
return
197197
}
198-
await botInstance.sendChannel(commandChannel, message)
198+
await botInstance.sendChannel(botChannel, message)
199199
}
200200

201201
const communityRoleIds = Object.values(communityRoles).flat()
@@ -304,7 +304,7 @@ export class ApiBotManagerService implements OnModuleInit {
304304
if (!botServer) {
305305
throw new Error(`Bot server ${serverId} not found`)
306306
}
307-
if (!botServer.commandChannel) {
307+
if (!botServer.botChannel) {
308308
throw new Error(`This bot does not have a command channel set`)
309309
}
310310
const identity = await this.core.data.identity.findFirst({
@@ -315,15 +315,15 @@ export class ApiBotManagerService implements OnModuleInit {
315315
}
316316
const summary = await this.getCommunityRoleSummary(bot.communityId)
317317

318-
await discordBot.sendChannel(botServer.commandChannel, {
318+
await discordBot.sendChannel(botServer.botChannel, {
319319
embeds: [
320320
{
321321
title: `Configuration for ${discordBot.client?.user?.username} in ${bot.community.name} (${bot.community.cluster})`,
322322
fields: [
323323
{ name: 'Requester', value: `<@${identity.providerId}>` },
324324
{ name: `Bot`, value: `<@${discordBot.client?.user?.id}>` },
325325
{ name: `Admin Role`, value: botServer.adminRole ? `<@&${botServer.adminRole}>` : 'Not set' },
326-
{ name: `Command Channel`, value: `<#${botServer.commandChannel}>` },
326+
{ name: `Bot Channel`, value: `<#${botServer.botChannel}>` },
327327
{ name: `Dry Run`, value: botServer.dryRun ? 'Enabled' : 'Disabled' },
328328
{ name: `Enable Sync`, value: botServer.enableSync ? 'Enabled' : 'Disabled' },
329329
{ name: 'Roles:', value: `There are ${summary.length} roles in this community` },

libs/api/bot/data-access/src/lib/dto/user-update-bot-server.input.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class UserUpdateBotServerInput {
55
@Field({ nullable: true })
66
adminRole?: string
77
@Field({ nullable: true })
8-
commandChannel?: string
8+
botChannel?: string
99
@Field({ nullable: true })
1010
dryRun?: boolean
1111
@Field({ nullable: true })

libs/api/bot/data-access/src/lib/entity/bot-server.entity.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class BotServer {
2121
@Field({ nullable: true })
2222
adminRole?: string
2323
@Field({ nullable: true })
24-
commandChannel?: string
24+
botChannel?: string
2525
@Field({ nullable: true })
2626
dryRun?: boolean
2727
@Field({ nullable: true })

libs/api/core/data-access/src/lib/api-core-provision-data.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ const PK_BOT: Prisma.BotCreateWithoutCommunityInput = {
119119
enableSync: true,
120120
dryRun: true,
121121
verbose: true,
122-
commandChannel: PK_SERVER_LOGS,
122+
botChannel: PK_SERVER_LOGS,
123123
},
124124
{
125125
serverId: DL_SERVER,
126126
enableSync: true,
127127
dryRun: true,
128128
verbose: true,
129-
commandChannel: DL_LOGS_DEV,
129+
botChannel: DL_LOGS_DEV,
130130
},
131131
],
132132
},

libs/api/core/data-access/src/lib/api-core.service.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,21 @@ import { slugifyId, slugifyUsername } from './helpers/slugify-id'
88
export class ApiCoreService {
99
private readonly logger = new Logger(ApiCoreService.name)
1010
readonly data: ApiCorePrismaClient = prismaClient
11-
constructor(readonly config: ApiCoreConfigService) {}
11+
constructor(readonly config: ApiCoreConfigService) {
12+
// Find the botServer entities that have a `commandChannel` value and migrate that to `botChannel`
13+
this.data.botServer.findMany({ where: { commandChannel: { not: null } } }).then((servers) =>
14+
servers.map((server) =>
15+
this.data.botServer
16+
.update({
17+
where: { id: server.id },
18+
data: { botChannel: server.commandChannel, commandChannel: null },
19+
})
20+
.then((updated) => {
21+
this.logger.verbose(`Migrated commandChannel to botChannel for ${updated.id}`)
22+
}),
23+
),
24+
)
25+
}
1226

1327
async createCommunity({ input, userId }: { input: Prisma.CommunityCreateInput; userId?: string }) {
1428
const id = slugifyId(input.name).toLowerCase()

libs/sdk/src/generated/graphql-sdk.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ export type BotRole = {
247247
export type BotServer = {
248248
__typename?: 'BotServer'
249249
adminRole?: Maybe<Scalars['String']['output']>
250+
botChannel?: Maybe<Scalars['String']['output']>
250251
botId: Scalars['String']['output']
251-
commandChannel?: Maybe<Scalars['String']['output']>
252252
createdAt?: Maybe<Scalars['DateTime']['output']>
253253
dryRun?: Maybe<Scalars['Boolean']['output']>
254254
enableSync?: Maybe<Scalars['Boolean']['output']>
@@ -1346,7 +1346,7 @@ export type UserUpdateBotInput = {
13461346

13471347
export type UserUpdateBotServerInput = {
13481348
adminRole?: InputMaybe<Scalars['String']['input']>
1349-
commandChannel?: InputMaybe<Scalars['String']['input']>
1349+
botChannel?: InputMaybe<Scalars['String']['input']>
13501350
dryRun?: InputMaybe<Scalars['Boolean']['input']>
13511351
enableSync?: InputMaybe<Scalars['Boolean']['input']>
13521352
mentionRoles?: InputMaybe<Scalars['Boolean']['input']>
@@ -1530,7 +1530,7 @@ export type BotServerDetailsFragment = {
15301530
botId: string
15311531
serverId: string
15321532
adminRole?: string | null
1533-
commandChannel?: string | null
1533+
botChannel?: string | null
15341534
dryRun?: boolean | null
15351535
enableSync?: boolean | null
15361536
mentionRoles?: boolean | null
@@ -1853,7 +1853,7 @@ export type UserFindOneBotServerQuery = {
18531853
botId: string
18541854
serverId: string
18551855
adminRole?: string | null
1856-
commandChannel?: string | null
1856+
botChannel?: string | null
18571857
dryRun?: boolean | null
18581858
enableSync?: boolean | null
18591859
mentionRoles?: boolean | null
@@ -1928,7 +1928,7 @@ export type UserTestBotServerConfigMutation = {
19281928
botId: string
19291929
serverId: string
19301930
adminRole?: string | null
1931-
commandChannel?: string | null
1931+
botChannel?: string | null
19321932
dryRun?: boolean | null
19331933
enableSync?: boolean | null
19341934
mentionRoles?: boolean | null
@@ -1953,7 +1953,7 @@ export type UserUpdateBotServerMutation = {
19531953
botId: string
19541954
serverId: string
19551955
adminRole?: string | null
1956-
commandChannel?: string | null
1956+
botChannel?: string | null
19571957
dryRun?: boolean | null
19581958
enableSync?: boolean | null
19591959
mentionRoles?: boolean | null
@@ -6161,7 +6161,7 @@ export const BotServerDetailsFragmentDoc = gql`
61616161
botId
61626162
serverId
61636163
adminRole
6164-
commandChannel
6164+
botChannel
61656165
dryRun
61666166
enableSync
61676167
mentionRoles
@@ -10449,7 +10449,7 @@ export function UserUpdateBotInputSchema(): z.ZodObject<Properties<UserUpdateBot
1044910449
export function UserUpdateBotServerInputSchema(): z.ZodObject<Properties<UserUpdateBotServerInput>> {
1045010450
return z.object({
1045110451
adminRole: z.string().nullish(),
10452-
commandChannel: z.string().nullish(),
10452+
botChannel: z.string().nullish(),
1045310453
dryRun: z.boolean().nullish(),
1045410454
enableSync: z.boolean().nullish(),
1045510455
mentionRoles: z.boolean().nullish(),

libs/sdk/src/graphql/feature-bot.graphql

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fragment BotServerDetails on BotServer {
2222
botId
2323
serverId
2424
adminRole
25-
commandChannel
25+
botChannel
2626
dryRun
2727
enableSync
2828
mentionRoles

libs/web/bot/ui/src/lib/user-bot-server-ui-update-form.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function UserBotServerUiUpdateForm({
2727
const form = useForm<UserUpdateBotServerInput>({
2828
initialValues: {
2929
adminRole: botServer.adminRole,
30-
commandChannel: botServer.commandChannel,
30+
botChannel: botServer.botChannel,
3131
dryRun: botServer.dryRun ?? false,
3232
enableSync: botServer.enableSync ?? false,
3333
mentionRoles: botServer.mentionRoles ?? false,
@@ -53,10 +53,10 @@ export function UserBotServerUiUpdateForm({
5353
{...form.getInputProps('adminRole')}
5454
/>
5555
<DiscordUiChannelSelect
56-
label="Command Channel"
57-
description="The channel where the bot will listen for commands and log events."
56+
label="Bot Channel"
57+
description="The channel where the bot will send log events."
5858
data={channels}
59-
{...form.getInputProps('commandChannel')}
59+
{...form.getInputProps('botChannel')}
6060
/>
6161
<Checkbox
6262
label="Dry Run"

prisma/schema.prisma

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ model BotServer {
5050
mentionUsers Boolean @default(false)
5151
verbose Boolean @default(false)
5252
adminRole String?
53+
botChannel String?
5354
commandChannel String?
5455
5556
@@unique([botId, serverId])

0 commit comments

Comments
 (0)