Skip to content

Commit

Permalink
fixed up some gh action stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
stuyy committed May 23, 2020
1 parent febf262 commit 66ea3f3
Show file tree
Hide file tree
Showing 9 changed files with 405 additions and 28 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/blank.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: self-hosted

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: denolib/setup-deno@master
with:
deno-version: v1.x
- run: deno test --allow-read ./tests/tests.ts
25 changes: 17 additions & 8 deletions src/client/ClientUser.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
export default class ClientUser {
constructor(
private username: string,
private discriminator: number,
private verified: boolean,
private id: string,
private flags: number,
private email: string,
private bot: boolean,
private avatar: string,
private _username: string,
private _discriminator: string,
private _verified: boolean,
private _id: string,
private _flags: number,
private _email: string | null,
private _bot: boolean,
private _avatar: string,
) {
}

get username(): string { return this._username; }
get discriminator(): string { return this._discriminator; }
get verified(): boolean { return this._verified; }
get id(): string { return this._id; }
get flags(): number { return this._flags; }
get email(): string | null { return this._email; }
get bot(): boolean { return this._bot; }
get avatar(): string { return this._avatar; }
}
4 changes: 3 additions & 1 deletion src/handlers/GUILD_CREATE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {

export default async function (client: Client, payload: Payload) {
const { d: guild } = payload;
if (client.guilds.has(payload.d.id)) {
if (client.guilds.has(guild.id)) {
const cachedGuild = client.guilds.get(guild.id);
client.emit(Events.GUILD_CREATE, cachedGuild);
} else {
Expand All @@ -26,6 +26,8 @@ export default async function (client: Client, payload: Payload) {
newGuild,
guild.members,
);

console.log(guild.channels);
newGuild.channels = channels;
newGuild.members = members;
client.guilds.set(newGuild.id, newGuild);
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ client.on("ready", () => {
console.log("Bot has logged in.");
});


client.on("message", async (message: Message) => {

console.log(message.channel.messages.size);
Expand Down
2 changes: 1 addition & 1 deletion src/models/Guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class Guild {
}

public get roles(): Collection<string, Role> { return this._roles; }

public get emojis(): Collection<string, Emoji> { return this._emojis; }
public set emojis(emojis: Collection<string, Emoji>) { this._emojis = emojis; }
public get channels(): Collection<string, GuildChannel> { return this._channels; }
Expand Down
2 changes: 2 additions & 0 deletions src/models/GuildMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Role from "./Role.ts";

export default class GuildMember {
constructor(
private _id: string,
private _user: User,
private _nickname: string,
private _roles: Collection<string, Role>,
Expand All @@ -14,6 +15,7 @@ export default class GuildMember {
) {
}

public get id(): string { return this._id; }
public get user(): User {
return this._user;
}
Expand Down
35 changes: 17 additions & 18 deletions src/utils/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,32 +94,31 @@ export function resolveGuildMembersAndUsers(
const membersMap = new Collection();
for (const member of members) {
const { user } = member;
client.users.set(
const newUser = new User(
user.id,
new User(
user.id,
user.username,
user.discriminator,
user.avatar,
user.bot,
user.system,
user.mfaEnabled,
user.locale,
user.verified,
user.flags,
user.premiumType,
user.public_flags,
client,
),
user.username,
user.discriminator,
user.avatar,
user.bot,
user.system,
user.mfaEnabled,
user.locale,
user.verified,
user.flags,
user.premiumType,
user.public_flags,
client,
);
client.users.set(newUser.id, newUser);
const roles = new Collection<string, Role>();
for (const role of member.roles) {
roles.set(role, newGuild.roles.get(role));
}
membersMap.set(
user.id,
newUser.id,
new GuildMember(
user,
newUser.id,
newUser,
member.nick,
roles,
member.joined_at,
Expand Down
Loading

0 comments on commit 66ea3f3

Please sign in to comment.