bot invite generator and css updates

This commit is contained in:
MathMan05 2024-09-25 12:48:07 -05:00
parent 6196c4ac85
commit 5c4b5605ed
5 changed files with 46 additions and 8 deletions

View file

@ -1,9 +1,11 @@
import { mainuserjson } from "./jsontypes.js";
import { Localuser } from "./localuser.js";
import { MarkDown } from "./markdown.js";
import { Settings } from "./settings.js";
import { Form, Settings } from "./settings.js";
import { User } from "./user.js";
import {guildjson} from "./jsontypes.js";
import { PermissionToggle } from "./role.js";
import { Permissions } from "./permissions.js";
class Bot{
readonly owner:Localuser;
readonly token:string;
@ -247,5 +249,29 @@ class Bot{
body: JSON.stringify(json),
});
}
static InviteMaker(id:string,container:Form,info:Localuser["info"]){
const gen=container.addSubOptions("URL generator",{
noSubmit:true
});
const params = new URLSearchParams("");
params.set("instance", info.wellknown);
params.set("client_id", id);
params.set("scope", "bot");
const url=gen.addText("");
const perms=new Permissions("0");
for(const perm of Permissions.info){
const permsisions=new PermissionToggle(perm,perms,gen);
gen.options.push(permsisions);
gen.generate(permsisions);
}
const cancel=setInterval(()=>{
if(!gen.container.deref()){
clearInterval(cancel);
}
params.set("permissions",perms.allow.toString());
const encoded = params.toString();
url.setText(`${location.origin}/oauth2/authorize?${encoded}`);
},100)
}
}
export {Bot};

View file

@ -1474,6 +1474,9 @@ class Localuser{
const botc=new Bot(bot,token,this);
botc.settings();
}
});
form.addButtonInput("","Bot Invite Creator",()=>{
Bot.InviteMaker(appId,form,this.info);
})
}
//---------- resolving members code -----------

View file

@ -296,6 +296,9 @@ class Permissions{
}
}
getPermission(name: string): number{
if(undefined===Permissions.map[name]){
console.error(name +" is not found in map",Permissions.map);
}
if(this.getPermissionbit(Permissions.map[name] as number, this.allow)){
return 1;
}else if(
@ -319,7 +322,7 @@ class Permissions{
}
setPermission(name: string, setto: number): void{
const bit = Permissions.map[name] as number;
if(!bit){
if(bit===undefined){
return console.error(
"Tried to set permission to " +
setto +

View file

@ -44,9 +44,9 @@ export{ Role };
import{ Options }from"./settings.js";
class PermissionToggle implements OptionsElement<number>{
readonly rolejson: {
name: string;
readableName: string;
description: string;
name: string;
readableName: string;
description: string;
};
permissions: Permissions;
owner: Options;
@ -177,4 +177,4 @@ class RoleList extends Buttons{
this.onchange(this.curid, this.permission);
}
}
export{ RoleList };
export{ RoleList, PermissionToggle };

View file

@ -452,6 +452,7 @@ p {
/* display: flex; */
width: 100%;
background: transparent;
flex-shrink: 0;
}
hr {
border-style: solid;
@ -538,9 +539,11 @@ hr {
flex-direction: column;
flex-shrink: 1;
min-height: 0;
height: 100vh;
/* height: 100vh; */
/* width: 100%; */
position: relative;
height: 1in;
flex-grow: 1;
}
.timestamp {
@ -1268,7 +1271,7 @@ span {
.flexttb{
display: flex;
flex-direction: column;
max-height: 100vh;
/* max-height: 100vh; */
overflow: auto;
/* margin-bottom: 1in; */
/* padding-bottom: .1in; */
@ -1371,6 +1374,8 @@ span {
display:flex;
justify-content: space-between;
width: 100%;
height: 100dvh;
align-content: space-around;
}
.userflex{
display:flex;
@ -1529,6 +1534,7 @@ span {
.scroller{
padding-bottom: .2in;
flex-grow: 0;
flex-shrink: 1;
}
.suberror{
animation: goout 6s forwards;