mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
* add webhook structure and getChannelWebhooks as well as getServerWebhooks * add sendMessage * add the ability to edit create and delete hooks * remove server wide cache and add getter.
71 lines
1.6 KiB
JavaScript
Executable File
71 lines
1.6 KiB
JavaScript
Executable File
"use strict";
|
|
|
|
import ServerChannel from "./ServerChannel";
|
|
import Cache from "../Util/Cache";
|
|
import {reg} from "../Util/ArgumentRegulariser";
|
|
|
|
export default class TextChannel extends ServerChannel{
|
|
constructor(data, client, server){
|
|
super(data, client, server);
|
|
|
|
this.topic = data.topic;
|
|
this.lastMessageID = data.last_message_id || data.lastMessageID;
|
|
this.webhooks = new Cache("id");
|
|
this.messages = new Cache("id", client.options.maxCachedMessages);
|
|
}
|
|
|
|
/* warning! may return null */
|
|
get lastMessage(){
|
|
return this.messages.get("id", this.lastMessageID);
|
|
}
|
|
|
|
toObject() {
|
|
let obj = super.toObject();
|
|
|
|
obj.topic = this.topic;
|
|
obj.lastMessageID = this.lastMessageID;
|
|
|
|
return obj;
|
|
}
|
|
|
|
setTopic(){
|
|
return this.client.setChannelTopic.apply(this.client, reg(this, arguments));
|
|
}
|
|
|
|
sendMessage(){
|
|
return this.client.sendMessage.apply(this.client, reg(this, arguments));
|
|
}
|
|
|
|
send(){
|
|
return this.client.sendMessage.apply(this.client, reg(this, arguments));
|
|
}
|
|
|
|
sendTTSMessage(){
|
|
return this.client.sendTTSMessage.apply(this.client, reg(this, arguments));
|
|
}
|
|
|
|
sendTTS(){
|
|
return this.client.sendTTSMessage.apply(this.client, reg(this, arguments));
|
|
}
|
|
|
|
sendFile(){
|
|
return this.client.sendFile.apply(this.client, reg(this, arguments));
|
|
}
|
|
|
|
getLogs(){
|
|
return this.client.getChannelLogs.apply(this.client, reg(this, arguments));
|
|
}
|
|
|
|
getMessage() {
|
|
return this.client.getMessage.apply(this.client, reg(this, arguments));
|
|
}
|
|
|
|
startTyping(){
|
|
return this.client.startTyping.apply(this.client, reg(this, arguments));
|
|
}
|
|
|
|
stopTyping(){
|
|
return this.client.stopTyping.apply(this.client, reg(this, arguments));
|
|
}
|
|
}
|