Skip to content

Commit fdf227f

Browse files
change: partial giveaway refactor
change: update deprecated Command.Context usage
1 parent 08743ed commit fdf227f

34 files changed

+192
-143
lines changed
Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import { getTextBasedChannel } from '#lib/discord-fetch';
2-
import { getEmbedBuilder, stringsToEmbedField } from '#lib/discord-messaging';
3-
import {
4-
GetGiveaways,
5-
GiveawayStatuses,
6-
isGiveawayStatus,
7-
} from '@/services/giveaway/index.js';
2+
import { FetchAndSendGiveaways } from '@/services/giveaway';
3+
import { GiveawayStatusEnum } from '@/services/giveaway/giveaway-status';
84
import { Command } from '@sapphire/framework';
95
import { PermissionsBitField } from 'discord.js';
106

117
export class FetchGiveawaysCommand extends Command {
12-
public constructor(context: Command.Context, options: Command.Options) {
8+
public constructor(context: Command.LoaderContext, options: Command.Options) {
139
super(context, {
1410
...options,
1511
description: 'Send giveaways to this channel',
@@ -44,34 +40,11 @@ export class FetchGiveawaysCommand extends Command {
4440
}
4541

4642
await interaction.editReply('Will search for new giveaways');
47-
const giveaways = await GetGiveaways();
48-
if (isGiveawayStatus(giveaways)) {
49-
const status = GiveawayStatuses[giveaways];
50-
return interaction.editReply(status.log_message);
51-
}
43+
const giveawayStatus = await FetchAndSendGiveaways(channel);
5244

53-
for (const giveaway of giveaways) {
54-
const embedFields = stringsToEmbedField(giveaway.body);
55-
const builder = getEmbedBuilder()
56-
.setTitle(giveaway.title)
57-
.addFields(embedFields);
58-
if (giveaway.imageURL) {
59-
builder.setImage(giveaway.imageURL);
60-
}
61-
const builtEmbed = builder.toJSON();
62-
await channel.send({ embeds: [builtEmbed] });
63-
return;
45+
if (giveawayStatus.status === GiveawayStatusEnum.SUCCESS) {
46+
return interaction.followUp('Giveaway fetch finished!');
6447
}
65-
return;
66-
// const result = await GetGiveaways(channel, {
67-
// noFilter: true,
68-
// ignorePreviousMessage: force,
69-
// });
70-
71-
// if (result === 'SUCCESS') {
72-
// void interaction.followUp('Giveaway fetch finished!');
73-
// } else {
74-
// void interaction.editReply(GiveawayFetchMessages[result]);
75-
// }
48+
return interaction.editReply(giveawayStatus.statusInformation.log_message);
7649
}
7750
}

src/commands/giveaways/subscribe-to-giveaways.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import cronstrue from 'cronstrue';
55
import { GiveawayNotifier } from '../../jobs/giveaways';
66

77
export class SubscribeToGiveawaysCommand extends Command {
8-
public constructor(context: Command.Context, options: Command.Options) {
8+
public constructor(context: Command.LoaderContext, options: Command.Options) {
99
super(context, {
1010
...options,
1111
description: `Start sending giveaways here ${cronstrue.toString(

src/commands/giveaways/unsubscribe-from-giveaways.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Command } from '@sapphire/framework';
33
import { PermissionsBitField } from 'discord.js';
44

55
export class UnsubscribeToGiveawaysCommand extends Command {
6-
public constructor(context: Command.Context, options: Command.Options) {
6+
public constructor(context: Command.LoaderContext, options: Command.Options) {
77
super(context, {
88
...options,
99
description: 'Stop sending giveaways here.',

src/commands/music/biquad.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type SupportedBiquadFilters = keyof typeof BiquadFilterType | 'Off';
88

99
// TODO: add run `runIn: 'GUILD_TEXT'` to all music commands
1010
export class BiquadCommand extends Command {
11-
public constructor(context: Command.Context, options: Command.Options) {
11+
public constructor(context: Command.LoaderContext, options: Command.Options) {
1212
super(context, {
1313
...options,
1414
description: 'The biquad filter that can be applied to tracks',

src/commands/music/clear.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Command } from '@sapphire/framework';
44
import { useQueue } from 'discord-player';
55

66
export class ClearCommand extends Command {
7-
public constructor(context: Command.Context, options: Command.Options) {
7+
public constructor(context: Command.LoaderContext, options: Command.Options) {
88
super(context, {
99
...options,
1010
description: 'Clears the current queue and removes all enqueued tracks',

src/commands/music/connect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useMainPlayer, useQueue } from 'discord-player';
55
import { GuildMember } from 'discord.js';
66

77
export class DisconnectCommand extends Command {
8-
public constructor(context: Command.Context, options: Command.Options) {
8+
public constructor(context: Command.LoaderContext, options: Command.Options) {
99
super(context, {
1010
...options,
1111
description:

src/commands/music/disconnect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Command } from '@sapphire/framework';
44
import { useQueue } from 'discord-player';
55

66
export class DisconnectCommand extends Command {
7-
public constructor(context: Command.Context, options: Command.Options) {
7+
public constructor(context: Command.LoaderContext, options: Command.Options) {
88
super(context, {
99
...options,
1010
description:

src/commands/music/dsp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Command } from '@sapphire/framework';
44
import { PCMAudioFilters, PCMFilters, useQueue } from 'discord-player';
55

66
export class PulsatorCommand extends Command {
7-
public constructor(context: Command.Context, options: Command.Options) {
7+
public constructor(context: Command.LoaderContext, options: Command.Options) {
88
super(context, {
99
...options,
1010
description: 'The DSP filters that can be applied to tracks',

src/commands/music/equaliser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Command } from '@sapphire/framework';
44
import { EqualizerConfigurationPreset, useQueue } from 'discord-player';
55

66
export class EqualizerCommand extends Command {
7-
public constructor(context: Command.Context, options: Command.Options) {
7+
public constructor(context: Command.LoaderContext, options: Command.Options) {
88
super(context, {
99
...options,
1010
description: 'The equaliser filter that can be applied to tracks',

src/commands/music/filters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Command } from '@sapphire/framework';
44
import { FiltersName, useQueue } from 'discord-player';
55

66
export class FiltersCommand extends Command {
7-
public constructor(context: Command.Context, options: Command.Options) {
7+
public constructor(context: Command.LoaderContext, options: Command.Options) {
88
super(context, {
99
...options,
1010
description: 'The FFmpeg filters that can be applied to tracks',

0 commit comments

Comments
 (0)