Skip to content

Instantly share code, notes, and snippets.

@apos37
apos37 / class-posts-tax-filter.php
Last active October 4, 2022 18:32
WordPress Shortcode Display Posts with Tax Filter
<?php
/**
* Display posts with taxonomy filter
*
* Add file to same folder as functions.php
* Add to functions.php: get_template_part( 'class-posts-tax-filter', '' );
* USAGE: [posts_tax_filter post_type="post" qty="6"]
*/
@apos37
apos37 / avatar.ts
Created August 12, 2022 21:43
Pylon Bot Avatar Command
/**
* Display any user's avatar
*/
commands.raw('avatar', async (message) => {
// Get the user id
const _mentions = message.mentions;
const _msg = message.content.replace('!avatar', '').replaceAll(' ', '');
var _userID = '';
if (_mentions[0]) {
_userID = _mentions[0].id;
@apos37
apos37 / ban.ts
Created August 12, 2022 21:43
Pylon Bot Ban User Command
/**
* Ban a user by mention or id
*/
commands.raw('ban', async (message) => {
// Get the current user
var _currentUser = message.member;
// Check if the current user has the admin role if trying to change someone else's nickname
if (!_currentUser.roles.includes(ADMIN_ROLE_ID)) {
return message.reply(
@apos37
apos37 / docs_js.ts
Created August 12, 2022 21:34
Pylon Bot JavaScript Reference Command
import { commands } from './command_group';
/**
* Fetch with a command
*/
commands.on(
{
name: 'js',
description: 'Fetch a JS code reference',
},
@apos37
apos37 / docs_css.ts
Created August 12, 2022 21:33
Pylon Bot CSS Reference Command
import { commands } from './command_group';
/**
* Fetch with a command
*/
commands.on(
{
name: 'css',
description: 'Fetch a CSS code reference',
},
@apos37
apos37 / karma.ts
Created August 12, 2022 21:32
Pylon Bot Karma Commands and Rewards
import { commands } from './command_group';
import {
ADMIN_ROLE_ID,
BIG_HELPER_ROLE_ID,
APPROVED_FOR_HIRE_ID,
FREELANCER_FOR_HIRE_ID,
EXPERTS_FOR_HIRE_CHANNEL_ID,
} from './ids';
/**
@apos37
apos37 / stackexchange_api.ts
Created August 12, 2022 21:26
Pylon Bot WordPress Stack Exchange Feed
import { commands } from './command_group';
import { STACKEXCHANGE_API_CHANNEL_ID } from './ids';
/**
* KV Namespace
*/
const stackKv = new pylon.KVNamespace('stackexchange');
/**
* Command for listing all items in the KV Namespace
@apos37
apos37 / public_flags.ts
Created August 12, 2022 21:24
Pylon Bot Commands for User Public Flags
import { commands } from './command_group';
import { WELCOME_CHANNEL_ID } from './ids';
/**
* Get user's publicFlags
*/
function getFlagsOld(publicFlags) {
const flags = Array(
[1, 1 << 0, 'DISCORD_EMPLOYEE', 'Discord Employee', true],
[2, 1 << 1, 'DISCORD_PARTNER', 'Discord Partner', true],
@apos37
apos37 / plugins.ts
Created August 12, 2022 21:15
Pylon Bot Command for Sharing WP.org Plugin from Repository
import { commands } from './command_group';
import { SUGGESTED_PLUGINS_CHANNEL_ID } from './ids';
import { numberWithCommas } from './utility';
/**
* KV Namespace
*/
const pluginKV = new pylon.KVNamespace('plugins');
/**