Skip to content
This repository has been archived by the owner on Apr 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #31 from Catboi8/interactions
Browse files Browse the repository at this point in the history
Interactions
  • Loading branch information
JustCat80 authored Jul 13, 2021
2 parents 5b60c50 + a2d340a commit cef886a
Show file tree
Hide file tree
Showing 18 changed files with 244 additions and 191 deletions.
4 changes: 2 additions & 2 deletions examples/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bot.on("error", (err) => {
bot.on("messageCreate", (msg) => { // When a message is created
if(msg.content === "!embed") { // If the message content is "!embed"
bot.createMessage(msg.channel.id, {
embed: {
embeds: [{
title: "I'm an embed!", // Title of the embed
description: "Here is some more info, with **awesome** formatting.\nPretty *neat*, huh?",
author: { // Author property
Expand All @@ -37,7 +37,7 @@ bot.on("messageCreate", (msg) => { // When a message is created
footer: { // Footer text
text: "Created with Eris."
}
}
}]
});
}
});
Expand Down
120 changes: 77 additions & 43 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ declare namespace Eris {
// Guild
type DefaultNotifications = 0 | 1;
type ExplicitContentFilter = 0 | 1 | 2;
type NSFWLevel = 0 | 1 | 2 | 3;
type PossiblyUncachedGuild = Guild | Uncached;
type PremiumTier = 0 | 1 | 2 | 3;
type VerificationLevel = 0 | 1 | 2 | 3 | 4;
Expand All @@ -76,7 +77,9 @@ declare namespace Eris {
allowedMentions?: AllowedMentions;
components?: ActionRow[];
content?: string;
/** @deprecated */
embed?: EmbedOptions;
embeds?: EmbedOptions[];
flags?: number;
messageReference?: MessageReferenceReply;
/** @deprecated */
Expand All @@ -93,7 +96,7 @@ declare namespace Eris {
type InteractionType = 1 | 2 | 3;

// Permission
type PermissionType = "role" | "member";
type PermissionType = 0 | 1;

// Presence/Relationship
type ActivityType = BotActivityType | 4;
Expand Down Expand Up @@ -230,8 +233,7 @@ declare namespace Eris {
firstShardID?: number;
getAllUsers?: boolean;
guildCreateTimeout?: number;
guildSubscriptions?: boolean;
intents?: number | IntentStrings[];
intents: number | IntentStrings[];
largeThreshold?: number;
lastShardID?: number;
/** @deprecated */
Expand Down Expand Up @@ -440,7 +442,9 @@ declare namespace Eris {
maxVideoChannelUsers?: number;
mfaLevel: MFALevel;
name: string;
/** @deprecated */
nsfw: boolean;
nsfwLevel: NSFWLevel;
ownerID: string;
preferredLocale?: string;
premiumSubscriptionCount?: number;
Expand Down Expand Up @@ -691,9 +695,6 @@ declare namespace Eris {
limit?: number;
userID?: string;
}
interface GetGuildIntegrationsOptions {
includeApplications?: boolean;
}
interface GetPruneOptions {
days?: number;
includeRoles?: string[];
Expand Down Expand Up @@ -751,9 +752,9 @@ declare namespace Eris {
summary: string;
}
interface IntegrationOptions {
enableEmoticons: string;
expireBehavior: string;
expireGracePeriod: string;
enableEmoticons?: string;
expireBehavior?: string;
expireGracePeriod?: string;
}
interface PruneMemberOptions extends GetPruneOptions {
computePruneCount?: boolean;
Expand Down Expand Up @@ -784,6 +785,27 @@ declare namespace Eris {
channel_id?: string;
enabled: boolean;
}
interface WidgetChannel {
id: string;
name: string;
position: number;
}
interface WidgetData {
channels: WidgetChannel[];
id: string;
instant_invite: string;
members: WidgetMember[];
name: string;
presence_count: number;
}
interface WidgetMember {
avatar: string | null;
avatar_url: string;
discriminator: string;
id: string;
status: string;
username: string;
}

// Invite
interface CreateInviteOptions {
Expand Down Expand Up @@ -823,6 +845,9 @@ declare namespace Eris {
id: string;
user: User;
}
interface MemberRoles extends BaseData {
roles: string[];
}
interface PartialUser {
avatar: string | null;
discriminator: string;
Expand Down Expand Up @@ -975,10 +1000,16 @@ declare namespace Eris {
[key: string]: unknown;
}
interface ActivityPartial<T extends ActivityType = BotActivityType> {
name?: string;
type?: T;
name: string;
type: T;
url?: string;
}
interface ClientPresence {
activities: Activity[] | null;
afk: boolean;
since: number | null;
status: Status;
}
interface ClientStatus {
desktop: Status;
mobile: Status;
Expand All @@ -987,7 +1018,6 @@ declare namespace Eris {
interface Presence {
activities?: Activity[];
clientStatus?: ClientStatus;
game: Activity | null;
status?: Status;
}

Expand All @@ -1012,7 +1042,7 @@ declare namespace Eris {
hoist?: boolean;
mentionable?: boolean;
name?: string;
permissions?: bigint | number;
permissions?: bigint | number | Permission;
}
interface RoleTags {
bot_id?: string;
Expand Down Expand Up @@ -1176,7 +1206,7 @@ declare namespace Eris {
GUILD_STORE: 6;
GUILD_STAGE: 13;
};
GATEWAY_VERSION: 6;
GATEWAY_VERSION: 8;
GatewayOPCodes: {
EVENT: 0;
HEARTBEAT: 1;
Expand Down Expand Up @@ -1299,7 +1329,7 @@ declare namespace Eris {
allVoice: 4629464849n;
all: 8589934591n;
};
REST_VERSION: 7;
REST_VERSION: 8;
StickerFormats: {
PNG: 1;
APNG: 2;
Expand Down Expand Up @@ -1513,7 +1543,7 @@ declare namespace Eris {
lastReconnectDelay: number;
notes: { [s: string]: string };
options: ClientOptions;
presence: Presence;
presence: ClientPresence;
privateChannelMap: { [s: string]: string };
privateChannels: Collection<PrivateChannel>;
ready: boolean;
Expand All @@ -1529,7 +1559,7 @@ declare namespace Eris {
users: Collection<User>;
userSettings: UserSettings;
voiceConnections: VoiceConnectionManager;
constructor(token: string, options?: ClientOptions);
constructor(token: string, options: ClientOptions);
acceptInvite(inviteID: string): Promise<Invite<"withoutCount">>;
addGroupRecipient(groupID: string, userID: string): Promise<void>;
addGuildDiscoverySubcategory(guildID: string, categoryID: string, reason?: string): Promise<DiscoverySubcategoryResponse>;
Expand Down Expand Up @@ -1689,7 +1719,7 @@ declare namespace Eris {
overwriteID: string,
allow: bigint | number,
deny: bigint | number,
type: string,
type: PermissionType,
reason?: string
): Promise<void>;
editChannelPosition(channelID: string, position: number, options?: EditChannelPositionOptions): Promise<void>;
Expand All @@ -1702,7 +1732,7 @@ declare namespace Eris {
reason?: string
): Promise<Emoji>;
editGuildIntegration(guildID: string, integrationID: string, options: IntegrationOptions): Promise<void>;
editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise<void>;
editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise<Member>;
editGuildTemplate(guildID: string, code: string, options: GuildTemplateOptions): Promise<GuildTemplate>;
editGuildVanity(guildID: string, code: string | null): Promise<GuildVanity>;
editGuildVoiceState(guildID: string, options: VoiceStateOptions, userID?: string): Promise<void>;
Expand All @@ -1719,7 +1749,8 @@ declare namespace Eris {
data: { friendSync: boolean; visibility: number }
): Promise<Connection>;
editSelfSettings(data: UserSettings): Promise<UserSettings>;
editStatus(status?: Status, game?: ActivityPartial<BotActivityType>): void;
editStatus(status: Status, activities?: ActivityPartial<BotActivityType>[] | ActivityPartial<BotActivityType>): void;
editStatus(activities?: ActivityPartial<BotActivityType>[] | ActivityPartial<BotActivityType>): void;
editUserNote(userID: string, note: string): Promise<void>;
editWebhook(
webhookID: string,
Expand Down Expand Up @@ -1758,15 +1789,16 @@ declare namespace Eris {
getGuildDiscovery(guildID: string): Promise<DiscoveryMetadata>;
/** @deprecated */
getGuildEmbed(guildID: string): Promise<Widget>;
getGuildIntegrations(guildID: string, options?: GetGuildIntegrationsOptions): Promise<GuildIntegration[]>;
getGuildIntegrations(guildID: string): Promise<GuildIntegration[]>;
getGuildInvites(guildID: string): Promise<Invite[]>;
getGuildPreview(guildID: string): Promise<GuildPreview>;
getGuildTemplate(code: string): Promise<GuildTemplate>;
getGuildTemplates(guildID: string): Promise<GuildTemplate[]>;
getGuildVanity(guildID: string): Promise<GuildVanity>;
getGuildWebhooks(guildID: string): Promise<Webhook[]>;
getGuildWelcomeScreen(guildID: string): Promise<WelcomeScreen>;
getGuildWidget(guildID: string): Promise<Widget>;
getGuildWidget(guildID: string): Promise<WidgetData>;
getGuildWidgetSettings(guildID: string): Promise<Widget>;
getInvite(inviteID: string, withCounts?: false): Promise<Invite<"withoutCount">>;
getInvite(inviteID: string, withCounts: true): Promise<Invite<"withCount">>;
getMessage(channelID: string, messageID: string): Promise<Message>;
Expand Down Expand Up @@ -1932,7 +1964,7 @@ declare namespace Eris {
commands: { [s: string]: Command };
guildPrefixes: { [s: string]: string | string[] };
preReady?: true;
constructor(token: string, options?: ClientOptions, commandOptions?: CommandClientOptions);
constructor(token: string, options: ClientOptions, commandOptions?: CommandClientOptions);
checkPrefix(msg: Message): string;
onMessageCreate(msg: Message): Promise<void>;
onMessageReactionEvent(msg: Message, emoji: Emoji, reactor: Member | Uncached | string): Promise<void>
Expand Down Expand Up @@ -2016,7 +2048,9 @@ declare namespace Eris {
members: Collection<Member>;
mfaLevel: MFALevel;
name: string;
/** @deprecated */
nsfw: boolean;
nsfwLevel: NSFWLevel;
ownerID: string;
preferredLocale: string;
premiumSubscriptionCount?: number;
Expand Down Expand Up @@ -2082,7 +2116,7 @@ declare namespace Eris {
editDiscovery(options?: DiscoveryOptions): Promise<DiscoveryMetadata>;
editEmoji(emojiID: string, options: { name: string; roles?: string[] }, reason?: string): Promise<Emoji>;
editIntegration(integrationID: string, options: IntegrationOptions): Promise<void>;
editMember(memberID: string, options: MemberOptions, reason?: string): Promise<void>;
editMember(memberID: string, options: MemberOptions, reason?: string): Promise<Member>;
editNickname(nick: string): Promise<void>;
editRole(roleID: string, options: RoleOptions): Promise<Role>;
editTemplate(code: string, options: GuildTemplateOptions): Promise<GuildTemplate>;
Expand All @@ -2100,7 +2134,7 @@ declare namespace Eris {
getDiscovery(): Promise<DiscoveryMetadata>;
/** @deprecated */
getEmbed(): Promise<Widget>;
getIntegrations(options?: GetGuildIntegrationsOptions): Promise<GuildIntegration>;
getIntegrations(): Promise<GuildIntegration>;
getInvites(): Promise<Invite[]>;
getPruneCount(options?: GetPruneOptions): Promise<number>;
getRESTChannels(): Promise<AnyGuildChannel[]>;
Expand All @@ -2116,11 +2150,12 @@ declare namespace Eris {
getVoiceRegions(): Promise<VoiceRegion[]>;
getWebhooks(): Promise<Webhook[]>;
getWelcomeScreen(): Promise<WelcomeScreen>;
getWidget(): Promise<Widget>;
getWidget(): Promise<WidgetData>;
getWidgetSettings(): Promise<Widget>;
kickMember(userID: string, reason?: string): Promise<void>;
leave(): Promise<void>;
leaveVoiceChannel(): void;
permissionsOf(memberID: string | Member): Permission;
permissionsOf(memberID: string | Member | MemberRoles): Permission;
pruneMembers(options?: PruneMemberOptions): Promise<number>;
removeMemberRole(memberID: string, roleID: string, reason?: string): Promise<void>;
searchMembers(query: string, limit?: number): Promise<Member[]>;
Expand Down Expand Up @@ -2170,29 +2205,29 @@ declare namespace Eris {
): Promise<PermissionOverwrite>;
editPosition(position: number, options?: EditChannelPositionOptions): Promise<void>;
getInvites(): Promise<Invite[]>;
permissionsOf(memberID: string | Member): Permission;
permissionsOf(memberID: string | Member | MemberRoles): Permission;
}

export class GuildIntegration extends Base {
account: { id: string; name: string };
application?: IntegrationApplication;
createdAt: number;
enabled: boolean;
enableEmoticons: boolean;
expireBehavior: number;
expireGracePeriod: number;
enableEmoticons?: boolean;
expireBehavior?: number;
expireGracePeriod?: number;
id: string;
name: string;
revoked: boolean;
roleID: string;
subscriberCount: number;
syncedAt: number;
syncing: boolean;
revoked?: boolean;
roleID?: string;
subscriberCount?: number;
syncedAt?: number;
syncing?: boolean;
type: string;
user?: User;
constructor(data: BaseData, guild: Guild);
delete(): Promise<void>;
edit(options: { enableEmoticons: string; expireBehavior: string; expireGracePeriod: string }): Promise<void>;
edit(options: IntegrationOptions): Promise<void>;
sync(): Promise<void>;
}

Expand Down Expand Up @@ -2458,10 +2493,9 @@ declare namespace Eris {
unsendMessage(messageID: string): Promise<void>;
}

export class Relationship extends Base implements Presence {
activities?: Activity[];
export class Relationship extends Base implements Omit<Presence, "activities"> {
activities: Activity[] | null;
clientStatus?: ClientStatus;
game: Activity | null;
id: string;
status: Status;
type: number;
Expand Down Expand Up @@ -2537,7 +2571,7 @@ declare namespace Eris {
lastHeartbeatSent: number | null;
latency: number;
preReady: boolean;
presence: Presence;
presence: ClientPresence;
presenceUpdateBucket: Bucket;
ready: boolean;
reconnectInterval: number;
Expand All @@ -2553,8 +2587,8 @@ declare namespace Eris {
createGuild(_guild: Guild): Guild;
disconnect(options?: { reconnect?: boolean | "auto" }, error?: Error): void;
editAFK(afk: boolean): void;
editStatus(status?: Status, game?: ActivityPartial<BotActivityType>): void;
editStatus(game?: ActivityPartial<BotActivityType>): void;
editStatus(status: Status, activities?: ActivityPartial<BotActivityType>[] | ActivityPartial<BotActivityType>): void;
editStatus(activities?: ActivityPartial<BotActivityType>[] | ActivityPartial<BotActivityType>): void;
// @ts-ignore: Method override
emit(event: string, ...args: any[]): void;
getGuildMembers(guildID: string, timeout: number): void;
Expand Down
Loading

0 comments on commit cef886a

Please sign in to comment.