PageSourceSearch

https://yagpdb-cc.github.io/assets/js/17e9e1bb.982f121f.js

js yagpdb-cc.github.io collected 2026-10-03 10:13:20 UTC 8,385 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[5047],{5680:(e,n,t)=>{t.d(n,{xA:()=>p,yg:()=>m});var r=t(6540);function i(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function s(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?a(Object(t),!0).forEach((function(n){i(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function o(e,n){if(null==e)return{};var t,r,i=function(e,n){if(null==e)return{};var t,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}var l=r.createContext({}),c=function(e){var n=r.useContext(l),t=n;return e&&(t="function"==typeof e?e(n):s(s({},n),e)),t},p=function(e){var n=c(e.components);return r.createElement(l.Provider,{value:n},e.children)},d="mdxType",u={inlineCode:"code",wrapper:function(e){var n=e.children;return r.createElement(r.Fragment,{},n)}},g=r.forwardRef((function(e,n){var t=e.components,i=e.mdxType,a=e.originalType,l=e.parentName,p=o(e,["components","mdxType","originalType","parentName"]),d=c(t),g=i,m=d["".concat(l,".").concat(g)]||d[g]||u[g]||a;return t?r.createElement(m,s(s({ref:n},p),{},{components:t})):r.createElement(m,s({ref:n},p))}));function m(e,n){var t=arguments,i=n&&n.mdxType;if("string"==typeof e||i){var a=t.length,s=new Array(a);s[0]=g;var o={};for(var l in n)hasOwnProperty.call(n,l)&&(o[l]=n[l]);o.originalType=e,o[d]="string"==typeof e?e:i,s[1]=o;for(var c=2;c<a;c++)s[c]=t[c];return r.createElement.apply(null,s)}return r.createElement.apply(null,t)}g.displayName="MDXCreateElement"},373:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>s,default:()=>u,frontMatter:()=>a,metadata:()=>o,toc:()=>c});var r=t(8168),i=(t(6540),t(5680));const a={title:"Export CCs"},s=void 0,o={unversionedId:"utilities/export-ccs",id:"utilities/export-ccs",title:"Export CCs",description:"Export all custom commands in the server as files with additional metadata.",source:"@site/docs/utilities/export-ccs.md",sourceDirName:"utilities",slug:"/utilities/export-ccs",permalink:"/utilities/export-ccs",draft:!1,editUrl:"https://github.com/yagpdb-cc/yagpdb-cc/edit/master/website/docs/utilities/export-ccs.md",tags:[],version:"current",frontMatter:{title:"Export CCs"},sidebar:"sidebar",previous:{title:"Edit Message",permalink:"/utilities/edit"},next:{title:"Flag Message",permalink:"/utilities/flag-message"}},l={},c=[{value:"Trigger",id:"trigger",level:2},{value:"Configuration",id:"configuration",level:2},{value:"Code",id:"code",level:2},{value:"Author",id:"author",level:2}],p={toc:c},d="wrapper";
1function u(e){let{components:n,...t}=e;return(0,i.yg)(d,(0,r.A)({},p,t,{components:n,mdxType:"MDXLayout"}),(0,i.yg)("p",null,"Export all custom commands in the server as files with additional metadata."),(0,i.yg)("admonition",{type:"tip"},(0,i.yg)("p",{parentName:"admonition"},"Executing this script in a ticket channel allows you to instruct YAGPDB.xyz to bundle all of the exported files in a zip archive!")),(0,i.yg)("h2",{id:"trigger"},"Trigger"),(0,i.yg)("p",null,(0,i.yg)("strong",{parentName:"p"},"Type:")," ",(0,i.yg)("inlineCode",{parentName:"p"},"Command"),(0,i.yg)("br",null),"\n",(0,i.yg)("strong",{parentName:"p"},"Trigger:")," ",(0,i.yg)("inlineCode",{parentName:"p"},"export-ccs")),(0,i.yg)("h2",{id:"configuration"},"Configuration"),(0,i.yg)("ul",null,(0,i.yg)("li",{parentName:"ul"},(0,i.yg)("inlineCode",{parentName:"li"},"$permissions"),(0,i.yg)("br",null),"\nThe triggering user must have at least one of the listed permissions to run the export CCs command.")),(0,i.yg)("h2",{id:"code"},"Code"),(0,i.yg)("pre",null,(0,i.yg)("code",{parentName:"pre",className:"language-gotmpl",metastring:"file=../../../src/utilities/export-ccs.go.tmpl",file:"../../../src/utilities/export-ccs.go.tmpl"},'{{/*\n    Export all server CCs as files.\n    See <https://yagpdb-cc.github.io/utilities/export-ccs> for more information.\n\n    Author: galen8183 <https://github.com/galen8183>\n*/}}\n\n{{/* Configuration values */}}\n{{$permissions := bitwiseOr .Permissions.Administrator .Permissions.ManageServer}}\n{{/* End of configuration values */}}\n\n{{if not .ExecData}}\n    {{if not (hasPermissions $permissions)}}\n        You don\'t have permission to run this command!\n        {{return}}\n    {{end}}\n\n    {{$lines := split (exec "cc") "\\n"}}\n    {{$ccs := slice $lines 1 (len $lines | add -1)}}\n\n    {{/* safety against unintentional invocation */}}\n    {{if not (dbGet .Channel.ID "CC export timer")}}\n        {{dbSetExpire .Channel.ID "CC export timer" true 60}}\n\u26a0\ufe0f **Warning**\nAre you sure you want to do this?\nAll {{len $ccs}} CCs in this server will be sent as individual files, to this channel!\nIf yes, run the command again within the next minute (60s).\n        {{return}}\n    {{end}}\n\n    {{dbDel .Channel.ID "CC export timer"}}\n\n    {{sendMessage nil (cembed\n        "title" "Export CCs"\n        "url" "https://yagpdb-cc.github.io/utilities/export-ccs"\n        "description" "Beginning CC export in 5 seconds!"\n    )}}\n\n    {{/* get metadata from the inbuilt `customcommands` command */}}\n    {{$meta := cslice}}\n    {{range $ccs}}\n        {{- $c := sdict}}\n        {{- range reFindAllSubmatches `\\x60#\\s*(\\d+):\\x60|(?:- (\\w+): \\x60(.+?)\\x60)(?: |$)` .}}\n            {{- if index . 1}}\n                {{- $c.Set "CCID" (index . 1 | toInt)}}\n            {{- else}}\n                {{- $c.Set (index . 2) (index . 3)}}\n            {{- end}}\n        {{- end}}\n\n        {{- $meta = $meta.Append $c}}\n    {{end}}\n\n    {{execCC .CCID nil 5 (sdict\n        "Meta" $meta\n        "Groups" sdict\n        "Count" (len $ccs)\n    )}}\n    {{return}}\n{{end}}\n\n{{/* start sending files */}}\n\n{{$meta := .ExecData.Meta}}\n{{$groups := .ExecData.Groups}}\n\n{{/* export 5 CCs at a time (exec function limit) */}}\n{{range 5}}\n    {{- if le (len $meta) .}}\n        {{- break }}\n    {{- end}}\n\n    {{- $c := index $meta .}}\n\n    {{- /* get just the response content, no preamble or code block */}}\n    {{- $lines := split (exec "cc" $c.CCID "-raw").Content "\\n"}}\n    {{- $response := slice $lines 2 (len $lines | add -1)}}\n    {{- $msg := sendMessageRetID nil (complexMessage\n        "file" (joinStr "\\n" $response)\n        "filename" (printf "%03d-%s" $c.CCID (or $c.Name $c.Trigger))\n    )}}\n\n    {{- $c.Set "URL" (index (getMessage nil $msg).Attachments 0).URL}}\n    {{- $groups.Set $c.Group ((or ($groups.Get $c.Group) cslice).Append $c)}}\n{{end}}\n\n{{/* more CCs to export? */}}\n{{if gt (len $meta) 5}}\n    {{.ExecData.Set "Meta" (slice $meta 5)}}\n    {{execCC .CCID nil 10 .ExecData}}\n    {{return}}\n{{end}}\n\n{{$chars := 0}}\n{{$total := 0}}\n{{$fields := cslice}}\n{{range $n, $v := $groups}}\n    {{- $g := ""}}\n    {{- range $v}}
1\n        {{- $g = printf "%s[#%d](%s) - %s\\n" $g .CCID .URL .Trigger}}\n    {{- end}}\n\n    {{- $chars = len $g}}\n    {{- $total = add $total $chars}}\n    {{- if gt $chars 1000}}\n        {{- break}}\n    {{- end}}\n\n    {{- $fields = $fields.Append (sdict "name" $n "value" $g)}}\n{{end}}\n\n{{$m := sdict\n    "file" (json $groups true)\n    "filename" "cc-export-metadata"\n    "embed" (sdict\n        "title" "CC Export Complete!"\n        "fields" $fields\n    )\n}}\n\n{{if or (gt $chars 1000) (gt $total 5000) (gt (len $fields) 25)}}\n    {{$m.embed.Del "fields"}}\n    {{$m.embed.Set "description" "Pretty text grew too long, please refer to the attached metadata file!"}}\n{{end}}\n\n{{sendMessage nil (complexMessage $m)}}\n')),(0,i.yg)("h2",{id:"author"},"Author"),(0,i.yg)("p",null,"This custom command was written by ",(0,i.yg)("a",{parentName:"p",href:"https://github.com/galen8183"},"@galen8183"),"."))}u.isMDXComponent=!0}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.