2021-09-16 23:55:08 -07:00
import { CommandInteraction , Interaction , Message } from "discord.js" ;
2021-09-18 03:51:26 -07:00
import { getEmotes , makeSuccessEmbed , makeProcessingEmbed , sendMessageOrInteractionResponse , sendReply , makeInfoEmbed } from "../utils/DiscordMessage" ;
2021-09-15 06:05:57 -07:00
import DiscordProvider from "../providers/Discord" ;
2021-09-18 03:51:26 -07:00
import Cache from "../providers/Cache" ;
2021-09-15 06:05:57 -07:00
2021-09-18 03:51:26 -07:00
const EMBEDS = {
INFO : async ( data : Message | Interaction ) => {
2021-09-15 06:05:57 -07:00
2021-09-18 03:51:26 -07:00
let GuildCache = await Cache . getGuild ( data . guildId ! );
2022-01-27 17:59:07 +07:00
// TODO: Better error handling
if ( typeof GuildCache === 'undefined' )
throw new Error ( "Guild not found" );
2021-09-15 06:05:57 -07:00
2021-09-18 03:51:26 -07:00
let prefix = GuildCache . prefix || '>' ;
2021-09-15 06:05:57 -07:00
2021-09-18 03:51:26 -07:00
let _e = makeInfoEmbed ({
2021-09-15 06:05:57 -07:00
icon : "💌" ,
title : `Help - ${ DiscordProvider . client . user ? . username } ` ,
2022-01-30 21:50:18 +07:00
description : ` \ u200b \ n📰 **Info** \ nYumi is currently undergoing complete rewrite, as expected, losing many of her functionality. All of the features will be re-implemented. \ n \ n🤔 **Why?** \ nYumi was specifically written for use in a only 1 private server, now it's time to extend the border and globalize it (just kidding lol) \ n \ n🏷️ **Prefix** \ nYou can call me using \`\` ${ prefix . replaceAll ( '`' , '` ' ) } \`\`, <@ ${ DiscordProvider . client . user ? . id } > or \`\`/slash command\`\` \ n \ n💻 **Available commands**` ,
2021-09-15 06:05:57 -07:00
fields : [
{
2022-01-30 21:50:18 +07:00
name : '☕ General' ,
2022-02-05 01:20:14 +07:00
value : `help, ping, invite, userinfo, stats` ,
2022-01-30 21:50:18 +07:00
inline : true
2021-09-15 06:05:57 -07:00
},
{
2022-01-30 21:50:18 +07:00
name : '🎵 Music' ,
2022-02-05 00:32:02 +07:00
value : `play (p), search, skip, queue, nowplaying (np), join, leave` ,
2022-01-30 21:50:18 +07:00
inline : true
2021-09-15 06:05:57 -07:00
},
2021-09-18 03:51:26 -07:00
{
2022-01-30 21:50:18 +07:00
name : '🎮 Games' ,
value : `osu` ,
inline : true
2021-09-18 03:51:26 -07:00
},
2021-09-15 06:05:57 -07:00
{
2022-01-30 21:50:18 +07:00
name : '🔐 Admin' ,
value : `settings, say, membershipscreening (ms)` ,
inline : true
},
{
name : '🔧 Developer' ,
value : 'interactions, serviceannouncement' ,
inline : true
2022-02-02 22:13:27 +07:00
},
{
name : '\u200b' ,
value : '**Made with 💖 and [open source](https://github.com/YuzuZensai/Yumi)**' ,
inline : false
2021-09-15 06:05:57 -07:00
}
],
2021-09-18 03:51:26 -07:00
user : ( data instanceof Interaction ) ? data.user : data.author
2021-09-15 06:05:57 -07:00
});
2021-09-18 03:51:26 -07:00
_e . setThumbnail ( DiscordProvider . client . user ? . avatarURL () || '' );
return _e ;
}
}
2021-09-15 06:05:57 -07:00
2021-09-18 03:51:26 -07:00
export default class Help {
2021-09-15 06:05:57 -07:00
2021-09-18 03:51:26 -07:00
async onCommand ( command : string , args : any , message : Message ) {
if ( command . toLowerCase () !== 'help' ) return ;
await this . process ( message , args );
}
async interactionCreate ( interaction : CommandInteraction ) {
if ( interaction . isCommand ()) {
if ( typeof interaction . commandName === 'undefined' ) return ;
if (( interaction . commandName ). toLowerCase () !== 'help' ) return ;
await this . process ( interaction , interaction . options );
2021-09-15 06:05:57 -07:00
}
}
2021-09-18 03:51:26 -07:00
async process ( data : Interaction | Message , args : any ) {
const isSlashCommand = data instanceof CommandInteraction && data . isCommand ();
const isMessage = data instanceof Message ;
2021-09-18 05:44:59 -07:00
if ( ! isSlashCommand && ! isMessage ) return ;
2021-09-18 03:51:26 -07:00
let sent = await sendMessageOrInteractionResponse ( data , { embeds : [ await EMBEDS . INFO ( data )] });
if ( isMessage )
return ( sent as Message ). react ( "♥" );
}
2021-09-15 06:05:57 -07:00
}