mirror of
https://github.com/jaronpate/unicord.git
synced 2026-10-18 21:47:40 +00:00
improved repeated hydration test case
This commit is contained in:
@@ -5,6 +5,7 @@ export { Intent, Trait } from './types/common';
|
|||||||
export type { ClientConfig } from './types/common';
|
export type { ClientConfig } from './types/common';
|
||||||
export type { Context } from './types/context';
|
export type { Context } from './types/context';
|
||||||
export { Expectation } from './types/common';
|
export { Expectation } from './types/common';
|
||||||
|
export { ChannelType } from './types/channel';
|
||||||
// Consumable util classes
|
// Consumable util classes
|
||||||
export { Guild } from './types/guild';
|
export { Guild } from './types/guild';
|
||||||
export { Role } from './types/role';
|
export { Role } from './types/role';
|
||||||
|
|||||||
+10
-12
@@ -1,4 +1,4 @@
|
|||||||
import { ApplicationCommandType, Client, CommandOptionType, ComponentStyle, type Context, createCommandHandler, Expectation, Intent, InteractionCommpoentData, type InteractionData, Message, type MessagePayload } from '../src/index';
|
import { ApplicationCommandType, ChannelType, Client, CommandOptionType, ComponentStyle, type Context, createCommandHandler, Expectation, Intent, InteractionCommpoentData, type InteractionData, Message, type MessagePayload } from '../src/index';
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
token: process.env.BOT_TOKEN!,
|
token: process.env.BOT_TOKEN!,
|
||||||
@@ -7,7 +7,9 @@ const client = new Client({
|
|||||||
Intent.GUILDS,
|
Intent.GUILDS,
|
||||||
Intent.GUILD_MESSAGES,
|
Intent.GUILD_MESSAGES,
|
||||||
Intent.GUILD_MESSAGE_REACTIONS,
|
Intent.GUILD_MESSAGE_REACTIONS,
|
||||||
Intent.MESSAGE_CONTENT
|
Intent.MESSAGE_CONTENT,
|
||||||
|
Intent.DIRECT_MESSAGES,
|
||||||
|
Intent.DIRECT_MESSAGE_REACTIONS
|
||||||
],
|
],
|
||||||
prefix: '!!'
|
prefix: '!!'
|
||||||
});
|
});
|
||||||
@@ -76,23 +78,19 @@ Nice to meet you, I'm ${context.self.username}!`
|
|||||||
// Repeated hydration
|
// Repeated hydration
|
||||||
client.chatCommands.register('me', async (context: Context, _args: any[]) => {
|
client.chatCommands.register('me', async (context: Context, _args: any[]) => {
|
||||||
// Note: Testing repeated hydration
|
// Note: Testing repeated hydration
|
||||||
const { message } = await context.hydrate(context, [Expectation.Message])
|
const { message } = await context.hydrate(context, [Expectation.Message]);
|
||||||
const hydrated = await context.hydrate(message, [Expectation.Channel])
|
const { channel } = await context.hydrate(message, [Expectation.Channel]);
|
||||||
const rehydrated = await context.hydrate(hydrated, [Expectation.Guild]);
|
|
||||||
rehydrated.guild.name
|
|
||||||
|
|
||||||
const hydrate = await context.hydrator(hydrated, [Expectation.Guild]);
|
const hydrate = await context.hydrator(context, [Expectation.Guild]);
|
||||||
const hasGuild = hydrate(hydrated);
|
const hasGuild = hydrate(context);
|
||||||
|
|
||||||
if (hasGuild) {
|
if (hasGuild) {
|
||||||
// Send a message stating the user that they are in a guild
|
// Send a message stating the user that they are in a guild
|
||||||
await context.reply(`You are ${message.author.username} and this is ${hydrated.guild.name}`, true);
|
await context.reply(`You are ${message.author.username} and this is ${context.guild.name}`, true);
|
||||||
} else {
|
} else {
|
||||||
// Send a message stating the user that they are not in a guild
|
// Send a message stating the user that they are not in a guild
|
||||||
await context.reply(`You are ${message.author.username} and we are not in a server`, true);
|
await context.reply(`You are ${message.author.username} and we are in ${channel.type === ChannelType.DM ? 'our DM\'s 😘' : 'a Group 👀'}`, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// await context.reply(`You are ${message.author.username} ${hasGuild ? message.guild.name : ''}`, true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Hydrator - hydration function generator
|
// Hydrator - hydration function generator
|
||||||
|
|||||||
Reference in New Issue
Block a user