Merge pull request #20 from yky4589/main
as any Remove and File Name change
This commit is contained in:
		
						commit
						1eedb69483
					
				
					 25 changed files with 81 additions and 71 deletions
				
			
		
							
								
								
									
										26
									
								
								mod.ts
									
										
									
									
									
								
							
							
						
						
									
										26
									
								
								mod.ts
									
										
									
									
									
								
							|  | @ -1,19 +1,19 @@ | ||||||
| export * from './src/gateway/index.ts' | export * from './src/gateway/index.ts' | ||||||
| export * from './src/models/client.ts' | export * from './src/models/client.ts' | ||||||
| export * from './src/models/rest.ts' | export * from './src/models/rest.ts' | ||||||
| export * from './src/models/CacheAdapter.ts' | export * from './src/models/cacheAdapter.ts' | ||||||
| export * from './src/models/shard.ts' | export * from './src/models/shard.ts' | ||||||
| export * from './src/managers/BaseManager.ts' | export * from './src/managers/base.ts' | ||||||
| export * from './src/managers/BaseChildManager.ts' | export * from './src/managers/baseChild.ts' | ||||||
| export * from './src/managers/ChannelsManager.ts' | export * from './src/managers/channels.ts' | ||||||
| export * from './src/managers/EmojisManager.ts' | export * from './src/managers/emojis.ts' | ||||||
| export * from './src/managers/GatewayCache.ts' | export * from './src/managers/gatewayCache.ts' | ||||||
| export * from './src/managers/GuildChannelsManager.ts' | export * from './src/managers/guildChannels.ts' | ||||||
| export * from './src/managers/GuildsManager.ts' | export * from './src/managers/guilds.ts' | ||||||
| export * from './src/managers/MembersManager.ts' | export * from './src/managers/members.ts' | ||||||
| export * from './src/managers/MessagesManager.ts' | export * from './src/managers/messages.ts' | ||||||
| export * from './src/managers/RolesManager.ts' | export * from './src/managers/roles.ts' | ||||||
| export * from './src/managers/UsersManager.ts' | export * from './src/managers/users.ts' | ||||||
| export * from './src/structures/base.ts' | export * from './src/structures/base.ts' | ||||||
| export * from './src/structures/cdn.ts' | export * from './src/structures/cdn.ts' | ||||||
| export * from './src/structures/channel.ts' | export * from './src/structures/channel.ts' | ||||||
|  | @ -29,7 +29,7 @@ export * from './src/structures/guildVoiceChannel.ts' | ||||||
| export * from './src/structures/invite.ts' | export * from './src/structures/invite.ts' | ||||||
| export * from './src/structures/member.ts' | export * from './src/structures/member.ts' | ||||||
| export * from './src/structures/message.ts' | export * from './src/structures/message.ts' | ||||||
| export * from './src/structures/MessageMentions.ts' | export * from './src/structures/messageMentions.ts' | ||||||
| export * from './src/structures/presence.ts' | export * from './src/structures/presence.ts' | ||||||
| export * from './src/structures/role.ts' | export * from './src/structures/role.ts' | ||||||
| export * from './src/structures/snowflake.ts' | export * from './src/structures/snowflake.ts' | ||||||
|  |  | ||||||
|  | @ -6,7 +6,7 @@ export const channelPinsUpdate: GatewayEventHandler = async ( | ||||||
|   gateway: Gateway, |   gateway: Gateway, | ||||||
|   d: ChannelPinsUpdatePayload |   d: ChannelPinsUpdatePayload | ||||||
| ) => { | ) => { | ||||||
|   const after: TextChannel | void = await gateway.client.channels.get<TextChannel>(d.channel_id) |   const after: TextChannel | undefined = await gateway.client.channels.get<TextChannel>(d.channel_id) | ||||||
|   if (after !== undefined) { |   if (after !== undefined) { | ||||||
|     const before = after.refreshFromData({ |     const before = after.refreshFromData({ | ||||||
|       last_pin_timestamp: d.last_pin_timestamp |       last_pin_timestamp: d.last_pin_timestamp | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| import { Channel } from '../../structures/channel.ts' | import { Channel } from '../../structures/channel.ts' | ||||||
| import { Guild } from "../../structures/guild.ts" | import { Guild } from "../../structures/guild.ts" | ||||||
| import { ChannelPayload } from '../../types/channel.ts' | import { ChannelPayload, GuildChannelPayload } from '../../types/channel.ts' | ||||||
| import getChannelByType from '../../utils/getChannelByType.ts' | import getChannelByType from '../../utils/getChannelByType.ts' | ||||||
| import { Gateway, GatewayEventHandler } from '../index.ts' | import { Gateway, GatewayEventHandler } from '../index.ts' | ||||||
| 
 | 
 | ||||||
|  | @ -13,8 +13,9 @@ export const channelUpdate: GatewayEventHandler = async ( | ||||||
|   if (oldChannel !== undefined) { |   if (oldChannel !== undefined) { | ||||||
|     await gateway.client.channels.set(d.id, d) |     await gateway.client.channels.set(d.id, d) | ||||||
|     let guild: undefined | Guild; |     let guild: undefined | Guild; | ||||||
|     if((d as any).guild_id !== undefined) { |     if('guild_id' in d) { | ||||||
|       guild = await gateway.client.guilds.get((d as any).guild_id) as Guild | undefined |       // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
 | ||||||
|  |       guild = await gateway.client.guilds.get((d as GuildChannelPayload).guild_id) as Guild | undefined | ||||||
|     } |     } | ||||||
|     if (oldChannel.type !== d.type) { |     if (oldChannel.type !== d.type) { | ||||||
|       const channel: Channel = getChannelByType(gateway.client, d, guild) ?? oldChannel |       const channel: Channel = getChannelByType(gateway.client, d, guild) ?? oldChannel | ||||||
|  |  | ||||||
|  | @ -1,30 +1,30 @@ | ||||||
| import { Gateway, GatewayEventHandler } from '../index.ts' | import { Gateway, GatewayEventHandler } from '../index.ts' | ||||||
| import { Guild } from '../../structures/guild.ts' | import { Guild } from '../../structures/guild.ts' | ||||||
| import { GuildPayload, MemberPayload } from "../../types/guild.ts" | import { GuildPayload, MemberPayload } from "../../types/guild.ts" | ||||||
| import { MembersManager } from "../../managers/MembersManager.ts" | import { MembersManager } from "../../managers/members.ts" | ||||||
| import { ChannelPayload } from "../../types/channel.ts" | import { GuildChannelPayload } from "../../types/channel.ts" | ||||||
| import { RolePayload } from "../../types/role.ts" | import { RolePayload } from "../../types/role.ts" | ||||||
| import { RolesManager } from "../../managers/RolesManager.ts" | import { RolesManager } from "../../managers/roles.ts" | ||||||
| 
 | 
 | ||||||
| export const guildCreate: GatewayEventHandler = async(gateway: Gateway, d: GuildPayload) => { | export const guildCreate: GatewayEventHandler = async(gateway: Gateway, d: GuildPayload) => { | ||||||
|   let guild: Guild | undefined = await gateway.client.guilds.get(d.id) |   let guild: Guild | undefined = await gateway.client.guilds.get(d.id) | ||||||
|   if (guild !== undefined) { |   if (guild !== undefined) { | ||||||
|     // It was just lazy load, so we don't fire the event as its gonna fire for every guild bot is in
 |     // It was just lazy load, so we don't fire the event as its gonna fire for every guild bot is in
 | ||||||
|     await gateway.client.guilds.set(d.id, d) |     await gateway.client.guilds.set(d.id, d) | ||||||
|     if ((d as any).members !== undefined) { |     if (d.members !== undefined) { | ||||||
|       const members = new MembersManager(gateway.client, guild) |       const members = new MembersManager(gateway.client, guild) | ||||||
|       await members.fromPayload((d as any).members as MemberPayload[]) |       await members.fromPayload(d.members as MemberPayload[]) | ||||||
|       guild.members = members |       guild.members = members | ||||||
|     } |     } | ||||||
|     if ((d as any).channels !== undefined) { |     if (d.channels !== undefined) { | ||||||
|       for (const ch of (d as any).channels as ChannelPayload[]) { |       for (const ch of d.channels as GuildChannelPayload[]) { | ||||||
|         (ch as any).guild_id = d.id |         ch.guild_id = d.id | ||||||
|         await gateway.client.channels.set(ch.id, ch) |         await gateway.client.channels.set(ch.id, ch) | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     if ((d as any).roles !== undefined) { |     if (d.roles !== undefined) { | ||||||
|       const roles = new RolesManager(gateway.client, guild) |       const roles = new RolesManager(gateway.client, guild) | ||||||
|       await roles.fromPayload((d as any).roles as RolePayload[]) |       await roles.fromPayload(d.roles as RolePayload[]) | ||||||
|       guild.roles = roles |       guild.roles = roles | ||||||
|     } |     } | ||||||
|     guild.refreshFromData(d) |     guild.refreshFromData(d) | ||||||
|  | @ -33,18 +33,18 @@ export const guildCreate: GatewayEventHandler = async(gateway: Gateway, d: Guild | ||||||
|     guild = new Guild(gateway.client, d) |     guild = new Guild(gateway.client, d) | ||||||
|     if ((d as any).members !== undefined) { |     if ((d as any).members !== undefined) { | ||||||
|       const members = new MembersManager(gateway.client, guild) |       const members = new MembersManager(gateway.client, guild) | ||||||
|       await members.fromPayload((d as any).members as MemberPayload[]) |       await members.fromPayload(d.members as MemberPayload[]) | ||||||
|       guild.members = members |       guild.members = members | ||||||
|     } |     } | ||||||
|     if ((d as any).channels !== undefined) { |     if (d.channels !== undefined) { | ||||||
|       for (const ch of (d as any).channels as ChannelPayload[]) { |       for (const ch of d.channels as GuildChannelPayload[]) { | ||||||
|         (ch as any).guild_id = d.id |         (ch as any).guild_id = d.id | ||||||
|         await gateway.client.channels.set(ch.id, ch) |         await gateway.client.channels.set(ch.id, ch) | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     if ((d as any).roles !== undefined) { |     if (d.roles !== undefined) { | ||||||
|       const roles = new RolesManager(gateway.client, guild) |       const roles = new RolesManager(gateway.client, guild) | ||||||
|       await roles.fromPayload((d as any).roles as RolePayload[]) |       await roles.fromPayload(d.roles) | ||||||
|       guild.roles = roles |       guild.roles = roles | ||||||
|     } |     } | ||||||
|     await guild.roles.fromPayload(d.roles) |     await guild.roles.fromPayload(d.roles) | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| import { Message } from '../../structures/message.ts' | import { Message } from '../../structures/message.ts' | ||||||
| import { MessageMentions } from '../../structures/MessageMentions.ts' | import { MessageMentions } from '../../structures/messageMentions.ts' | ||||||
| import { TextChannel } from '../../structures/textChannel.ts' | import { TextChannel } from '../../structures/textChannel.ts' | ||||||
| import { User } from '../../structures/user.ts' | import { User } from '../../structures/user.ts' | ||||||
| import { MessagePayload } from '../../types/channel.ts' | import { MessagePayload } from '../../types/channel.ts' | ||||||
|  | @ -12,7 +12,8 @@ export const messageCreate: GatewayEventHandler = async ( | ||||||
|   let channel = await gateway.client.channels.get<TextChannel>(d.channel_id) |   let channel = await gateway.client.channels.get<TextChannel>(d.channel_id) | ||||||
|   // Fetch the channel if not cached
 |   // Fetch the channel if not cached
 | ||||||
|   if (channel === undefined) |   if (channel === undefined) | ||||||
|     channel = (await gateway.client.channels.fetch(d.channel_id)) as any |     // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
 | ||||||
|  |     channel = (await gateway.client.channels.fetch(d.channel_id)) as TextChannel | ||||||
|   const user = new User(gateway.client, d.author) |   const user = new User(gateway.client, d.author) | ||||||
|   await gateway.client.users.set(d.author.id, d.author) |   await gateway.client.users.set(d.author.id, d.author) | ||||||
|   let guild |   let guild | ||||||
|  |  | ||||||
|  | @ -1,5 +1,4 @@ | ||||||
| import { Gateway } from "../index.ts" | import { Gateway , GatewayEventHandler } from "../index.ts" | ||||||
| import { GatewayEventHandler } from "../index.ts" |  | ||||||
| 
 | 
 | ||||||
| export const reconnect: GatewayEventHandler = async (gateway: Gateway, d: any) => { | export const reconnect: GatewayEventHandler = async (gateway: Gateway, d: any) => { | ||||||
|     gateway.reconnect() |     gateway.reconnect() | ||||||
|  |  | ||||||
|  | @ -5,6 +5,6 @@ import { Gateway, GatewayEventHandler } from '../index.ts' | ||||||
| export const resume: GatewayEventHandler = async (gateway: Gateway, d: any) => { | export const resume: GatewayEventHandler = async (gateway: Gateway, d: any) => { | ||||||
|   gateway.debug(`Session Resumed!`) |   gateway.debug(`Session Resumed!`) | ||||||
|   gateway.client.emit('resume') |   gateway.client.emit('resume') | ||||||
|   if (gateway.client.user === undefined) gateway.client.user = new User(gateway.client, await gateway.client.rest.get(CLIENT_USER()) as any) |   if (gateway.client.user === undefined) gateway.client.user = new User(gateway.client, await gateway.client.rest.get(CLIENT_USER())) | ||||||
|   gateway.client.emit('ready') |   gateway.client.emit('ready') | ||||||
| } | } | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| import { Client } from "../models/client.ts"; | import { Client } from "../models/client.ts"; | ||||||
| import { Collection } from "../utils/collection.ts"; | import { Collection } from "../utils/collection.ts"; | ||||||
| import { BaseManager } from "./BaseManager.ts"; | import { BaseManager } from "./base.ts"; | ||||||
| 
 | 
 | ||||||
| export class BaseChildManager<T, T2> { | export class BaseChildManager<T, T2> { | ||||||
|   client: Client |   client: Client | ||||||
|  | @ -3,7 +3,7 @@ import { Channel } from "../structures/channel.ts"; | ||||||
| import { ChannelPayload } from "../types/channel.ts"; | import { ChannelPayload } from "../types/channel.ts"; | ||||||
| import { CHANNEL } from "../types/endpoint.ts"; | import { CHANNEL } from "../types/endpoint.ts"; | ||||||
| import getChannelByType from "../utils/getChannelByType.ts"; | import getChannelByType from "../utils/getChannelByType.ts"; | ||||||
| import { BaseManager } from "./BaseManager.ts"; | import { BaseManager } from "./base.ts"; | ||||||
| 
 | 
 | ||||||
| export class ChannelsManager extends BaseManager<ChannelPayload, Channel> { | export class ChannelsManager extends BaseManager<ChannelPayload, Channel> { | ||||||
|   constructor(client: Client) { |   constructor(client: Client) { | ||||||
|  | @ -2,7 +2,7 @@ import { Client } from '../models/client.ts' | ||||||
| import { Emoji } from '../structures/emoji.ts' | import { Emoji } from '../structures/emoji.ts' | ||||||
| import { EmojiPayload } from '../types/emoji.ts' | import { EmojiPayload } from '../types/emoji.ts' | ||||||
| import { CHANNEL } from '../types/endpoint.ts' | import { CHANNEL } from '../types/endpoint.ts' | ||||||
| import { BaseManager } from './BaseManager.ts' | import { BaseManager } from './base.ts' | ||||||
| 
 | 
 | ||||||
| export class EmojisManager extends BaseManager<EmojiPayload, Emoji> { | export class EmojisManager extends BaseManager<EmojiPayload, Emoji> { | ||||||
|   constructor (client: Client) { |   constructor (client: Client) { | ||||||
|  | @ -6,8 +6,8 @@ import { GuildTextChannel } from "../structures/guildTextChannel.ts"; | ||||||
| import { VoiceChannel } from "../structures/guildVoiceChannel.ts"; | import { VoiceChannel } from "../structures/guildVoiceChannel.ts"; | ||||||
| import { GuildChannelCategoryPayload, GuildTextChannelPayload, GuildVoiceChannelPayload } from "../types/channel.ts"; | import { GuildChannelCategoryPayload, GuildTextChannelPayload, GuildVoiceChannelPayload } from "../types/channel.ts"; | ||||||
| import { CHANNEL } from "../types/endpoint.ts"; | import { CHANNEL } from "../types/endpoint.ts"; | ||||||
| import { BaseChildManager } from "./BaseChildManager.ts"; | import { BaseChildManager } from "./baseChild.ts"; | ||||||
| import { ChannelsManager } from "./ChannelsManager.ts"; | import { ChannelsManager } from "./channels.ts"; | ||||||
| 
 | 
 | ||||||
| export type GuildChannelPayloads = GuildTextChannelPayload | GuildVoiceChannelPayload | GuildChannelCategoryPayload | export type GuildChannelPayloads = GuildTextChannelPayload | GuildVoiceChannelPayload | GuildChannelCategoryPayload | ||||||
| export type GuildChannel = GuildTextChannel | VoiceChannel | CategoryChannel | export type GuildChannel = GuildTextChannel | VoiceChannel | CategoryChannel | ||||||
|  | @ -2,8 +2,8 @@ import { Client } from "../models/client.ts"; | ||||||
| import { Guild } from "../structures/guild.ts"; | import { Guild } from "../structures/guild.ts"; | ||||||
| import { GUILD } from "../types/endpoint.ts"; | import { GUILD } from "../types/endpoint.ts"; | ||||||
| import { GuildPayload, MemberPayload } from "../types/guild.ts"; | import { GuildPayload, MemberPayload } from "../types/guild.ts"; | ||||||
| import { BaseManager } from "./BaseManager.ts"; | import { BaseManager } from "./base.ts"; | ||||||
| import { MembersManager } from "./MembersManager.ts"; | import { MembersManager } from "./members.ts"; | ||||||
| 
 | 
 | ||||||
| export class GuildManager extends BaseManager<GuildPayload, Guild> { | export class GuildManager extends BaseManager<GuildPayload, Guild> { | ||||||
|   constructor (client: Client) { |   constructor (client: Client) { | ||||||
|  | @ -3,7 +3,7 @@ import { Guild } from "../structures/guild.ts"; | ||||||
| import { Member } from "../structures/member.ts"; | import { Member } from "../structures/member.ts"; | ||||||
| import { GUILD_MEMBER } from "../types/endpoint.ts"; | import { GUILD_MEMBER } from "../types/endpoint.ts"; | ||||||
| import { MemberPayload } from "../types/guild.ts"; | import { MemberPayload } from "../types/guild.ts"; | ||||||
| import { BaseManager } from "./BaseManager.ts"; | import { BaseManager } from "./base.ts"; | ||||||
| 
 | 
 | ||||||
| export class MembersManager extends BaseManager<MemberPayload, Member> { | export class MembersManager extends BaseManager<MemberPayload, Member> { | ||||||
|   guild: Guild |   guild: Guild | ||||||
|  | @ -1,11 +1,11 @@ | ||||||
| import { Client } from "../models/client.ts"; | import { Client } from "../models/client.ts"; | ||||||
| import { Message } from "../structures/message.ts"; | import { Message } from "../structures/message.ts"; | ||||||
| import { MessageMentions } from "../structures/MessageMentions.ts"; | import { MessageMentions } from "../structures/messageMentions.ts"; | ||||||
| import { TextChannel } from "../structures/textChannel.ts"; | import { TextChannel } from "../structures/textChannel.ts"; | ||||||
| import { User } from "../structures/user.ts"; | import { User } from "../structures/user.ts"; | ||||||
| import { MessagePayload } from "../types/channel.ts"; | import { MessagePayload } from "../types/channel.ts"; | ||||||
| import { CHANNEL_MESSAGE } from "../types/endpoint.ts"; | import { CHANNEL_MESSAGE } from "../types/endpoint.ts"; | ||||||
| import { BaseManager } from "./BaseManager.ts"; | import { BaseManager } from "./base.ts"; | ||||||
| 
 | 
 | ||||||
| export class MessagesManager extends BaseManager<MessagePayload, Message> { | export class MessagesManager extends BaseManager<MessagePayload, Message> { | ||||||
|   constructor (client: Client) { |   constructor (client: Client) { | ||||||
|  | @ -3,7 +3,7 @@ import { Guild } from '../structures/guild.ts' | ||||||
| import { Role } from '../structures/role.ts' | import { Role } from '../structures/role.ts' | ||||||
| import { GUILD_ROLE } from '../types/endpoint.ts' | import { GUILD_ROLE } from '../types/endpoint.ts' | ||||||
| import { RolePayload } from '../types/role.ts' | import { RolePayload } from '../types/role.ts' | ||||||
| import { BaseManager } from './BaseManager.ts' | import { BaseManager } from './base.ts' | ||||||
| 
 | 
 | ||||||
| export class RolesManager extends BaseManager<RolePayload, Role> { | export class RolesManager extends BaseManager<RolePayload, Role> { | ||||||
|   guild: Guild |   guild: Guild | ||||||
|  | @ -2,7 +2,7 @@ import { Client } from '../models/client.ts' | ||||||
| import { User } from '../structures/user.ts' | import { User } from '../structures/user.ts' | ||||||
| import { USER } from '../types/endpoint.ts' | import { USER } from '../types/endpoint.ts' | ||||||
| import { UserPayload } from '../types/user.ts' | import { UserPayload } from '../types/user.ts' | ||||||
| import { BaseManager } from './BaseManager.ts' | import { BaseManager } from './base.ts' | ||||||
| 
 | 
 | ||||||
| export class UserManager extends BaseManager<UserPayload, User> { | export class UserManager extends BaseManager<UserPayload, User> { | ||||||
|   constructor (client: Client) { |   constructor (client: Client) { | ||||||
|  | @ -3,12 +3,12 @@ import { GatewayIntents } from '../types/gateway.ts' | ||||||
| import { Gateway } from '../gateway/index.ts' | import { Gateway } from '../gateway/index.ts' | ||||||
| import { RESTManager } from './rest.ts' | import { RESTManager } from './rest.ts' | ||||||
| import EventEmitter from 'https://deno.land/std@0.74.0/node/events.ts' | import EventEmitter from 'https://deno.land/std@0.74.0/node/events.ts' | ||||||
| import { DefaultCacheAdapter, ICacheAdapter } from "./CacheAdapter.ts" | import { DefaultCacheAdapter, ICacheAdapter } from "./cacheAdapter.ts" | ||||||
| import { UserManager } from "../managers/UsersManager.ts" | import { UserManager } from "../managers/users.ts" | ||||||
| import { GuildManager } from "../managers/GuildsManager.ts" | import { GuildManager } from "../managers/guilds.ts" | ||||||
| import { EmojisManager } from "../managers/EmojisManager.ts" | import { EmojisManager } from "../managers/emojis.ts" | ||||||
| import { ChannelsManager } from "../managers/ChannelsManager.ts" | import { ChannelsManager } from "../managers/channels.ts" | ||||||
| import { MessagesManager } from "../managers/MessagesManager.ts" | import { MessagesManager } from "../managers/messages.ts" | ||||||
| import { ActivityGame, ClientActivity, ClientPresence } from "../structures/presence.ts" | import { ActivityGame, ClientActivity, ClientPresence } from "../structures/presence.ts" | ||||||
| 
 | 
 | ||||||
| /** Some Client Options to modify behaviour */ | /** Some Client Options to modify behaviour */ | ||||||
|  |  | ||||||
|  | @ -5,9 +5,9 @@ import { Base } from './base.ts' | ||||||
| import { Emoji } from './emoji.ts' | import { Emoji } from './emoji.ts' | ||||||
| import { VoiceState } from './voiceState.ts' | import { VoiceState } from './voiceState.ts' | ||||||
| import cache from '../models/cache.ts' | import cache from '../models/cache.ts' | ||||||
| import { RolesManager } from "../managers/RolesManager.ts" | import { RolesManager } from "../managers/roles.ts" | ||||||
| import { GuildChannelsManager } from "../managers/GuildChannelsManager.ts" | import { GuildChannelsManager } from "../managers/guildChannels.ts" | ||||||
| import { MembersManager } from "../managers/MembersManager.ts" | import { MembersManager } from "../managers/members.ts" | ||||||
| 
 | 
 | ||||||
| export class Guild extends Base { | export class Guild extends Base { | ||||||
|   id: string |   id: string | ||||||
|  |  | ||||||
|  | @ -14,7 +14,7 @@ import { User } from './user.ts' | ||||||
| import { Member } from './member.ts' | import { Member } from './member.ts' | ||||||
| import { Embed } from './embed.ts' | import { Embed } from './embed.ts' | ||||||
| import { CHANNEL_MESSAGE } from '../types/endpoint.ts' | import { CHANNEL_MESSAGE } from '../types/endpoint.ts' | ||||||
| import { MessageMentions } from "./MessageMentions.ts" | import { MessageMentions } from "./messageMentions.ts" | ||||||
| import { TextChannel } from "./textChannel.ts" | import { TextChannel } from "./textChannel.ts" | ||||||
| import { DMChannel } from "./dmChannel.ts" | import { DMChannel } from "./dmChannel.ts" | ||||||
| import { Guild } from "./guild.ts" | import { Guild } from "./guild.ts" | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ import { MessageOption, TextChannelPayload } from '../types/channel.ts' | ||||||
| import { CHANNEL_MESSAGE, CHANNEL_MESSAGES } from '../types/endpoint.ts' | import { CHANNEL_MESSAGE, CHANNEL_MESSAGES } from '../types/endpoint.ts' | ||||||
| import { Channel } from './channel.ts' | import { Channel } from './channel.ts' | ||||||
| import { Message } from './message.ts' | import { Message } from './message.ts' | ||||||
| import { MessageMentions } from './MessageMentions.ts' | import { MessageMentions } from './messageMentions.ts' | ||||||
| 
 | 
 | ||||||
| export class TextChannel extends Channel { | export class TextChannel extends Channel { | ||||||
|   lastMessageID?: string |   lastMessageID?: string | ||||||
|  | @ -24,7 +24,7 @@ export class TextChannel extends Channel { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   async send (text?: string, option?: MessageOption): Promise<Message> { |   async send (text?: string, option?: MessageOption): Promise<Message> { | ||||||
|     if (text !== undefined && option !== undefined) { |     if (text === undefined && option === undefined) { | ||||||
|       throw new Error('Either text or option is necessary.') |       throw new Error('Either text or option is necessary.') | ||||||
|     } |     } | ||||||
|     const resp = await this.client.rest.post(CHANNEL_MESSAGES(this.id), { |     const resp = await this.client.rest.post(CHANNEL_MESSAGES(this.id), { | ||||||
|  |  | ||||||
|  | @ -2,11 +2,14 @@ import { Client } from '../models/client.ts' | ||||||
| import { GatewayIntents } from '../types/gateway.ts' | import { GatewayIntents } from '../types/gateway.ts' | ||||||
| import { TOKEN } from './config.ts' | import { TOKEN } from './config.ts' | ||||||
| import { Message } from "../structures/message.ts" | import { Message } from "../structures/message.ts" | ||||||
| import { RedisCacheAdapter } from "../models/CacheAdapter.ts" | import { DefaultCacheAdapter } from "../models/cacheAdapter.ts" | ||||||
| import { ClientPresence } from "../structures/presence.ts" | import { ClientPresence } from "../structures/presence.ts" | ||||||
| import { Member } from "../structures/member.ts" | import { Member } from "../structures/member.ts" | ||||||
| import { Role } from "../structures/role.ts" | import { Role } from "../structures/role.ts" | ||||||
| import { GuildChannel } from "../managers/GuildChannelsManager.ts" | import { GuildChannel } from "../managers/guildChannels.ts" | ||||||
|  | import { TextChannel } from "../structures/textChannel.ts" | ||||||
|  | import { Embed } from "../structures/embed.ts" | ||||||
|  | import { Guild } from "../structures/guild.ts" | ||||||
| 
 | 
 | ||||||
| const bot = new Client({ | const bot = new Client({ | ||||||
|   presence: new ClientPresence({ |   presence: new ClientPresence({ | ||||||
|  | @ -17,10 +20,7 @@ const bot = new Client({ | ||||||
|   }), |   }), | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| bot.setAdapter(new RedisCacheAdapter(bot, { | bot.setAdapter(new DefaultCacheAdapter(bot)) | ||||||
|   hostname: "127.0.0.1", |  | ||||||
|   port: 6379 |  | ||||||
| })) |  | ||||||
| 
 | 
 | ||||||
| bot.on('ready', () => { | bot.on('ready', () => { | ||||||
|   console.log(`[Login] Logged in as ${bot.user?.tag}!`) |   console.log(`[Login] Logged in as ${bot.user?.tag}!`) | ||||||
|  | @ -32,6 +32,15 @@ bot.on('ready', () => { | ||||||
| 
 | 
 | ||||||
| bot.on('debug', console.log) | bot.on('debug', console.log) | ||||||
| 
 | 
 | ||||||
|  | bot.on('channelPinsUpdate', (before: TextChannel, after: TextChannel) => { | ||||||
|  |   console.log(before.send('', { | ||||||
|  |     embed: new Embed({ | ||||||
|  |       title: 'Test', | ||||||
|  |       description: 'Test Embed' | ||||||
|  |     }) | ||||||
|  |   })) | ||||||
|  | }) | ||||||
|  | 
 | ||||||
| bot.on('messageCreate', async (msg: Message) => { | bot.on('messageCreate', async (msg: Message) => { | ||||||
|   if (msg.author.bot === true) return |   if (msg.author.bot === true) return | ||||||
|   if (msg.content === "!ping") { |   if (msg.content === "!ping") { | ||||||
|  | @ -44,7 +53,7 @@ bot.on('messageCreate', async (msg: Message) => { | ||||||
|     msg.channel.send("Member List:\n" + data) |     msg.channel.send("Member List:\n" + data) | ||||||
|   } else if (msg.content === "!guilds") { |   } else if (msg.content === "!guilds") { | ||||||
|     const guilds = await msg.client.guilds.collection() |     const guilds = await msg.client.guilds.collection() | ||||||
|     msg.channel.send("Guild List:\n" + (guilds.array().map((c, i: number) => { |     msg.channel.send("Guild List:\n" + (guilds.array().map((c: Guild, i: number) => { | ||||||
|       return `${i + 1}. ${c.name} - ${c.memberCount} members` |       return `${i + 1}. ${c.name} - ${c.memberCount} members` | ||||||
|     }).join("\n") as string)) |     }).join("\n") as string)) | ||||||
|   } else if (msg.content === "!roles") { |   } else if (msg.content === "!roles") { | ||||||
|  |  | ||||||
|  | @ -99,9 +99,9 @@ export interface MessagePayload { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export interface MessageOption { | export interface MessageOption { | ||||||
|   tts: boolean |   tts?: boolean | ||||||
|   embed: Embed |   embed: Embed | ||||||
|   file: Attachment |   file?: Attachment | ||||||
|   allowedMention?: { |   allowedMention?: { | ||||||
|     parse: ['everyone', 'users', 'roles'] |     parse: ['everyone', 'users', 'roles'] | ||||||
|     roles: string[] |     roles: string[] | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue