Skip to content

Commit

Permalink
Merge pull request #25 from minesa-hub:new
Browse files Browse the repository at this point in the history
An huge update for O-codex.
  • Loading branch information
Neo authored Apr 20, 2023
2 parents bb0fd8e + e4affc7 commit 7da8bad
Show file tree
Hide file tree
Showing 40 changed files with 1,232 additions and 1,714 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ config.js
json.sqlite

# VSCode
.vscode
.vscode

# Environment variables
.env
1,011 changes: 623 additions & 388 deletions package-lock.json

Large diffs are not rendered by default.

23 changes: 11 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
{
"name": "o-codex",
"version": "1.2.0",
"description": "Minesa Hub's Bot",
"version": "2.0.0",
"description": "A Discord bot is doing unique things.",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
"start": "node src/index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/minesa-hub/Neobot.git"
"url": "git+https://github.com/minesa-hub/O-codex.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/minesa-hub/Neobot/issues"
"url": "https://github.com/minesa-hub/O-codex/issues"
},
"homepage": "https://github.com/minesa-hub/Neobot#readme",
"homepage": "https://github.com/minesa-hub/o-codex#readme",
"dependencies": {
"@iamtraction/google-translate": "^2.0.0",
"colors": "^1.4.0",
"discord.js": "^14.7.1",
"erela.js": "^2.4.0",
"node-fetch": "^3.2.10",
"openai": "^3.1.0"
"@iamtraction/google-translate": "^2.0.1",
"chalk": "^5.2.0",
"discord.js": "^14.9.0",
"dotenv": "^16.0.3",
"mongoose": "^7.0.4"
}
}
51 changes: 0 additions & 51 deletions src/commands/context menus/user-avatar.js

This file was deleted.

35 changes: 0 additions & 35 deletions src/commands/context menus/user-banner.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,40 @@ import { ApplicationCommandType, ContextMenuCommandBuilder } from 'discord.js';

export default {
data: new ContextMenuCommandBuilder()
.setName('Translate')
.setName('Translate Message')
.setNameLocalizations({
tr: 'Çevir',
it: 'Tradurre',
ChineseCN: '翻译',
ChineseCN: '翻译消息',
it: 'Traduci Messaggio',
tr: 'Mesajı Çevir',
})
.setType(ApplicationCommandType.Message),
async execute({ interaction }) {
// Getting the message from the context menu
const message = interaction.options.getMessage('message', true);
execute: async ({ interaction }) => {
await interaction.deferReply({ ephemeral: true });

// Getting the language from the command arguments
const message = interaction.options.getMessage('message');

if (!message.content)
return interaction.editReply({ content: 'There is no text in this message.' });
interaction.editReply({
content: 'Message has no content to translate.',
ephemeral: true,
});

try {
// Translating the message
const locale = !['zh-CN', 'zh-TW'].includes(interaction.locale)
? new Intl.Locale(interaction.locale).language
: interaction.locale;
const translated = await translate(
message.content.replace(/(<a?)?:\w+:(\d{18}>)?/g, ''),
{
to: locale,
},
{ to: locale },
);

// Sending the translated message
return interaction.editReply({ content: translated.text });
interaction.editReply({
content: translated.text,
});
} catch (error) {
// Sending an error message
return interaction.editReply({
interaction.editReply({
content: 'An error occurred while translating the message.',
ephemeral: true,
});
}
},
Expand Down
34 changes: 34 additions & 0 deletions src/commands/contextMenu/userAvatar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {
ContextMenuCommandBuilder,
ApplicationCommandType,
EmbedBuilder,
ButtonBuilder,
ButtonStyle,
ActionRowBuilder,
} from 'discord.js';

export default {
data: new ContextMenuCommandBuilder()
.setName('User Avatar')
.setNameLocalizations({
ChineseCN: '用户头像',
it: 'Avatar Utente',
tr: 'Kullanıcı Avatarı-',
})
.setType(ApplicationCommandType.User),
execute: async ({ interaction }) => {
await interaction.deferReply({ ephemeral: true });

const target = interaction.guild.members.cache.get(interaction.targetId);
const avatar = target.user.displayAvatarURL({ dynamic: true, size: 4096 });

const embed = new EmbedBuilder()
.setTitle(`${target.user.tag}'s Avatar`)
.setImage(avatar)
.setColor(0x1e1e1e);

await interaction.editReply({
embeds: [embed],
});
},
};
34 changes: 34 additions & 0 deletions src/commands/contextMenu/userBanner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { ContextMenuCommandBuilder, ApplicationCommandType, EmbedBuilder } from 'discord.js';

export default {
data: new ContextMenuCommandBuilder()
.setName('User Banner')
.setNameLocalizations({
ChineseCN: '用户横幅',
it: 'Banner Utente',
tr: 'Kullanıcı Afişi',
})
.setType(ApplicationCommandType.User),
execute: async ({ interaction, client }) => {
await interaction.deferReply({ ephemeral: true });

const user = client.users.fetch(interaction.targetId, { force: true });

user.then(async (resolved) => {
const imageURI = resolved.bannerURL({ dynamic: true, size: 4096 });
const embed = new EmbedBuilder()
.setTitle(`${resolved.tag}'s Banner`)
.setImage(imageURI)
.setColor(0x1e1e1e);

if (imageURI === null) {
await interaction.editReply({
content: 'User has no banner set.',
ephemeral: true,
});
} else {
await interaction.editReply({ embeds: [embed] });
}
});
},
};
57 changes: 0 additions & 57 deletions src/commands/general/generate-image.js

This file was deleted.

33 changes: 0 additions & 33 deletions src/commands/general/generate-meme.js

This file was deleted.

Loading

0 comments on commit 7da8bad

Please sign in to comment.