commit
c4f41593c0
@ -0,0 +1,12 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<module type="WEB_MODULE" version="4"> |
||||||
|
<component name="NewModuleRootManager"> |
||||||
|
<content url="file://$MODULE_DIR$"> |
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.tmp" /> |
||||||
|
<excludeFolder url="file://$MODULE_DIR$/temp" /> |
||||||
|
<excludeFolder url="file://$MODULE_DIR$/tmp" /> |
||||||
|
</content> |
||||||
|
<orderEntry type="inheritedJdk" /> |
||||||
|
<orderEntry type="sourceFolder" forTests="false" /> |
||||||
|
</component> |
||||||
|
</module> |
@ -0,0 +1,8 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project version="4"> |
||||||
|
<component name="ProjectModuleManager"> |
||||||
|
<modules> |
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/Natsuki.iml" filepath="$PROJECT_DIR$/.idea/Natsuki.iml" /> |
||||||
|
</modules> |
||||||
|
</component> |
||||||
|
</project> |
@ -0,0 +1,26 @@ |
|||||||
|
const Discord = require('discord.js'); |
||||||
|
const {Tag} = require('../util/tag'); |
||||||
|
const {TagFilter} = require('../util/tagfilter'); |
||||||
|
|
||||||
|
module.exports = { |
||||||
|
name: "avatar", |
||||||
|
aliases: ['av', 'a', 'pfp'], |
||||||
|
help: "Use `{{p}}avatar` to get your own profile picture, or mention someone to get theirs!", |
||||||
|
async execute(message, msg, args, cmd, prefix, mention, client) { |
||||||
|
let member = !args.length ? message.author : mention ? mention : client.users.cache.has(args[0]) ? client.users.cache.get(args[0]) : message.author; |
||||||
|
let name = !args.length ? message.member ? message.member.displayName : message.author.username : mention ? mention.username : client.users.cache.has(args[0]) ? client.users.cache.get(args[0]).username : message.author.username; |
||||||
|
let options = new TagFilter([ |
||||||
|
new Tag(['small', 's', 'mini', 'm'], 'small', 'toggle'), |
||||||
|
new Tag(['verysmall', 'vsmall', '-vs', 'xs'], 'vsmall', 'toggle') |
||||||
|
]).test(args.join(" ")); |
||||||
|
try { |
||||||
|
let avem = new Discord.MessageEmbed() |
||||||
|
.setTitle(`${name.endsWith('s') ? `${name}'` : `${name}'s`} Avatar`) |
||||||
|
.setImage(member.avatarURL({size: options.vsmall ? 128 : options.small ? 256 : 2048})) |
||||||
|
.setColor('c375f0') |
||||||
|
.setFooter("Natsuki", client.user.avatarURL()) |
||||||
|
if (!options.vsmall) {avem.setTimestamp();} |
||||||
|
return message.channel.send(avem); |
||||||
|
} catch {return message.reply("Hmm, there seems to have been an error while I tried to show you that user's avatar.");} |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,48 @@ |
|||||||
|
const Discord = require('discord.js'); |
||||||
|
const GuildSettings = require('../models/guild'); |
||||||
|
|
||||||
|
module.exports = { |
||||||
|
name: "staffrole", |
||||||
|
aliases: ['sr', 'setstaffrole'], |
||||||
|
help: "Set your server's staff role, which allows users with that role to modify my settings in this server. You must be an admin in the server to change this setting.", |
||||||
|
async execute(message, msg, args, cmd, prefix, mention, client) { |
||||||
|
if (!message.guild) {return message.reply("This is a guild-only command!");} |
||||||
|
if (!args.length) {return message.channel.send(`Syntax: \`${prefix}staffrole <@role|roleID|clear|view>\``);} |
||||||
|
if (!message.member.permissions.has("ADMINISTRATOR")) {return message.reply("You must be an admin in this server in order to change this setting!");} |
||||||
|
|
||||||
|
let tguild = await GuildSettings.findOne({gid: message.guild.id}) |
||||||
|
? await GuildSettings.findOne({gid: message.guild.id}) |
||||||
|
: new GuildSettings({gid: message.guild.id}); |
||||||
|
|
||||||
|
if (['view', 'v'].includes(args[0].trim().toLocaleLowerCase())) {return message.reply( |
||||||
|
tguild.staffrole.length |
||||||
|
? message.guild.roles.cache.has(tguild.staffrole) |
||||||
|
? `\`People with the ${message.guild.roles.cache.get(tguild.staffrole).name}\` role can edit my setting here.` |
||||||
|
: `I have a role stored for this server, but it doesn't seem to exist anymore, so only admins can edit my settings right now.` |
||||||
|
: 'Only admins may edit settings in this server.' |
||||||
|
);} |
||||||
|
|
||||||
|
let role = !['c', 'clear', 'n', 'none'].includes(args[0].trim().toLowerCase()) ? message.mentions.roles.size ? message.mentions.roles.first() : message.guild.roles.cache.has(args[0]) ? message.guild.roles.cache.get(args[0]) : null : 'c'; |
||||||
|
|
||||||
|
if (!role) {return message.reply("I couldn't find that role!");} |
||||||
|
if (role === "c") { |
||||||
|
tguild.staffrole = ''; |
||||||
|
tguild.save(); |
||||||
|
return message.reply("Got it, only admins can edit my settings in this server."); |
||||||
|
} else { |
||||||
|
tguild.staffrole = role.id; |
||||||
|
tguild.save(); |
||||||
|
let upm = message.reply("Sure thing!"); |
||||||
|
await require('../util/wait')(1750); |
||||||
|
return upm.edit(new Discord.MessageEmbed() |
||||||
|
.setAuthor('Staff role updated!', message.author.avatarURL()) |
||||||
|
.setDescription(`<@${tguild.staffrole}> can now edit my settings in this server.`) |
||||||
|
.addField('Auditing Admin', message.member.displayName, true) |
||||||
|
.addField('Role-Holders', `${message.guild.members.cache.filter(m => m.roles.cache.has(tguild.staffrole) && !client.users.cache.get(m.id).bot)}+ members have this role`) |
||||||
|
.setColor('c375f0') |
||||||
|
.setFooter('Natsuki', client.user.avatarURL()) |
||||||
|
.setTimestamp() |
||||||
|
); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,9 @@ |
|||||||
|
export declare class Tag { |
||||||
|
triggers: string[]; |
||||||
|
tagName: string; |
||||||
|
filterType: TagFilterType; |
||||||
|
constructor(triggers: string[], tagName: string, filterType: TagFilterType); |
||||||
|
addTrigger(trigger: string): Tag; |
||||||
|
} |
||||||
|
declare type TagFilterType = "append" | "toggle"; |
||||||
|
export {}; |
@ -0,0 +1,21 @@ |
|||||||
|
"use strict"; |
||||||
|
Object.defineProperty(exports, "__esModule", { value: true }); |
||||||
|
exports.Tag = void 0; |
||||||
|
class Tag { |
||||||
|
constructor(triggers, tagName, filterType) { |
||||||
|
this.triggers = []; |
||||||
|
let trigger; |
||||||
|
for (trigger of triggers) { |
||||||
|
this.triggers.push(trigger.trim().startsWith("-") ? trigger.trim() : `-${trigger.trim()}`); |
||||||
|
} |
||||||
|
this.tagName = tagName; |
||||||
|
this.filterType = filterType; |
||||||
|
} |
||||||
|
; |
||||||
|
addTrigger(trigger) { |
||||||
|
this.triggers.push(trigger.trim().startsWith("-") ? trigger.trim() : `-${trigger.trim()}`); |
||||||
|
return this; |
||||||
|
} |
||||||
|
; |
||||||
|
} |
||||||
|
exports.Tag = Tag; |
@ -0,0 +1,10 @@ |
|||||||
|
import { Tag } from "./tag"; |
||||||
|
export declare class TagFilter { |
||||||
|
tags: Tag[]; |
||||||
|
triggers: Map<String, String>; |
||||||
|
filterTypes: Map<String, TagFilterType>; |
||||||
|
constructor(tags: Tag[]); |
||||||
|
test(text: string): object; |
||||||
|
} |
||||||
|
declare type TagFilterType = "append" | "toggle"; |
||||||
|
export {}; |
@ -0,0 +1,49 @@ |
|||||||
|
"use strict"; |
||||||
|
Object.defineProperty(exports, "__esModule", { value: true }); |
||||||
|
exports.TagFilter = void 0; |
||||||
|
class TagFilter { |
||||||
|
constructor(tags) { |
||||||
|
this.tags = tags; |
||||||
|
this.triggers = new Map(); |
||||||
|
this.filterTypes = new Map(); |
||||||
|
let tag; |
||||||
|
for (tag of this.tags) { |
||||||
|
let trigger; |
||||||
|
for (trigger of tag.triggers) { |
||||||
|
this.triggers.set(trigger, tag.tagName); |
||||||
|
} |
||||||
|
if (!this.filterTypes.has(tag.tagName)) { |
||||||
|
this.filterTypes.set(tag.tagName, tag.filterType); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
test(text) { |
||||||
|
var filtered = {}; |
||||||
|
var reading = null; |
||||||
|
let words = text.trim().split(/\s+/g); |
||||||
|
let word; |
||||||
|
for (word of words) { |
||||||
|
if (word.startsWith('-') && word.length > 1 && this.triggers.has(word.trim())) { |
||||||
|
reading = this.filterTypes.get(this.triggers.get(word.trim())) == "toggle" ? null : word.trim(); |
||||||
|
if (!reading) { |
||||||
|
filtered[`${this.triggers.get(word.trim())}`] = true; |
||||||
|
} |
||||||
|
else { |
||||||
|
filtered[`${this.triggers.get(reading)}`] = ''; |
||||||
|
} |
||||||
|
} |
||||||
|
else if (reading) { |
||||||
|
filtered[`${this.triggers.get(reading)}`] = `${filtered[`${this.triggers.get(reading)}`]} ${word}`; |
||||||
|
} |
||||||
|
} |
||||||
|
let key; |
||||||
|
for (key of Object.keys(filtered)) { |
||||||
|
if (typeof filtered[key] == 'string') { |
||||||
|
filtered[key] = filtered[key].trim(); |
||||||
|
} |
||||||
|
} |
||||||
|
return filtered; |
||||||
|
} |
||||||
|
; |
||||||
|
} |
||||||
|
exports.TagFilter = TagFilter; |
@ -0,0 +1,25 @@ |
|||||||
|
export class Tag { |
||||||
|
triggers: string[] = []; |
||||||
|
tagName: string; |
||||||
|
filterType: TagFilterType; |
||||||
|
|
||||||
|
constructor(triggers: string[], tagName: string, filterType: TagFilterType) { |
||||||
|
let trigger: string; for (trigger of triggers) { |
||||||
|
this.triggers.push( |
||||||
|
trigger.trim().startsWith("-") ? trigger.trim() : `-${trigger.trim()}` |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
this.tagName = tagName; |
||||||
|
this.filterType = filterType; |
||||||
|
}; |
||||||
|
|
||||||
|
public addTrigger(trigger: string): Tag { |
||||||
|
this.triggers.push( |
||||||
|
trigger.trim().startsWith("-") ? trigger.trim() : `-${trigger.trim()}` |
||||||
|
); |
||||||
|
return this; |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
type TagFilterType = "append" | "toggle"; |
@ -0,0 +1,45 @@ |
|||||||
|
import {Tag} from "./tag"; |
||||||
|
|
||||||
|
export class TagFilter { |
||||||
|
tags: Tag[]; |
||||||
|
triggers: Map<String, String>; |
||||||
|
filterTypes: Map<String, TagFilterType>; |
||||||
|
|
||||||
|
constructor(tags: Tag[]) { |
||||||
|
this.tags = tags; |
||||||
|
this.triggers = new Map<String, String>(); |
||||||
|
this.filterTypes = new Map<String, TagFilterType>(); |
||||||
|
let tag: Tag; |
||||||
|
for (tag of this.tags) { |
||||||
|
let trigger: string; for (trigger of tag.triggers) { |
||||||
|
this.triggers.set(trigger, tag.tagName); |
||||||
|
} |
||||||
|
if (!this.filterTypes.has(tag.tagName)) {this.filterTypes.set(tag.tagName, tag.filterType);} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public test(text: string): object { |
||||||
|
var filtered: object = {}; |
||||||
|
var reading: string = null; |
||||||
|
|
||||||
|
let words = text.trim().split(/\s+/g); |
||||||
|
let word: string; for (word of words) { |
||||||
|
if (word.startsWith('-') && word.length > 1 && this.triggers.has(word.trim())) { |
||||||
|
reading = this.filterTypes.get(this.triggers.get(word.trim())) == "toggle" ? null : word.trim(); |
||||||
|
if (!reading) {filtered[`${this.triggers.get(word.trim())}`] = true;} |
||||||
|
else {filtered[`${this.triggers.get(reading)}`] = '';} |
||||||
|
} |
||||||
|
else if (reading) { |
||||||
|
filtered[`${this.triggers.get(reading)}`] = `${filtered[`${this.triggers.get(reading)}`]} ${word}`; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
let key: string; for (key of Object.keys(filtered)) { |
||||||
|
if (typeof filtered[key] == 'string') {filtered[key] = filtered[key].trim();} |
||||||
|
} |
||||||
|
|
||||||
|
return filtered; |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
type TagFilterType = "append" | "toggle"; |
@ -0,0 +1,11 @@ |
|||||||
|
{ |
||||||
|
"compilerOptions": { |
||||||
|
"module": "commonjs", |
||||||
|
"lib": ["es2017", "es6", "dom"], |
||||||
|
"target": "es2017", |
||||||
|
"declaration": true, |
||||||
|
"outDir": "../" |
||||||
|
}, |
||||||
|
"include": ["**/*"], |
||||||
|
"exclude": [] |
||||||
|
} |
Loading…
Reference in new issue