This repository has been archived by the owner on Jan 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added embed service & commands |
v1.0.5-beta
- Loading branch information
CrawlTheDev
committed
Jun 8, 2021
1 parent
e41d6e1
commit 1df914a
Showing
19 changed files
with
342 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { ICommand, CommandContext } from '..'; | ||
|
||
export default class HelpCommand implements ICommand { | ||
name = 'help'; | ||
description = 'Shows all commands'; | ||
example = 'help [command-name]'; | ||
aliases = ['yardım']; | ||
|
||
async execute(ctx: CommandContext, commandName: string): Promise<void> { | ||
const guild = await ctx.database.findGuildById(ctx.guild.id); | ||
|
||
if (guild) { | ||
if (!commandName) { | ||
const HelpEmbed = ctx.embed.info(true, { | ||
title: 'Command Page', | ||
description: 'The commands you can use are listed', | ||
fields: [ | ||
{ | ||
name: 'Admin', | ||
value: '`change-prefix`', | ||
inline: true | ||
}, | ||
{ | ||
name: 'Core', | ||
value: '`invite`**,** `help`', | ||
inline: true | ||
} | ||
] | ||
}); | ||
await ctx.channel.send(HelpEmbed); | ||
} else { | ||
const commands = ctx.pbot.commandService.commands; | ||
const command = | ||
commands.get(commandName) ?? | ||
Array.from(commands.values()).find((c) => | ||
c.aliases?.some((a) => a === commandName) | ||
); | ||
|
||
if (command) { | ||
const commandDescription = | ||
command.description ?? "I couldn't find the command description"; | ||
const commandExample = | ||
command.example ?? "I couldn't find the command example"; | ||
const commandAliases = | ||
command.aliases?.map((alias) => `\`${alias}\``).join('**,** ') ?? | ||
"I couldn't find the command aliases"; | ||
const commandName = command.name; | ||
|
||
const CommandInfoEmbed = ctx.embed.info(true, { | ||
title: `[HELP] Command: ${commandName.toUpperCase()}`, | ||
description: commandDescription, | ||
fields: [ | ||
{ | ||
name: 'Example Usage', | ||
value: command.example | ||
? `\`${guild?.main.prefix}${commandExample}\`` | ||
: commandExample | ||
}, | ||
{ | ||
name: 'Aliases', | ||
value: commandAliases | ||
} | ||
] | ||
}); | ||
await ctx.channel.send(CommandInfoEmbed); | ||
} else { | ||
await ctx.channel.send( | ||
ctx.embed.error("I couldn't find this command") | ||
); | ||
} | ||
} | ||
} else { | ||
await ctx.channel.send( | ||
ctx.embed.error( | ||
`Guild with id **${ctx.guild.id}** not found in database` | ||
) | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import { MessageEmbed } from 'discord.js'; | ||
|
||
import { ICommand, CommandContext } from '..'; | ||
|
||
export default class InviteCommand implements ICommand { | ||
name = 'invite'; | ||
description = 'Allows you to add the bot'; | ||
example = 'invite'; | ||
aliases = ['davet-et']; | ||
|
||
async execute(ctx: CommandContext): Promise<void> { | ||
const invite_url = `https://discord.com/oauth2/authorize?client_id=${ctx.bot.user.id}&scope=bot&permissions=8`; | ||
const InviteEmbed = new MessageEmbed({ | ||
color: ctx.config.color.info, | ||
description: `Hello, [click here](${invite_url}) to invite me to guild` | ||
}); | ||
|
||
await ctx.channel.send(InviteEmbed); | ||
await ctx.channel.send( | ||
ctx.embed.info(false, { | ||
description: `Hello, [click here](${invite_url}) to invite me to guild` | ||
}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.