-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for GuildScheduledEvent (#6493)
Co-authored-by: Rodry <38259440+ImRodry@users.noreply.github.com> Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com> Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: GoldenAngel <50855202+GoldenAngel2@users.noreply.github.com> Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com> Co-authored-by: Antonio Román <kyradiscord@gmail.com> Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
- Loading branch information
1 parent
aa7c1b2
commit 1316fd4
Showing
29 changed files
with
1,261 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
const Action = require('./Action'); | ||
const { Events } = require('../../util/Constants'); | ||
|
||
class GuildScheduledEventCreateAction extends Action { | ||
handle(data) { | ||
const client = this.client; | ||
const guild = client.guilds.cache.get(data.guild_id); | ||
if (guild) { | ||
const guildScheduledEvent = guild.scheduledEvents._add(data); | ||
|
||
/** | ||
* Emitted whenever a guild scheduled event is created. | ||
* @event Client#guildScheduledEventCreate | ||
* @param {GuildScheduledEvent} guildScheduledEvent The created guild scheduled event | ||
*/ | ||
client.emit(Events.GUILD_SCHEDULED_EVENT_CREATE, guildScheduledEvent); | ||
|
||
return { guildScheduledEvent }; | ||
} | ||
|
||
return {}; | ||
} | ||
} | ||
|
||
module.exports = GuildScheduledEventCreateAction; |
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,31 @@ | ||
'use strict'; | ||
|
||
const Action = require('./Action'); | ||
const { Events } = require('../../util/Constants'); | ||
|
||
class GuildScheduledEventDeleteAction extends Action { | ||
handle(data) { | ||
const client = this.client; | ||
const guild = client.guilds.cache.get(data.guild_id); | ||
|
||
if (guild) { | ||
const guildScheduledEvent = this.getScheduledEvent(data, guild); | ||
if (guildScheduledEvent) { | ||
guild.scheduledEvents.cache.delete(guildScheduledEvent.id); | ||
|
||
/** | ||
* Emitted whenever a guild scheduled event is deleted. | ||
* @event Client#guildScheduledEventDelete | ||
* @param {GuildScheduledEvent} guildScheduledEvent The deleted guild scheduled event | ||
*/ | ||
client.emit(Events.GUILD_SCHEDULED_EVENT_DELETE, guildScheduledEvent); | ||
|
||
return { guildScheduledEvent }; | ||
} | ||
} | ||
|
||
return {}; | ||
} | ||
} | ||
|
||
module.exports = GuildScheduledEventDeleteAction; |
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,30 @@ | ||
'use strict'; | ||
|
||
const Action = require('./Action'); | ||
const { Events } = require('../../util/Constants'); | ||
|
||
class GuildScheduledEventUpdateAction extends Action { | ||
handle(data) { | ||
const client = this.client; | ||
const guild = client.guilds.cache.get(data.guild_id); | ||
|
||
if (guild) { | ||
const oldGuildScheduledEvent = guild.scheduledEvents.cache.get(data.id)?._clone() ?? null; | ||
const newGuildScheduledEvent = guild.scheduledEvents._add(data); | ||
|
||
/** | ||
* Emitted whenever a guild scheduled event gets updated. | ||
* @event Client#guildScheduledEventUpdate | ||
* @param {?GuildScheduledEvent} oldGuildScheduledEvent The guild scheduled event object before the update | ||
* @param {GuildScheduledEvent} newGuildScheduledEvent The guild scheduled event object after the update | ||
*/ | ||
client.emit(Events.GUILD_SCHEDULED_EVENT_UPDATE, oldGuildScheduledEvent, newGuildScheduledEvent); | ||
|
||
return { oldGuildScheduledEvent, newGuildScheduledEvent }; | ||
} | ||
|
||
return {}; | ||
} | ||
} | ||
|
||
module.exports = GuildScheduledEventUpdateAction; |
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,32 @@ | ||
'use strict'; | ||
|
||
const Action = require('./Action'); | ||
const { Events } = require('../../util/Constants'); | ||
|
||
class GuildScheduledEventUserAddAction extends Action { | ||
handle(data) { | ||
const client = this.client; | ||
const guild = client.guilds.cache.get(data.guild_id); | ||
|
||
if (guild) { | ||
const guildScheduledEvent = this.getScheduledEvent(data, guild); | ||
const user = this.getUser(data); | ||
|
||
if (guildScheduledEvent && user) { | ||
/** | ||
* Emitted whenever a user subscribes to a guild scheduled event | ||
* @event Client#guildScheduledEventUserAdd | ||
* @param {GuildScheduledEvent} guildScheduledEvent The guild scheduled event | ||
* @param {User} user The user who subscribed | ||
*/ | ||
client.emit(Events.GUILD_SCHEDULED_EVENT_USER_ADD, guildScheduledEvent, user); | ||
|
||
return { guildScheduledEvent, user }; | ||
} | ||
} | ||
|
||
return {}; | ||
} | ||
} | ||
|
||
module.exports = GuildScheduledEventUserAddAction; |
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,32 @@ | ||
'use strict'; | ||
|
||
const Action = require('./Action'); | ||
const { Events } = require('../../util/Constants'); | ||
|
||
class GuildScheduledEventUserRemoveAction extends Action { | ||
handle(data) { | ||
const client = this.client; | ||
const guild = client.guilds.cache.get(data.guild_id); | ||
|
||
if (guild) { | ||
const guildScheduledEvent = this.getScheduledEvent(data, guild); | ||
const user = this.getUser(data); | ||
|
||
if (guildScheduledEvent && user) { | ||
/** | ||
* Emitted whenever a user unsubscribes from a guild scheduled event | ||
* @event Client#guildScheduledEventUserRemove | ||
* @param {GuildScheduledEvent} guildScheduledEvent The guild scheduled event | ||
* @param {User} user The user who unsubscribed | ||
*/ | ||
client.emit(Events.GUILD_SCHEDULED_EVENT_USER_REMOVE, guildScheduledEvent, user); | ||
|
||
return { guildScheduledEvent, user }; | ||
} | ||
} | ||
|
||
return {}; | ||
} | ||
} | ||
|
||
module.exports = GuildScheduledEventUserRemoveAction; |
5 changes: 5 additions & 0 deletions
5
src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.js
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,5 @@ | ||
'use strict'; | ||
|
||
module.exports = (client, packet) => { | ||
client.actions.GuildScheduledEventCreate.handle(packet.d); | ||
}; |
5 changes: 5 additions & 0 deletions
5
src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_DELETE.js
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,5 @@ | ||
'use strict'; | ||
|
||
module.exports = (client, packet) => { | ||
client.actions.GuildScheduledEventDelete.handle(packet.d); | ||
}; |
5 changes: 5 additions & 0 deletions
5
src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.js
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,5 @@ | ||
'use strict'; | ||
|
||
module.exports = (client, packet) => { | ||
client.actions.GuildScheduledEventUpdate.handle(packet.d); | ||
}; |
5 changes: 5 additions & 0 deletions
5
src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_ADD.js
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,5 @@ | ||
'use strict'; | ||
|
||
module.exports = (client, packet) => { | ||
client.actions.GuildScheduledEventUserAdd.handle(packet.d); | ||
}; |
5 changes: 5 additions & 0 deletions
5
src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_REMOVE.js
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,5 @@ | ||
'use strict'; | ||
|
||
module.exports = (client, packet) => { | ||
client.actions.GuildScheduledEventUserRemove.handle(packet.d); | ||
}; |
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
Oops, something went wrong.