Add missing delete() method to IChannel; Fixes #105
This commit is contained in:
parent
3643e239bb
commit
3a22fa65e7
|
@ -33,6 +33,9 @@ abstract class IChannel extends SnowflakeEntity implements Disposable {
|
|||
}
|
||||
}
|
||||
|
||||
/// Deletes channel if guild channel or closes DM if DM channel
|
||||
Future<void> delete() => this.client.httpEndpoints.deleteChannel(this.id);
|
||||
|
||||
@override
|
||||
Future<void> dispose() async {
|
||||
// Empty body
|
||||
|
|
|
@ -269,6 +269,8 @@ abstract class IHttpEndpoints {
|
|||
Future<GuildPreview> fetchGuildPreview(Snowflake guildId);
|
||||
|
||||
Future<IChannel> createGuildChannel(Snowflake guildId, ChannelBuilder channelBuilder);
|
||||
|
||||
Future<void> deleteChannel(Snowflake channelId);
|
||||
}
|
||||
|
||||
class _HttpEndpoints implements IHttpEndpoints {
|
||||
|
@ -1466,6 +1468,7 @@ class _HttpEndpoints implements IHttpEndpoints {
|
|||
|
||||
return Future.error(response);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<IChannel> createGuildChannel(Snowflake guildId, ChannelBuilder channelBuilder) async {
|
||||
final response = await _httpClient._execute(
|
||||
|
@ -1477,4 +1480,13 @@ class _HttpEndpoints implements IHttpEndpoints {
|
|||
|
||||
return Future.error(response);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteChannel(Snowflake channelId) async {
|
||||
final response = await _httpClient._execute(BasicRequest._new("/channels/${channelId.toString()}", method: "DELETE"));
|
||||
|
||||
if (response is HttpResponseError) {
|
||||
return Future.error(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue