Skip to content

Commit

Permalink
Better image api (deploy)
Browse files Browse the repository at this point in the history
  • Loading branch information
barbarbar338 committed Apr 30, 2024
1 parent d2696e8 commit 1b0c80d
Show file tree
Hide file tree
Showing 19 changed files with 1,752 additions and 3,048 deletions.
39 changes: 20 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,29 @@
"update": "taze latest -w"
},
"devDependencies": {
"@types/express": "^4.17.17",
"@types/node": "^20.2.5",
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
"@types/express": "^4.17.21",
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"cross-env": "^7.0.3",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"nodemon": "^2.0.22",
"prettier": "^2.8.8",
"rimraf": "^5.0.1",
"taze": "^0.10.1",
"ts-node": "^10.9.1",
"typescript": "^5.1.3"
"eslint": "^9.1.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"nodemon": "^3.1.0",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"taze": "^0.13.7",
"ts-node": "^10.9.2",
"typescript": "^5.4.5"
},
"dependencies": {
"@hammerhq/logger": "^0.1.5",
"@hammerhq/logger": "^2.2.0",
"canvas": "^2.11.2",
"discord.js": "^14.11.0",
"dotenv": "^16.1.3",
"express": "^4.18.2",
"mongodb-memory-server": "^8.12.2",
"mongoose": "^7.2.2"
"discord.js": "^14.14.1",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"mongodb-memory-server": "^9.2.0",
"mongoose": "^8.3.3",
"sharp": "^0.33.3"
}
}
Binary file removed src/assets/ellips1.png
Binary file not shown.
Binary file removed src/assets/ellips2.png
Binary file not shown.
Binary file removed src/assets/fonts/Poppins-Bold.ttf
Binary file not shown.
Binary file removed src/assets/fonts/Poppins-Light.ttf
Binary file not shown.
Binary file removed src/assets/fonts/Poppins-Regular.ttf
Binary file not shown.
Binary file removed src/assets/pin1.png
Binary file not shown.
Binary file removed src/assets/pin2.png
Binary file not shown.
Binary file removed src/assets/pin3.png
Binary file not shown.
Binary file removed src/assets/pin4.png
Binary file not shown.
Binary file removed src/assets/pin5.png
Binary file not shown.
Binary file removed src/assets/pin6.png
Binary file not shown.
Binary file removed src/assets/progress.png
Binary file not shown.
40 changes: 18 additions & 22 deletions src/commands/rank.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { SlashCommandBuilder,AttachmentBuilder } from "discord.js";
import { AttachmentBuilder, SlashCommandBuilder } from "discord.js";
import { CONFIG } from "../config";
import { GuildMemberModel } from "../models/GuildMemberModel";
import { UserModel } from "../models/UserModel";
import { registerFont } from "canvas";
import { GuildMemberVoiceModel } from "../models/GuildMemberVoiceModel";

registerFont(__dirname + '/../assets/fonts/Poppins-Bold.ttf', { family: 'Poppins Bold' });
registerFont(__dirname + '/../assets/fonts/Poppins-Light.ttf', { family: 'Poppins Light' });
registerFont(__dirname + '/../assets/fonts/Poppins-Regular.ttf', { family: 'Poppins Regular' });


const RankCommand: SlashLevel.ICommand = {
builder: new SlashCommandBuilder()
Expand Down Expand Up @@ -58,25 +51,28 @@ const RankCommand: SlashLevel.ICommand = {
const { xp, level } = guildMemberModel;
const requiredXP = client.utils.calculateRequiredExp(level + 1);

const dateObj = new Date();
const month = dateObj.getUTCMonth() + 1;
const year = dateObj.getUTCFullYear();
const newDate = `${year}/${month}`;
let voiceModel = await GuildMemberVoiceModel.findOne({
guildID: member.guild.id,
userID: member.id,
month: newDate
});
const userTime = !voiceModel ? 0 : voiceModel.time;
const img = await client.utils.createImage(member.user.tag,level,xp,requiredXP,member.displayAvatarURL({
extension: "png",
}),userTime)
const position =
(await GuildMemberModel.countDocuments({
guildID: interaction.guild!.id,
xp: { $gt: xp },
})) + 1;

const img = await client.utils.createLevelCard(
xp,
level,
requiredXP,
position,
member.user.displayAvatarURL({ extension: "png", size: 512 }),
member.presence?.status || "offline",
member.user.username,
userModel.rankColor,
"png",
);

const file = new AttachmentBuilder(img);
return interaction.editReply({
content: `🏆 Rank card of **${member.user.tag}**`,
files: [file]
files: [file],
});
},
};
Expand Down
1 change: 0 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const CONFIG = {
PORT: parseInt(process.env.PORT as string),
CLIENT_ID,
INVITE: `https://discord.com/oauth2/authorize?client_id=${CLIENT_ID}&scope=bot+applications.commands&permissions=268725328`,
IMAGE_API_URL: "http://localhost:3000/imageApi",
EXAMPLE_GIF: "https://338.rocks/slash-example.gif",
REPO_URL: "https://github.com/barisbored/slash-level",
PRESENCE: {
Expand Down
44 changes: 0 additions & 44 deletions src/events/voiceStateUpdate.ts

This file was deleted.

35 changes: 0 additions & 35 deletions src/models/GuildMemberVoiceModel.ts

This file was deleted.

Loading

0 comments on commit 1b0c80d

Please sign in to comment.