discorddb

package
v0.0.0-...-2232ac3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteMessageWithLog

func DeleteMessageWithLog(s *discordgo.Session, channelID string, messageID string) error

DeleteMessageWithLog deletes the message after displaying the content of the message

Types

type DataBase

type DataBase struct {
	Session   *discordgo.Session
	Tables    map[string]*Table
	ChannelID string
}

DataBase is a struct for using Discord as a database

func New

func New(s *discordgo.Session, channelID string) (*DataBase, error)

New is a constructor for DataBase

func (*DataBase) Create

func (db *DataBase) Create(key string) error

Create creates a new table

func (*DataBase) Delete

func (db *DataBase) Delete(key string) error

Delete deletes the table

func (*DataBase) Read

func (db *DataBase) Read(key string) (interface{}, bool)

Read reads the value from the Key

func (*DataBase) Save

func (db *DataBase) Save(key string) error

Save saves the table corresponding to the key in DataBase

func (*DataBase) Update

func (db *DataBase) Update(key string, value interface{}) error

Update updates the table

type Table

type Table struct {
	Value     interface{}
	MessageID string
}

Table holds the data marshalled to JSON and the corresponding Discord message

func CreateTableFromMessage

func CreateTableFromMessage(s *discordgo.Session, m *discordgo.Message) (string, *Table, error)

CreateTableFromMessage creates a table from the message and returns the key and table

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL