Fix userid/channelid argument types; rename userid/userID to userId for consistency; misc code style fix

This commit is contained in:
Dragory 2019-08-10 01:47:45 +03:00
parent afd677b270
commit 8d8343543d
6 changed files with 17 additions and 17 deletions

View file

@ -49,7 +49,7 @@ export class AutoReactionsPlugin extends ZeppelinPlugin<TConfigSchema> {
this.savedMessages.events.off("create", this.onMessageCreateFn); this.savedMessages.events.off("create", this.onMessageCreateFn);
} }
@d.command("auto_reactions", "<channelId:channelid> <reactions...>") @d.command("auto_reactions", "<channelId:channelId> <reactions...>")
@d.permission("can_manage") @d.permission("can_manage")
async setAutoReactionsCmd(msg: Message, args: { channelId: string; reactions: string[] }) { async setAutoReactionsCmd(msg: Message, args: { channelId: string; reactions: string[] }) {
const finalReactions = []; const finalReactions = [];
@ -83,7 +83,7 @@ export class AutoReactionsPlugin extends ZeppelinPlugin<TConfigSchema> {
msg.channel.createMessage(successMessage(`Auto-reactions set for <#${args.channelId}>`)); msg.channel.createMessage(successMessage(`Auto-reactions set for <#${args.channelId}>`));
} }
@d.command("auto_reactions disable", "<channelId:channelid>") @d.command("auto_reactions disable", "<channelId:channelId>")
@d.permission("can_manage") @d.permission("can_manage")
async disableAutoReactionsCmd(msg: Message, args: { channelId: string }) { async disableAutoReactionsCmd(msg: Message, args: { channelId: string }) {
const autoReaction = await this.autoReactions.getForChannel(args.channelId); const autoReaction = await this.autoReactions.getForChannel(args.channelId);

View file

@ -52,7 +52,7 @@ export class LocatePlugin extends ZeppelinPlugin<TConfigSchema> {
for (const alert of outdatedAlerts) { for (const alert of outdatedAlerts) {
await this.alerts.delete(alert.id); await this.alerts.delete(alert.id);
await this.removeUserIDFromActiveAlerts(alert.user_id); await this.removeUserIdFromActiveAlerts(alert.user_id);
} }
this.outdatedAlertsTimeout = setTimeout(() => this.outdatedAlertsLoop(), ALERT_LOOP_TIME); this.outdatedAlertsTimeout = setTimeout(() => this.outdatedAlertsLoop(), ALERT_LOOP_TIME);
@ -137,7 +137,7 @@ export class LocatePlugin extends ZeppelinPlugin<TConfigSchema> {
async userJoinedVC(member: Member, channel: Channel) { async userJoinedVC(member: Member, channel: Channel) {
if (this.usersWithAlerts.includes(member.id)) { if (this.usersWithAlerts.includes(member.id)) {
this.sendAlerts(member.id); this.sendAlerts(member.id);
await this.removeUserIDFromActiveAlerts(member.id); await this.removeUserIdFromActiveAlerts(member.id);
} }
} }
@ -145,7 +145,7 @@ export class LocatePlugin extends ZeppelinPlugin<TConfigSchema> {
async userSwitchedVC(member: Member, newChannel: Channel, oldChannel: Channel) { async userSwitchedVC(member: Member, newChannel: Channel, oldChannel: Channel) {
if (this.usersWithAlerts.includes(member.id)) { if (this.usersWithAlerts.includes(member.id)) {
this.sendAlerts(member.id); this.sendAlerts(member.id);
await this.removeUserIDFromActiveAlerts(member.id); await this.removeUserIdFromActiveAlerts(member.id);
} }
} }
@ -157,9 +157,9 @@ export class LocatePlugin extends ZeppelinPlugin<TConfigSchema> {
}); });
} }
async sendAlerts(userid: string) { async sendAlerts(userId: string) {
const triggeredAlerts = await this.alerts.getAlertsByUserId(userid); const triggeredAlerts = await this.alerts.getAlertsByUserId(userId);
const member = await resolveMember(this.bot, this.guild, userid); const member = await resolveMember(this.bot, this.guild, userId);
triggeredAlerts.forEach(alert => { triggeredAlerts.forEach(alert => {
const prepend = `<@!${alert.requestor_id}>, an alert requested by you has triggered!\nReminder: \`${ const prepend = `<@!${alert.requestor_id}>, an alert requested by you has triggered!\nReminder: \`${
@ -170,8 +170,8 @@ export class LocatePlugin extends ZeppelinPlugin<TConfigSchema> {
}); });
} }
async removeUserIDFromActiveAlerts(userid: string) { async removeUserIdFromActiveAlerts(userId: string) {
const index = this.usersWithAlerts.indexOf(userid); const index = this.usersWithAlerts.indexOf(userId);
if (index > -1) { if (index > -1) {
this.usersWithAlerts.splice(index, 1); this.usersWithAlerts.splice(index, 1);
} }

View file

@ -40,7 +40,7 @@ export class NameHistoryPlugin extends ZeppelinPlugin<TConfigSchema> {
this.usernameHistory = new UsernameHistory(); this.usernameHistory = new UsernameHistory();
} }
@d.command("names", "<userId:userid>") @d.command("names", "<userId:userId>")
@d.permission("can_view") @d.permission("can_view")
async namesCmd(msg: Message, args: { userId: string }) { async namesCmd(msg: Message, args: { userId: string }) {
const nicknames = await this.nicknameHistory.getByUserId(args.userId); const nicknames = await this.nicknameHistory.getByUserId(args.userId);
@ -72,7 +72,7 @@ export class NameHistoryPlugin extends ZeppelinPlugin<TConfigSchema> {
@d.event("guildMemberUpdate") @d.event("guildMemberUpdate")
async onGuildMemberUpdate(_, member: Member) { async onGuildMemberUpdate(_, member: Member) {
const latestEntry = await this.nicknameHistory.getLastEntry(member.id); const latestEntry = await this.nicknameHistory.getLastEntry(member.id);
if (!latestEntry || latestEntry.nickname != member.nick) { if (!latestEntry || latestEntry.nickname !== member.nick) {
// tslint:disable-line // tslint:disable-line
await this.nicknameHistory.addEntry(member.id, member.nick); await this.nicknameHistory.addEntry(member.id, member.nick);
} }

View file

@ -53,7 +53,7 @@ export class PingableRolesPlugin extends ZeppelinPlugin<TConfigSchema> {
return this.cache.get(channelId); return this.cache.get(channelId);
} }
@d.command("pingable_role disable", "<channelId:channelid> <role:role>") @d.command("pingable_role disable", "<channelId:channelId> <role:role>")
@d.permission("can_manage") @d.permission("can_manage")
async disablePingableRoleCmd(msg: Message, args: { channelId: string; role: Role }) { async disablePingableRoleCmd(msg: Message, args: { channelId: string; role: Role }) {
const pingableRole = await this.pingableRoles.getByChannelAndRoleId(args.channelId, args.role.id); const pingableRole = await this.pingableRoles.getByChannelAndRoleId(args.channelId, args.role.id);
@ -70,7 +70,7 @@ export class PingableRolesPlugin extends ZeppelinPlugin<TConfigSchema> {
); );
} }
@d.command("pingable_role", "<channelId:channelid> <role:role>") @d.command("pingable_role", "<channelId:channelId> <role:role>")
@d.permission("can_manage") @d.permission("can_manage")
async setPingableRoleCmd(msg: Message, args: { channelId: string; role: Role }) { async setPingableRoleCmd(msg: Message, args: { channelId: string; role: Role }) {
const existingPingableRole = await this.pingableRoles.getByChannelAndRoleId(args.channelId, args.role.id); const existingPingableRole = await this.pingableRoles.getByChannelAndRoleId(args.channelId, args.role.id);

View file

@ -177,7 +177,7 @@ export class StarboardPlugin extends ZeppelinPlugin<TConfigSchema> {
/** /**
* Deletes the starboard from the specified channel. The already-posted starboard messages are retained. * Deletes the starboard from the specified channel. The already-posted starboard messages are retained.
*/ */
@d.command("starboard delete", "<channelId:channelid>") @d.command("starboard delete", "<channelId:channelId>")
@d.permission("can_manage") @d.permission("can_manage")
async deleteCmd(msg: Message, args: { channelId: string }) { async deleteCmd(msg: Message, args: { channelId: string }) {
const starboard = await this.starboards.getStarboardByChannelId(args.channelId); const starboard = await this.starboards.getStarboardByChannelId(args.channelId);
@ -336,7 +336,7 @@ export class StarboardPlugin extends ZeppelinPlugin<TConfigSchema> {
} }
} }
@d.command("starboard migrate_pins", "<pinChannelId:channelid> <starboardChannelId:channelid>") @d.command("starboard migrate_pins", "<pinChannelId:channelId> <starboardChannelId:channelId>")
async migratePinsCmd(msg: Message, args: { pinChannelId: string; starboardChannelId }) { async migratePinsCmd(msg: Message, args: { pinChannelId: string; starboardChannelId }) {
const starboard = await this.starboards.getStarboardByChannelId(args.starboardChannelId); const starboard = await this.starboards.getStarboardByChannelId(args.starboardChannelId);
if (!starboard) { if (!starboard) {

View file

@ -554,7 +554,7 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
}, CLEAN_COMMAND_DELETE_DELAY); }, CLEAN_COMMAND_DELETE_DELAY);
} }
@d.command("clean user", "<userId:userid> <count:number>") @d.command("clean user", "<userId:userId> <count:number>")
@d.permission("can_clean") @d.permission("can_clean")
async cleanUserCmd(msg: Message, args: { userId: string; count: number }) { async cleanUserCmd(msg: Message, args: { userId: string; count: number }) {
if (args.count > MAX_CLEAN_COUNT || args.count <= 0) { if (args.count > MAX_CLEAN_COUNT || args.count <= 0) {