Skip to content

Commit

Permalink
cleanup & rm obsolete "thanos snap"
Browse files Browse the repository at this point in the history
  • Loading branch information
d-shaun committed Nov 7, 2022
1 parent ce47f1b commit becec01
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 75 deletions.
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ SPOTIFY_SECRETID: Spotify client ID for the &chart command to show artist images
genius_api: GENIUS_API,

url: GLOBALS.LASTFM_ENDPOINT,
}).init_dev();
}).init();

const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildPresences],
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/CrownBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class CrownBot {
* - Finally, logs the bot in.
*/

async init_dev() {
async init() {
await this.load_db();
this.load_models();
await this.register_commands();
Expand Down
61 changes: 0 additions & 61 deletions src/handlers/DB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { UserTopArtist } from "../interfaces/ArtistInterface";
import { DBUser } from "../interfaces/DBUserInterface";
import { LeaderboardInterface } from "../interfaces/LeaderboardInterface";
import { ServerConfigInterface } from "../models/ServerConfig";
import { SnapLogInterface } from "../models/SnapLog";

export default class DB {
#models: { [key: string]: Model<any> };
Expand Down Expand Up @@ -342,64 +341,4 @@ export default class DB {
}
return server_config;
}

/// TEMPORARY HELPER FUNCTIONS FOR &eval command snap AND WHATEVER IT AFFECTS
// (https://discord.com/channels/657915913567469588/663355060058718228/879388787489276034)

async find_multiple_usernames(): Promise<SnapLogInterface[]> {
return await this.#models.crowns.aggregate([
{
$group: {
_id: { userID: "$userID", guildID: "$guildID" },
usernames: { $addToSet: "$lastfm_username" },
},
},
{
$project: {
_id: 0,
userID: "$_id.userID",
guildID: "$_id.guildID",
username_count: {
$size: "$usernames",
},
},
},
{
$match: {
username_count: {
$gt: 1,
},
},
},
]);
}

async check_snap(guildID: string, userID: string) {
const snap_log = await this.#models.snaplog.findOne({ userID, guildID });
return !!snap_log;
}

async snap(guildID: string, userID: string) {
return await this.#models.snaplog.findOneAndUpdate(
{
userID,
guildID,
},
{
userID,
guildID,
},
{
upsert: true,
useFindAndModify: false,
}
);
}

async unsnap(guildID: string, userID: string) {
return await this.#models.snaplog.deleteMany({
userID,
guildID,
});
}
}
12 changes: 0 additions & 12 deletions src/models/SnapLog.ts

This file was deleted.

0 comments on commit becec01

Please sign in to comment.