Skip to content

Commit

Permalink
fix: remove pieces of code that used NetworkManager class
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-737 committed May 6, 2024
1 parent 54f4802 commit 0c15352
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
7 changes: 3 additions & 4 deletions src/commands/context-menu/editMsg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import db from '../../utils/Db.js';
import BaseCommand from '../../core/BaseCommand.js';
import { HubSettingsBitField } from '../../utils/BitFields.js';
import { checkIfStaff, replaceLinks, userVotedToday } from '../../utils/Utils.js';
import { checkIfStaff, getAttachmentURL, replaceLinks, userVotedToday } from '../../utils/Utils.js';
import { censor } from '../../utils/Profanity.js';
import { RegisterInteractionHandler } from '../../decorators/Interaction.js';
import { CustomID } from '../../utils/CustomID.js';
Expand Down Expand Up @@ -203,13 +203,12 @@ export default class EditMessage extends BaseCommand {
}

static async getImageUrls(target: Message, newMessage: string) {
const { networkManager } = target.client;
// get image from embed
// get image from content
const oldImageUrl = target.content
? await networkManager.getAttachmentURL(target.content)
? await getAttachmentURL(target.content)
: target.embeds[0]?.image?.url;
const newImageUrl = await networkManager.getAttachmentURL(newMessage);
const newImageUrl = await getAttachmentURL(newMessage);
return { oldImageUrl, newImageUrl };
}

Expand Down
4 changes: 2 additions & 2 deletions src/commands/slash/Main/hub/browse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
calculateAverageRating,
getOrCreateWebhook,
parseTimestampFromId,
sendToHub,
simpleEmbed,
} from '../../../../utils/Utils.js';
import { showOnboarding } from '../../../../scripts/network/onboarding.js';
Expand Down Expand Up @@ -362,7 +363,6 @@ export default class Browse extends Hub {
const webhook = await getOrCreateWebhook(channel);
if (!webhook) return;

const networkManager = interaction.client.networkManager;
// finally make the connection
await db.connectedList.create({
data: {
Expand Down Expand Up @@ -391,7 +391,7 @@ export default class Browse extends Hub {
});

// announce
await networkManager.sendToHub(hubDetails.id, {
await sendToHub(hubDetails.id, {
username: `InterChat | ${hubDetails.name}`,
content: stripIndents`
A new server has joined the hub! ${emojis.clipart}
Expand Down
5 changes: 2 additions & 3 deletions src/commands/slash/Main/hub/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Hub from './index.js';
import db from '../../../../utils/Db.js';
import BlacklistManager from '../../../../managers/BlacklistManager.js';
import { hubs } from '@prisma/client';
import { simpleEmbed, getOrCreateWebhook } from '../../../../utils/Utils.js';
import { simpleEmbed, getOrCreateWebhook, sendToHub } from '../../../../utils/Utils.js';
import { showOnboarding } from '../../../../scripts/network/onboarding.js';
import { stripIndents } from 'common-tags';
import { t } from '../../../../utils/Locale.js';
Expand All @@ -14,7 +14,6 @@ export default class JoinSubCommand extends Hub {
if (!interaction.inCachedGuild()) return;

const locale = interaction.user.locale;
const networkManager = interaction.client.networkManager;

// FIXME: Change later
const hubName = interaction.options.getString('hub') ?? 'InterChat Central';
Expand Down Expand Up @@ -181,7 +180,7 @@ export default class JoinSubCommand extends Hub {
});

// announce
await networkManager.sendToHub(hub.id, {
await sendToHub(hub.id, {
username: `InterChat | ${hub.name}`,
content: stripIndents`
A new server has joined the hub! ${emojis.clipart}
Expand Down
2 changes: 0 additions & 2 deletions src/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ClusterClient } from 'discord-hybrid-sharding';
import { Collection, Snowflake } from 'discord.js';
import { Scheduler } from '../services/SchedulerService.ts';
import NSFWClient from '../utils/NSFWDetection.ts';
import NetworkManager from '../managers/NetworkManager.ts';
import BlacklistManager from '../managers/BlacklistManager.ts';
import CommandManager from '../managers/CommandManager.ts';
import CooldownService from '../services/CooldownService.ts';
Expand Down Expand Up @@ -46,7 +45,6 @@ declare module 'discord.js' {
get cachePopulated(): boolean;

commandManager: CommandManager;
networkManager: NetworkManager;
blacklistManager: BlacklistManager;
nsfwDetector: NSFWClient;
}
Expand Down

0 comments on commit 0c15352

Please sign in to comment.