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 { mainuserjson } from "./jsontypes.js";
import { Localuser } from "./localuser.js"; import { Localuser } from "./localuser.js";
import { MarkDown } from "./markdown.js"; import { MarkDown } from "./markdown.js";
import { Settings } from "./settings.js"; import { Form, Settings } from "./settings.js";
import { User } from "./user.js"; import { User } from "./user.js";
import {guildjson} from "./jsontypes.js"; import {guildjson} from "./jsontypes.js";
import { PermissionToggle } from "./role.js";
import { Permissions } from "./permissions.js";
class Bot{ class Bot{
readonly owner:Localuser; readonly owner:Localuser;
readonly token:string; readonly token:string;
@ -247,5 +249,29 @@ class Bot{
body: JSON.stringify(json), 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}; export {Bot};

View file

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

View file

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

View file

@ -177,4 +177,4 @@ class RoleList extends Buttons{
this.onchange(this.curid, this.permission); this.onchange(this.curid, this.permission);
} }
} }
export{ RoleList }; export{ RoleList, PermissionToggle };

View file

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